4 ms·
> elaborate 3d scenes built up out mostly out of distance field primitives, a stunning demonstration of the power and flexibility of the technique. Also a demo
by gfxgirl 7y ago
> elaborate 3d scenes built up out mostly out of distance field primitives, a stunning demonstration of the power and flexibility of the technique.
Also a demonstration of how slow that technique is. I can run stunning games with entire cities of buildings and people and cars and mountains in the distance and trees and grass and clouds all running at 60fps or faster. Or I can run some SDF that runs at 0.2 to 3 fps on the same machine.
Don't get me wrong, I'm blown away by those shaders but they aren't remotely performant.
This particular technique might be okay but you'd still arguably be better running it on 4 quads that make a frame. There's no reason you want to be computing pixels in the middle of the frame where there is no shadow.
- raphlinus 7y agoIt depends on how you use it. The Shadertoy examples demonstrate that it's possible to do a whole scene as one shader, but I agree the performance is not great for complex scenes. This one is intended to be used as part of a 2D renderer. It would be easy to write this up as a fragment shader (and the parameter calculation can be done in either the vertex shader on the CPU). I believe, without having tested it yet, that it would be lightning fast, especially because the heart of the erf approximation can be done with inversesqrt. I'm also working on a compute-centric renderer, and for that I expect it to be even faster. There, I'll break the scene into tiles, and for each tile there can be an analysis of what's inside. So tiles on the interior of a large blurred rounded rectangle can be solid colors, the edges can just compute a 1d function, etc, and only the corners with the full version. Keep in mind, what's done in many, if not most, rendering pipelines is to render the rounded rect into a buffer, run a Gaussian blur shader over that buffer into another one (often two or more stages for the separable version of the kernel or something like a dual Kawase blur). Even the simple fragment shader version should massively outperform that.
- kroltan 7y ago> Also a demonstration of how slow that technique is. Or how fast! SDFs can compute approximations of volumetric effects that on a regular raytracing engine would take a few seconds to render. Additionally, games have been using (baked) 2D SDFs [1] for ages to render world-space (and recently even plain screen-space) text, it's plausible to use the same technique to generate other kinds of shapes. It can be very useful for UI elements since you can have just a few source assets, and with some shader parameters you get fully animatable effects such as drop shadows, glow, and even normals. [1]: https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007_AlphaTestedMagnification.pdf https://steamcdn-a.akamaihd.net/apps/valve/2007/SIGGRAPH2007...
- BubRoss 7y agoYou are conflating multiple things here. Marching through volumes for volumetric effects are not going to be made faster by SDFs generally because you need to march through the videos from an eye ray and march back to the light sources while doing it. 2D signed distance fields are also different, since as textures, each shader fragment is still looking at the same pixels it would have seen before and is just able to do a little extra work with the values it finds to create sharp text.
- deleted 7y ago[deleted]
- dahart 7y agoLots of amazing SDF examples run at 60Hz, are you thinking of some specific examples that run at 3fps and below? It’s not really fair to compare SDF with rasterizing using a game engine that has bounding volumes. They are different things. Some of the terrain & grass SDF examples run faster than any raster engine can ever do it. > you’d still arguably be better running it on 4 quads Nothing about the article precludes doing that, right? The technique would work without modification if you attach it to some quads and leave out the middle. Probably even better yet, just exclude the middle from any calculations in the shader and use 1 quad...
- Lorin 7y agoThe folks at CIG (makers of the upcoming Star Citizen game) are hard at work optimizing SDF for shaders.