-
Notifications
You must be signed in to change notification settings - Fork 1
Rendering Technology
Ray casting is a simple and efficient method for rendering solid models that have not been triangulated. Using a technique called sphere tracing with distance fields, arbitrary shapes can be easily rendered using the GPU's fragment shaders. This allows us to interactively modify parameters without the expensive triangulation step. Furthermore, bandwidth between the client and server will be greatly reduced and rendering a few primitives should be faster than rendering the equivalent triangle mesh.
- Interactive editing
- Well suited to electronic components which tend to have simple parametric shapes
- Easy to scale performance vs quality through parameters
- Low bandwidth solution
- Simple, elegant code
- Should be fast to render simple components compared to complex meshes?
- Depends on model complexity...
- To be tested...
- Almost no javascript overhead
- Can be used as a completely indedependent module (no server required) for other applications
Guide lines are very useful for engineering applications.
- How to determine correct placement of lines?
- Especially arcs and circles are tricky.
- Many Symmetric operations are nearly free
- Absolute value for reflection (mirror image)
- Modula for repetition along an axis
- Others
- Use geometry representation to calculate normals (I.e. 90% of stuff is planes / cylinders / spheres etc with trivial normal)
- Compile spatial structures into the code (I.e. use half-spaces as kd-tree planes)
- Use sphere-tracing as a fall-back only for non-analytic functions
- Use hierarchical sphere tracing (share probe distance between pixels)
- Wrap primitives into bounding boxes
- Many union operations do not need to be in the same shader.
- Also boxes can be drawn without any tracing whatsoever.
- Avoid recompiling shaders...
- Better to recompile one large one versus lots of small ones?
- If necessary generate mesh offline while editing
Mapping textures to parametric objects will occur in the fragment shader.
- TODO: Should the PCB be rendered as a triangle mesh with a masked texture of the footprint? Perhaps, using a simple "parallax mapping"-like shader for depth.
- TODO: Alternatively, raycast against a primitive extruded from the 2d vector footprint. (Might be need for the export to OpenCASCADE.
- Global rendering would allow nice ray tracing and ambient occlusion effects which is something to keep in mind for the future... (Especially ambient occlusion might be handy for engineers)
- Overhead of recompiling shaders?
- WebGL does not support gl_FragDepth in the fragment shader which would come in very useful for this technique (E.g. it's not possible to perform CSG operations with rasterized primitives without using render-to-texture, and floating point textures are only supported through the OES_texture_float extension)
- Complex shaders may confuse ANGLE in windows when translating from GLSL to HLSL
- Anti-aliasing could be tricky to implement
- Derivatives which could also be useful (esp for anti-aliasing) is only supported as an extension, OES_standard_derivatives
- http://codeflow.org/entries/2011/sep/11/webgl-and-html5-challenges-for-the-future/
- Keep in mind possibility for transparent objects (LED's etc)
- Distance Fields
- Sphere Tracing
- A little example of sphere tracing in WebGL - The article
- A little example of sphere tracing in WebGL - The demo (Very unoptimized and has added effects such as ray traced reflections and ambient occlusion)
- Approximate distance to spline / surface
- The classic Object-object intersections page
- Another distance fields demo
Since JavaScript is used on both the client-side and server-side it would be advantageous to create the solid modelling language as a JavaScript library. This language must cross-compile to GLSL for the renderer and (possibly to Python?) for the exporter.
All language operations must map to operations available in the server-side exporter (e.g. OpenCASCADE).
Since the user can send JavaScript to the server for exporting models, security needs to be kept in mind. Code will most likely need to be sanitized (perhaps enforce a some kind of guarantee that all functions will must be side-effect free, or some kind of sandbox on the server side?)
- TODO: Cross compilation could be achieved by building an abstract syntax tree in JavaScript...
The scripts should include line numbers in script when an error occurs. If everything is in a try-catch block, can we retrieve sufficient info from the err parameter? http://www.w3schools.com/js/js_try_catch.asp
Appears to work well, the browser gives lots of info: http://jsfiddle.net/Zf37s/2/ (tested in chrome & firefox)
Since JavaScript does not support operator overloading it might be useful to add this with a small parser later on.
SceneJS needs only a few small modifications to work with the proposed technique