← Blender.Today
  • 1
  • Published 15 Jan 2024

Easy Signed Distance Fields In Blender | SDF NodeBox Intro 1

LightRayCreativeDigital
15 Jan 2024

18 Comments

Hi LightRay, I bought the NodeBox and I like it. Do you think it is possible to create a displacement shape like a infinite "snake scales" for example ? An if so how would you do it. I I played a bit with the NodeBox but I always have the problem, that the top of the scales is not smooth and rounded.. It is always like planar or plateau surface and gets some sharp parts when rounding and softening. Hope you have some time to explain it if it is possible. Would be nice to know how to achive this. Anyways. I like it! Have a good time!

1
LightRayCreativeDigital Author

Hi Fred! First, thanks for the support, and I'm glad you're enjoying the node pack!

Apologies for the incoming wall of text; there was a surprising amount to unpack here, and creating a procedural snake scales shader was an intriguing challenge.

Before I go further, I'll mention that while I was typing out my response here, I decided to do a quick YouTube search to see if anyone's come up with a better solution than what I was able to come up with. I did find this video ( youtube.com/watch ) by "grinsegold," which I'll refer you to because I think it's just a better solution than mine. Their version is simpler to set up and more displacement-friendly but does have a slightly different look.

As for your question about a snake scale texture, I'm not 100% sure what you're asking, as there are a couple of ways it could be interpreted, so I'm just going to cover everything I can think of.

What I'm confused about is when you say that the top of your scales are being cut off like a plateau. I'm not sure if you're talking about the "3D top," as in the actual displacement away from the surface of your model is being clamped, or the "2D top," as in the rounded part of the scale is being cut off by the edge of the repeat infinite cell.

I suspect it's the latter, but if you are talking about the first issue, it sounds like you have a node clamping your height value somewhere. All the math nodes have an easy-to-miss "Clamp" checkbox, which clamps their output between 0-1. I recommend going through your node graph and double-checking that you don't have it enabled anywhere you don't want it enabled.

The other possibility I can think of is that maybe you're using the feathering value in the SDF To Mask node to create your height gradient. If that's the case, then anything outside the feathering radius will have a value of 0 or 1, and these areas will create that plateau effect. If this happens, you'll need to ensure that the feathering value is large enough to cover the entire visible area; then, you can use a float curve node to shape the surface of your scales.

If it is the latter issue, as I suspect, it becomes a much trickier problem to solve and is more a problem for UV manipulation than Signed Distance Fields.

I tried playing around to see what I could come up with, and while it took me a couple of hours to figure out, I did come up with this: ___. I've also included an image of the shader graph in that link if you ( or someone else ) need to re-create it, as it's too large to explain in detail through messages.

The gist is that I'm creating an infinite grid, shifting every second row to the side by half a cell to make the alternating grid, and lastly, cutting out quarter circles from the bottom corners of each cell and re-constructing a continuation of the coordinate space of the two lower cell's coordinate spaces to create a "scale-shaped" coordinate space. Once you have that, you can turn it into a height map with a circle SDF and float curve to control the rounding of the surface of the scale, combined with the Y coordinate of the new coordinate space to make the rounded ends of the scale stick out more. It's not perfect, and I'm sure there are quite a few places it can be improved, but that's the best I can do.

I hope this helps! Thanks again for the support, and please keep me updated if this works out for you.

LightRayCreativeDigital Author

Ok, so for some reason, I couldn't post the link to the images. Let me try this: imgur.com/a/RJGFAsT

1

High Ray, first of all thanks a lot for the long answere.. It is much more helpful than saying " it can be done". What you show is more then less I tried to create. Think you got me right. ;) Maybe try to do a tutorial of it because like you wrote it took you a couple of hours to figure this out as the creator of this nice nodes. So it would take me some days ;) .. Like it and thank you very much for your long answere. I`ll play with your Nodes. I realy think it they are great and also the the asset browser visualisation. And wish you success and some new creative ideas to improve it more. Hope this becomes more advanced than it is right now. Like it. :)

1
LightRayCreativeDigital Author

I can definitely do a tutorial! I'll move some plans around and try to have it uploaded for Friday.

When you mention that you hope the pack becomes more advanced than it is now, is there anything in particular you would like added?

sure ;) a more advanced shape modeling system,, imagine a shape created by blenders super nice editable curves system projected to your nodes in a very easy way.. just shape a curve and make it to your SDF system... Should be possible. .. I think ... without many extra clicks.. for example... anyways I do like your approach to the things.. keep it clean and as much easy as you can...

1
LightRayCreativeDigital Author

Hmm, that's a tricky one... I'll need to spend some time thinking about how to do that.

Traditional SDFs are made with just math and UV manipulation, so in the pure shader sense it's not possible to create one from an external curve object, but I can think of a few ways that I might be able to construct an SDF using geometry nodes and to get that data to a shader.

I'm making zero guarantees, but I'll see what I can do.

Thanks for the request!

Maybe think about a canvas 1x1 meter and this is the canvas for the curve.... think this could be a good start. And use this as a base for the UV projection.. Just an rough idea that could work...

LightRayCreativeDigital Author

Yeah, that's one of the possible routes using geometry nodes I thought of first when you asked for this (and it's likely the most promising route). Specifically, my mind went right to this post by Blender Studio about a curve-to-stitching tool they made with geo nodes for the Charge open move: studio.blender.org/films/charge/3aee478ba5e53a/

The issue isn't so much generating an SDF from a curve in geometry nodes, I'm fairly confident that I can figure out a way to do that, the bigger issue is getting that data to shaders. I'm not super familiar with sending data from geo-nodes to shaders yet, but I believe that, for the most part, it can only be done through vertex attributes. This would mean that the resolution of the SDF would be dependent upon the resolution of the mesh, and you would need a pretty dense mesh to have enough data for it to be usable.

Like I said, I have a few ideas floating around for how I might be able to deal with that to transfer the data more efficiently (mostly around editing the topology or custom UV maps, but both of those are still going to be at least somewhat dependent on the geometry).

I'm sorry, but I don't really have time to look into it this week. I'll try to do some tinkering next week if I can find some time though.

o.k. I understand. So I think it would be possible.. 1x1 m needs al lot of subdiv in geometry nodes. That is not the way to do it. But hey.. Think your nodes are great. And there is a way to do it..

LightRayCreativeDigital Author

Hey Fred, just wanted to let you know the tutorial you requested is uploaded and live now: youtu.be/_iVLanJDOzU

Hope this helps!

Fred

Super nice ! Thank you very much. I ask myself if it would be possible or if it makes sense for your SDF NodeBox to add some new nodes doing this kind of UV creation and row offsetting and overlapping. ( that overlapping might be difficult because it is more or less fake.. but maybe.. ;). I mean the thing you did in the first part of you Video.And also that rounding curve node Idea for displacements and bumps. Would be cool Anyways thank you very much and have a nice weekend and.. Kind regards! :) Fred............

1
LightRayCreativeDigital Author

Hi Fred! Apologies for the late response; I didn't see this message until now as I didn't receive a notification. Perhaps another platform would be better for longer conversations like this?

Thanks for the feature requests! Both should be pretty doable, and I can see the utility of including them. I'll try to find some time this week or next to add them in and update the node pack.

Also, the Float Curve node will already work as is with SDFs. You can see an example of that in the pattern cube video where I use the node to create the rounded displacement for the threads: youtu.be/07rG3qMAMrI

Thanks again!

-Ben

Fred

Perhaps another platform would be better for longer conversations like this?

yeah if you like. maybe discord or whatever. I realy like your knowledge and I`m more from the other side.. more an "artist" and hate it to figure out things again and again for special cases.. but think im not stupid when it comes to blender. And lots of respect to your "clean" aproach to that procedural stuff.. hope you understand what I mean. Anyways.. If you like to stay in contact I would be happy to share ideas and discuss abaout them.. Think it could have a lot of potential.

1
LightRayCreativeDigital Author

I could set up a Discord server for the channel. Is that something you would be interested in joining?

Fred

Yes sure. Would be nice!

1
LightRayCreativeDigital Author

Done! It took longer than I thought it would, but everything should be set up now. It seems I can't post the invite here, but you should be able to find it on my youtube, Hope to see you there!

thats cool ! ;) I tried to create some shapes procedural but this is much more advanced and well thought through. Thanks.

1