I've been working with a lot of volumetric rendering related stuff recently, and sometimes it involves creating volumetric textures. The another method is to use procedural content in the volumetric renderer, at least in real time applications. So I've been exploring the ways of creating volumetric textures for different purposes. Since I work with Unreal, I tried baking volumetric material setups using blueprints. This method work nicely, but sometimes it takes long and requires a lot of back and forth to make iterations and get the right result. The feedback isn't the best. So I figured, I could just use a similar setup in Substance Designer, to what I do in Unreal. This tutorial isn't a detailed explanation of how exactly volumetric rendering works, or how to make a ray marcher. If you are not familiar with the previously mentioned topics and you are interested, check out these articles:
https://shaderbits.com/blog/authoring-pseudo-volume-textures https://shaderbits.com/blog/creating-volumetric-ray-marcher These two links have nice in depth explanation of how does these techniques work, they cover the principles. So I'm not going into details regarding those topics. But its important to read the first link in order to understand how the 3d uv setup works in both applications(Unreal and Substance).
So if you are familiar with the content of the first link, you will immediately think oh right, otherwise this is how the volume texture uv setup looks like:
From the texture resolution, and tiles per sides, we can see that I'm generation some 256^3 resolution volumes here. The tile sampler on the bottom provides the z coordinate. Its color parameterization is set to display pattern id in increasing order. This way, the top left slice will be the bottom of the volumetric texture when its rendered.
Lets go further. There are several nodes in SD to create 3d masks or volumetric data. The most basic one is the 3d volume mask node:
In this example, I've set the feather parameter to be almost zero, to get uniform density everywhere. This is what the result looks like Unreal, when its rendered using a ray marcher :
Not very interesting of course, but lets go in small steps... The 3d volume mask node can generate other shapes too. Lets try a cube with small feather parameter.
More interesting, but we try adding some feather.
Again, better, because we can have more softness to it. Using uniform density can cause to visible value clipping. For example, I didn't let this ray marcher to go above density of one, and marching a uniform density texture can make it quickly reach max density.
You can generate cylinders too using the 3d volume mask node, but didn't make an example for that. Instead, I'm going to show some 3d noises:
Perlin:
Perlin fractal:
Simplex:
Worley:
And finally, lets combine a box with some worley noise:
All together:
And here is the link to the download of the generated textures made for this tutorial:
https://www.dropbox.com/sh/tstg6di89m0zkeo/AACfIO9Ff5VGLQi2VkwsMW-na?dl=0 I hope you the tutorial, and if you are interested about more of this kind of stuff, please let me know in a comment.
Replies
Provided you do all the work within a single node I've not seen any issues dealing with numbers way outside the 0-1 range - assuming you're in a graph with a floating point bit depth at least
The problem with tiling when using volume textures or flipbooks is this:
https://shaderbits.com/blog/tiling-within-subuv-or-volume-textures
Basically bilinear interpolation breaks the x y tiling because the neightbour slices around a given slice. So the edges of the next / previous slice would start to blend in because of how the slices are laid out. The workaround for this, is to push each slice a 1 pixel smaller on each direction, and have 1 pixel tiling within the texture on each side, like this:
However, unfortunately it seems like there is another issue with the 3d noises in Designer. They don't seem to be tiling anyways. So if this turns out to be the case, noises are better be baked inside Unreal.
https://shaderbits.com/blog/tiling-within-subuv-or-volume-textures
I will talk about this more, and the shape and other nodes in the followup in the weekend.I will also upload the seamless noise bakes from unreal so other people don't need to set the whole thing up.
This is beautiful work by the way, really cutting edge. We don't see enough of this in game releases.
That's not to say there aren't use cases but it's like tessellation or layered materials in the sense that you really, really have to need the tech before you can justify implementing it in production.
@Skullbear94
Inigo quilez has some pretty simple explanations of how to generate this sort of information in Shader code on his website - he's pretty much the go to resource for that sort of thing.
At one point I was considering making a beginners write up regarding the topic but its a big one and there are many techniques, and its hard to not get very technical. When I started to learn about this stuff, i used Ryans blog and I can totally agree, it can look scary for first. Inigo Quilez has some very nice resources as well, like it was mentioned by poopipe. But they are really not beginner material in the moat of cases. They require solid understanding of the basics.
https://youtu.be/RvoU3P2ZG18
Animating it and rendering into an image sequence should be straight forward and easy. A trick can be done when rendering it so its automatically composed into an atlas. You could have copies with different height setting laid out in a way that a volume texture requires, and render it in one go without animating the slicing geo. I'll do more tests soon, but I think array can do this easily. So one can have a template max scene for baking volumes, and all that needs to be done is to input the source mesh, and slap array with proper settings on it. Then bake it using a plane....
https://youtu.be/X_T1eGeJtGw
Unfortunately the array method is so slow, it freezes max even with simple meshes. But moving the boolean object works nicely.
https://youtu.be/BkAmOWc838o
I rendered an image sequence, and put them together using a sprite sheet script in Photoshop.
Ok this technique works great, at least on such simple meshes. The setup is fairly straight forward, and easy to handle. I'll try a more complex mesh soon and post the results.
https://youtu.be/k3tjyG7Fc00
https://youtu.be/wGc3KGGVcS4
Mesh is from here:
http://casual-effects.com/data/index.html#mesh4
Chapter 1 - https://polycount.com/discussion/208918/ray-marching-chapter-1-the-very-basics-and-all-about-the-clipping#latest
Chapter 2 - https://polycount.com/discussion/208922/ray-marching-chapter-2-the-first-not-fancy-ray-marcher#latest
Bunny volume also available here:
https://www.dropbox.com/s/kxz8g08lr63p1t6/bunny_volume.tga?dl=0
Also forgot to reply back Obscura, the main benefit of the 3d volume texture is its all on the hardware to sample the texture rather than the pseudovolumetexture uv stuff. Last I saw Ryan's new clouds stuff uses the blueprint -> 3d volume texture workflow. (https://twitter.com/ShaderBits/status/1201529560879251457)
Or the another way is to not use volumetric texture asset, but simple call (in a custom node) : "PseudoVolumeTexture(yourtex,yourtexSampler,uvw,slicesperside,totalslices);
The volumetric texture asset it there since 4.22 I believe. Both methods has downsides and benefits. In these particular examples, I used the textures with the volume material domain which has a documentation page so you can check that out if you haven't. You can also use them in a ray marching shader.
https://docs.unrealengine.com/en-US/Engine/Content/Types/Textures/VolumeTextures/index.html
https://shaderbits.com/blog/creating-volumetric-ray-marcher
If you are planning to use it with the volumetric fog, you need to be aware that it will not cast self shadow and this usually requires some specific shader. The another downsides of the fog in my opinion is the temporal accumulation which can cause ghosting, and the voxel size depencence on screen size. Basically you will need some really high settings to make them look good at far too. For some applications, its still usable, if you don't have much high frequency detail. For anything detailed, or needed to be properly lit, and shadowing, I'd rather recommend a custom raymarch shader.
Hope this helps.
I was targeting mobile and looking at creating some cheap dense looking fog shafts to place around windows ( I'm not worried about shadowing or shading too much either, i will fake what i need) and true volumetric fog on mobile is a no go right now!
I was playing with the "sphere gradient 3d" node in material editor which looks nice on mobile but wanted something with a box shape!
@Obscura one question for you. do you know how can I fix the texture slicing artifact on the side of the baked volume texture? I was following the tutorial on this page https://www.overdraw.xyz/blog to create volume texture in unreal.
this is the top view of my volume texture
this is the side view of my volume texture
my material graph
thanks