5 ms·
There's a disclaimer missing from this article (and many others like it), writing a frag shader to generate 3d geometry is generally not the ideal way to actual
by fenwick67 7y ago
There's a disclaimer missing from this article (and many others like it), writing a frag shader to generate 3d geometry is generally not the ideal way to actually render stuff unless you're doing demos (with some exceptions).
The other thing that gets me is these articles say "here's how you write a shader" but shaders are much more than a fragment shader over the whole screen (like what shadertoy provides).
- gmiller123456 7y agoHe's using ray tracing, I thought this was the typical way of doing it. Do you have references on alternate methods?
- GuB-42 7y agoI think that GP's point is that signed distance functions are not the ideal way of representing geometry. If you are clever, and that's the whole point of the demoscene, your can design a good looking scene in a very small amount of space. However, when it comes to model real world objects or an artistic vision, they are not as effective as triangle meshes. An alternate method of rendering could use the marching cubes[1] algorithm to convert the signed distance field into a triangle mesh and then render it using more conventional techniques (rasterization). [1] https://en.wikipedia.org/wiki/Marching_cubes https://en.wikipedia.org/wiki/Marching_cubes
- fenwick67 7y agoTypically this is called "ray marching" and it is expensive. With a more standard forward rendering pipeline, you hand the geometry to the GPU as triangles, then your vertex shader tells the GPU how to move your geometry around, the GPU then handles determining which parts of which triangles are visible, then your fragment shader puts your textures on the triangles and handles lighting them.
- Arelius 7y agoWhile I don't disagree, SDFs in specific have the nice property in that you can converge on the surface much quicker than in standard ray-marching which has a very significant impact on performance, which is why given many scenes, SDF ray-marching can be much less expensive than the alternatives.
- Arelius 7y agoSo, specifically, he is ray-marching a signed-distance field. Which has some interesting properties. One of the major down-sides is it's often more difficult to create the boundary surface, fewer editors and the like. More common methods are polygons, subdivision surfaces, and nurbs. So, one common technique as you mentioned is ray-tracing, the key difference is ray-marching samples the world at intervals (often regularly spaced, but in SDFs you can search for the boundary since given any location, you know the distance to the closest surface) where ray-tracing you intersect each primitive directly, and normally build up data structures (BVH, for example) to minimize the amount of individual tests you need to do. Another common technique, used almost exclusively in every real-time case (games, CAD tools, etc) Is rasterization, where you project the triangles into screenspace and intersect them with the pixels, the main difference being that your outer loop is now "for each triangle" rather than "for each pixel" The differences might seem pretty subtle, and in a sense they are. But they have pretty enormous ramifications on the design of a renderer, how they handle content and their performance characteristics.
- packetslave 7y agoShe
- Zelizz 7y agoIt's she, not he.