1
$\begingroup$

So ive been using Signed Distance Functions in rendering recently....

And I wanted a really efficient way to make custom shaders for the SDFs themselves and render them very quickly...

I wrote a raymarching engine within blender to start applying my effects... But Ive realized that for some reason, I cant translate the 3D position of the SDFs in the raymarcher...

It renders the SDFs as a surface shader... so it uses the vertex color on the surface of the cube, not the SDFs inside...

So using a stack of planes, I can estimate what it SHOULD look like: enter image description here

And this is fine and dandy.... but its a terribly inefficient way of rendering SDFs, and its incredibly slow / memory intensive...

meanwhile, a raymarcher is many times faster and more efficient.

Sadly the raymarcher uses the surface as points.... so when I plug in my colors, it overlays the colors on the host shape's surface (its a cube)

So it results in this horrid output:

enter image description here

What I want to know is, Can I take the output positions of the SDF and render the color at that location on the surface of the cube? So that way its using the internal color, not the surface color...

$\endgroup$
3
  • $\begingroup$ I think I understand what's your issue, and I'm not sure how you implemented your SDF. but in the end you display the surface of the SDF anyhow, so only the surface color should suffice(?). anyhow your issue might be to due of geometry, a quick and dirty fix could be to subdivide the cube. you could try adaptive subdivision for efficiency. otherwise more info about your implementation would help $\endgroup$
    – Hanan Beer
    Oct 14 at 5:13
  • $\begingroup$ @HananBeer Theyre Signed Distance fields, theres really only 1 way to implement them... Calculating distance. I just use vector math. The file is available here if you want to use it, its the SDF Library blend file. github.com/MisterSirCode/Blender-Utilities $\endgroup$ Oct 14 at 13:23
  • $\begingroup$ As for the surface color, it doesnt use the surface color. Theres no meshes. SDFs are just math. And blender supports 3D vectors in shaders, so the SDFs are far under the surface. The slight blue and red you see on the surface of the cube is a result of the SDF's Distance. Its always blurry / like a gradient until you use a Greater Than 0 node, which turns it into a flat shape with sharp edges. $\endgroup$ Oct 14 at 13:25
0
$\begingroup$

You had your SDF connected to surface, that's why. I connected to volume and it seems to be the desired result.

enter image description here

$\endgroup$
3
  • $\begingroup$ Its raymarching... not the volume $\endgroup$ Oct 18 at 21:34
  • $\begingroup$ Also that layer node is only meant for a stack of planes. SDF Volume plugs into volume $\endgroup$ Oct 18 at 21:34
  • $\begingroup$ SDF Raymarch is what Im trying to fix right now... I cant color the surface of the SDFs correctly in the surface renderer $\endgroup$ Oct 18 at 21:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.