#"Triplanar" volumetric shader

1 messages · Page 1 of 1 (latest)

uneven rivet
#

I have been trying, without success, to make a fog volume shader which samples 3 different textures on different axes.

I rendered the standard xy flipbook head on in embergen, then the xz rotated to the side by 90 degrees, then a final yz rotated above 90 degrees.

I can't figure out a way to blend them together. Doing anything "useful" on the z has been eluding me. Using a 3d texture works just fine but I can't really get 2d textures to do what I want.

Another option I considered was just lerping the showcased texture based on the viewing angle, but then I would need to billboard the volume, which sounds kinda ridiculous and defeats the purpose of it.

Can I fix this?

clever bane
#

Well show what you have tried

glass panther
#

I'm not sure you can meaningfully do triplanar sampling for a volumetric effect

#

Triplanar shading requires you to have a position and a normal

#

what is the normal vector for fog?

#

it doesn't point in a specific directino

uneven rivet
# clever bane Well show what you have tried

Any variation of manipulating W of the uvw. Tried blending with a xz/yz of a 3d procedural noise, tried blending with all 3 floats of the procedural noise.

Even tried adding time to z from the position node and adding back to time for the position input and that also doesn't behave how I'd expect it.

Also, tried a bunch of stuff but honestly, the way I test things is I have a throwaway shader that I keep adding nodes to. Then if that doesn't work, I disconnect them and add more nodes etc.

If I show you the shader graphs, you'll get cancer

uneven rivet
#

that's what happened when I tried to do triplanar sampling for the texture

#

well

#

is it techically triplanar if it's using 3 different textures? Maybe not

glass panther
#

I would define "triplanar sampling" as calculating UVs based on three orthogonal planes and then blending the resulting colors together based on how well those planes align with your normal vector

uneven rivet
#

I got this deranged result when I tried

uneven rivet
glass panther
#

Volumetric effects really demand a 3D texture

#

You need continuous values in every direction

#

Triplanar shading works because surfaces are 2D

#

You just need to handle the transitions between the three planes

uneven rivet
#

or, like, construct a cube out of the different samples of 2d flipbooks and add a volume inside but that sounds stupid

clever bane
#

You definitely can use three 2D textures projected on each axis, blended together to produce volumetric variance
But the pattern is revealed quite easily because any variation occurs per-axis

uneven rivet
glass panther
#

how are you deciding where to sample the fog? are you doing raymarching?

#

I'm using a volumetric fog effect in a VRC world that's raymarched and that uses a 3D noise texture

uneven rivet
glass panther
#

ah, right, there's a specific shader graph type for that

uneven rivet
#

3d noise textures are cool and they work, but not for my use case

clever bane
#

It works but there's lattice-like patterns that can be noticed

#

When not viewing along any axis directly

glass panther
#

i wonder if using non-orthogonal planes would help

#

it'd probably just make it look bad from different angles

uneven rivet
#

so is this method doomed?

clever bane
#

Well it does produce a result so that's up to you really

glass panther
#

That is better than I was imagining

#

but yeah, it's going to reveal that you don't have a single continuous 3D noise texture

clever bane
#

How good it is also depends on how much continuity the type of noise requires

uneven rivet
uneven rivet
#

I decided to try the hand silt thing the following way:

I forwent the simulation thing for the hand thing. I decided on a compromise, but better than just plain flipbook particles.

I decided I would bake the smoke around the hand with collision with embergen (which I did) and make variations of that.

But because of that, I can't billboard them, I need a consistent shape, hence this "solution"

clever bane
glass panther
#

quadplanar sampling

#

i found an example of someone doing six planes

uneven rivet
clever bane
clever bane
#

Anything that's occluded from the projections will start forming into the 3D gridlike patterns

#

If the textures also had depth information, maybe that'd enable some clever workarounds

#

But even without anything fancy this might work for simple use cases

#

Ultimately it's not possible to avoid losing data when stuff is overlapping

uneven rivet
#

that somehow hasn't occured to me till now

clever bane
#

I'd be surprised if they can
But more surprised if that's anywhere near acceptable regarding performance

uneven rivet
uneven rivet
#

it's not perfect but things could be tweaked to make it look better

#

and it has a negligible effect on performance

#

shader is trash, scaling should be tweaked etc etc

clever bane
#

Now it appears you're projecting from just one

uneven rivet
#

when I enabled the other volume

clever bane
#

Right
It does look like the second volume can "carve" density out of the first
Which is interesting but probably doesn't make a difference here, since you can do that within the graph just as well

uneven rivet
#

I didn't actually manage to do that tho

#

doesn't work like projecting textures on planes as Fen said

clever bane
#

I'm not in a position to test it, but I'm not aware of any reason why the same technique I used earlier in blender wouldn't work in shader graph

#

It should be as simple as sampling 3 textures, each using object space coordinates swizzled into xy, xz and zy respectively

#

Multiplied together

uneven rivet
#

I assume it has something to do with the slices

#

It doesn't really project it normally, it kind of divides it into slices where every slice is same on the y (for the xz one)