Home Technical Talk

The basics of creating pseudo volume textures in Substance Designer - Tutorial

grand marshal polycounter
Offline / Send Message
Obscura grand marshal polycounter
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

  • Noors
    Options
    Offline / Send Message
    Noors greentooth
    Yes this is excellent. You're raising the tech art quality bar around here. Thanks !
  • Justo
    Options
    Offline / Send Message
    Justo polycounter
    SMASHIN' that fav button on this thread
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Would you guys be interested in a followup, discussing intermediate techniques regarding this topic? Discussing revolve objects using curves, twist, etc, using this technique. There is a benefit of doing this inside Unreal though, or at least I haven't found a workaround in SD. We would need negative values in the 3d uvw calculation, in order to be able to bake seamless volumes. Like I mentioned, there are also ways of doing this in a procedural way, and it gives better (technically infinite) resolution depending on the implementation, for the cost of more expensive pixel shader. So this is a wide topic overall, please let me know which part you are interested in. I'm glad to see that you guys find this interesting.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    In the meanwhile, here are some examples of revolve objects using curves. A 4 and a 6 sided pillar, and the third example is a 2d texture with a procedural gradient - which is again, only applicable depending on the case, but might be more optimal.

  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    I'm a bit pissed so probably missing something but what's the issue with negative uv values?  
    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 
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Pissed? Anyway, you are right, 16F and 32F does work, so thanks for pointing that out.
    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.
  • ant1fact
    Options
    Offline / Send Message
    ant1fact polycounter lvl 9
    Obscura said:
    Pissed? Anyway, you are right, 16F and 32F does work, so thanks for pointing that out.
    I think he meant he was drunk :) Thanks for the tutorial!
  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    ant1fact said:
    Obscura said:
    Pissed? Anyway, you are right, 16F and 32F does work, so thanks for pointing that out.
    I think he meant he was drunk :) Thanks for the tutorial!
    That would be correct :)

  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Not seeing opinions regargint the followup. Which is kind of weird by looking a the amount of love for the first one. So please go on.
  • Zack Maxwell
    Options
    Offline / Send Message
    Zack Maxwell interpolator
    I'd be interested in the follow up. I'd love to see how the more complex shapes are made.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
  • Polynaught
    Options
    Offline / Send Message
    Polynaught polycounter lvl 11
    This is looking cool. I like the firy spike trap and the worley noise. How did you setup that 1-pixel-indent in designer?
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Hi. It can be done by multiplying the xy coordinates by 2*(1/resolution) and then  subtracting 1/resolution in SD, but as it was pointed out, unfortunately the SD 3d noises doesn't seem to tile regardless of the seamless uvws provided. It works nicely in the Unreal setup though. Here is the explanation of this:
    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.
  • Skullbear94
    Options
    Offline / Send Message
    Hey, I am a uni student studying games technology, hoping one day to be a tech artist. I was wondering if possible you could provide sources for where I can learn to ray march these kinds of volumetric materials in UE4, where you learnt etc. It would be incredibly useful, as Ryan Brucks shaderbits blog jumps into the subject at a bit of a higher level than I am familiar with.
    This is beautiful work by the way, really cutting edge. We don't see enough of this in game releases.
  • Eric Chadwick
    Options
    Offline / Send Message
    I did some volume textures awhile back for a proprietary 3d engine. Figured out a way using an animated Slice modifier in 3ds Max to render out meshes into volume textures. Also did tiling & looping animations as volume textures. That was a bit hairy though, and the results were a major memory hog. Fun to play with though!
  • poopipe
    Options
    Offline / Send Message
    poopipe grand marshal polycounter
    That's the main issue really, 3d textures are hugely expensive  in memory terms compared to 2d and procedural generation doesn't provide the sort of specific information artists really need.

    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. 
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    I wouldnt say that they are terribly expensive especially nowadays. A 256^3 volume has the memory consumption of a single channel 4k texture. But looking them up many times can be expensive and you do need to, in a ray marcher. There are some cool examples for in game usage, like the cloud system in Horizon Zero Dawn for example. There are some optims for it, but the shader code gets very complicated. You can use adaptive step size for example, and thats what they did. You can use4x step size until you hit something and then switch to small steps, and switch back to the cheaper setup when you are out of the hit media. I tried this out and it can give a nice speedup but this really depends on the volume you are tracing. Animated volumes, yeah now this has big memory requiremwnts for real. You basically cycle through a bunch of volume textures.

    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. 
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Procedurals are hard to treat right, and require a lot of tweaking to get the desired results. I experimented with them a lot. You can check them out in my Unreal sketchbook thread. They usually provide much higher quality though, and allow various shading and tracing methods. Using signed sdf volumes allows you to use diatance aided ray marching, which shortens the iteration a lot on a lot of pixels. This is the technique that they use in those fancy shader toys usually, because its very efficient and technically the simplest to implement. 
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    I did some volume textures awhile back for a proprietary 3d engine. Figured out a way using an animated Slice modifier in 3ds Max to render out meshes into volume textures. Also did tiling & looping animations as volume textures. That was a bit hairy though, and the results were a major memory hog. Fun to play with though!
    Thanks for the tip with 3dsmax  <3 I did a quick test with simple boolean , and its working great!
    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....
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    :)
    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.
  • cptSwing
    Options
    Offline / Send Message
    cptSwing polycounter lvl 11
    I did some volume textures awhile back for a proprietary 3d engine. Figured out a way using an animated Slice modifier in 3ds Max to render out meshes into volume textures. Also did tiling & looping animations as volume textures. That was a bit hairy though, and the results were a major memory hog. Fun to play with though!
    Most of this topic is *whoosh*-ing right over my head, but that seems like an wfully smart way of doing things
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Here is the result of the teapot bake from 3dsmax. I used 2 boxes close to each other for slicing using boolean. Applying "cap holes" on the teapot before the boolean yields better results.
    https://youtu.be/BkAmOWc838o
    I rendered an image sequence, and put them together using a sprite sheet script in Photoshop.
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    And a wild torus...
    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
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Standford bunny. There is a little error on one of the ears but overall I'd call this a success.
    https://youtu.be/wGc3KGGVcS4


    Mesh is from here:
    http://casual-effects.com/data/index.html#mesh4
  • Obscura
  • Skullbear94
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
  • cptSwing
    Options
    Offline / Send Message
    cptSwing polycounter lvl 11
    Yeah this is a great resource and as always, an interesting read. So I'll chime in and add my 'thank you', Obscura.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Just wanted to say thanks for the bunny volume. Trying to do this with Texture3d instead of the pseudo since UE4.21 supports it. Got one error but need to debug. 
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Cool. Show your results please! Are you talking about the "new" volume texture asset? I tried it myself but to be honest, I don't see much benefit of using it. I think it still calls the standard pseudovolume texture code when its placed in the material editor.
  • HnT1511
    Options
    Offline / Send Message
    I am wondering if raymarching is suitable to deploy on mobile headsets like Oculus Go or Oculus Quest. I have been experimenting with Ryan Brucks' raymarch shader in UE4 to visualize MRI data, but facing the challenge of making his shader to work in Oculus Go, they work fine on HTC Vive btw. Will there any optimization that will improve the performance at all? I am not much of a coder though...
  • DavidCruz
    Options
    Offline / Send Message
    DavidCruz interpolator
    Don't know if this post helps at all but i did a search and didn't see it mentioned at all.
    I was looking for a way to manually create a cloud image in marmoset, I've been wanting to do it forever my way... silly enough, came across some information that might be beneficial for this process, i found out you need or can use a blue noise gradient map, in a pattern form, here is an example:
    there was also a video about a guy talking about testing things out more and wanted to publish his works, idk the guys name i seem to have lost the video link, i thought i saved it, but it seems the unreal video i linked basically talks about the same thing.
    ^edit this is the video, i know its old, so probably not helpful.
    hope it helps someone.
    I wanted to point out the blue noise map, which was the point of the post in general, however my best guess is you are onto the next best thing?.


  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    The biggest possible optim is to run the shader in half res relative to the screen res. This would be done by slightly modifying the ray origin and ray direction definition so the ray origin van be rendered to a render target fom the players perspective. The Horizon Zero Dawn doc also mentions some optimizations regarding light sampling. Use only a few light steps, and even , switch to a cheaper lighting calculation after a certain density is reached. I also found that the amount of steps  in a density ray marcher can be reduced somewhat by using an sdf enclosure of the shape. This can be used to make rays accelerate as they go towards the object, instead of going in tiny uniform steps. This trick was used in horizon too. They start sampling the detailed cloud shader code only when they are close to the cloud surface. They didn't use sdf, but its similar, still.
  • haiddasalami
    Options
    Offline / Send Message
    haiddasalami polycounter lvl 14
    Yeah most of your optimizations are gonna come from running half or quarter res and upsampling. Also TAA helps a lot with step artifacts. 

    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
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    Yeah. Now there is an asset type for that in Unreal. Though, there is a downside of that. It doesn't have blueprint functions exposed so you can hardly script it. So when it needs to be changed during runtime, or do any scripting,a pseudo volume one is better. When its static or needs to tile, the non-pseudo one, of course.
  • beefeastwood
    Options
    Offline / Send Message
    What does your material setup in Unreal look like for this? I've been digging around everywhere and can't seem to find any examples of the material nodes for something like this! Thanks for the write up by the way! 
  • Obscura
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    There are 2 ways now to sample volumetric texture in Unreal. The first one is to create a volumetric texture asset from the original texture asset. Right click on it, ->create volumetric texture. Then set up its parameters, and after that, you can drag and drop it into the material editor, like you would normally do with a regular texture. This texture sampler requires 3d coordinates as uv input. world position or bounding box based uvw works. You can have a volumetric texture sampler in the custom node too by using "Texture3DSample(yourtex,yourtexSampler,uvw);"


    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.

  • beefeastwood
    Options
    Offline / Send Message
    Thank you for the info! Do all these methods use unreal volumetric fog? I was understanding that using the volume material domain required volumetric fog in the project to be in use. But i didn't know if there was any way of sampling a volume texture without using volumetric fog? 
    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
    Options
    Offline / Send Message
    Obscura grand marshal polycounter
    The second link is a tutorial about writing a custom ray marcher, so it doesn't require fog. Volumetric materials, whether its done with the fog or through a custom ray marcher, are expensive and can't really run nicely on mobile. This is because they require hundreds of samples. The best is to just model the lightbeams from geometry and add some simple unlit gradient shader. 
  • beefeastwood
    Options
    Offline / Send Message
    I figured they would be pretty heavy shaders! Was hoping there could things i can trim down and use some basics off it but thank you for the heads up! Yeah i think it will just have to be some fresnel/gradient effects to keep the fog shafts from looking like geometry! 
  • anniezhao
    Options
    Offline / Send Message

    @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

Sign In or Register to comment.