#How do i correctly render depth in a volume shader? (A cloud)

1 messages · Page 1 of 1 (latest)

scarlet crag
#

I have a cloud shader where im rendering data, and having lines appear in the data for intersections. the problem i have is im not handling the depth currently and the cloud shader is using

    Tags { "RenderPipeline"="UniversalPipeline" "Queue"="Transparent" "RenderType"="Transparent" }

how would i get a "depth falloff" for objects inside the volume, rather than use the volumes boundary for the depth?

in the screenshots provided

the left image shows that a bit of it is peeking out from the cloud)

the right image shows that if you look at it from the side, it looks like its WAYYY behind everything in the depth. when in reality it should be almost fully visible since its on the edge

white seal
#

You need to read the depth buffer in your fog shader and compare the pixel world position to the closest edge of the fog volume.

#

Then interpolate between the original pixel and your fog color accordingly.

scarlet crag
#

thanks for the quick reply @white seal ! is there any guides or docs that can help me get started with this?

#

i assume depth falloff is a thing? like its not like im choosing front or back right?

#

i can say, this is 80% covered by the fog

#

all of my shader code is HLSL, im not using shadergraph

white seal
#

This is up to you to calculate. Should probably get the closest edge and calculate the fade from the distance to it.

white seal
#

As for the docs, the unity manual basically. + the shader library on github(or in your project package cache).