Is it possible to create a depth texture based on only Y value and us this as an alpha? Creating a fog that only is affected in Y space that is?
I’m not sure what you mean. A texture that stores world space Y position for each fragment?
That might be it. I’m not sure? What I want is a fog only affected by height. I want to use it for an underwater scene so when you look down into the deep it gradually fades to dark. So I was thinking render a depth map to texture and use that? Am I thinking totally wrong?
one easy and (maybe cheesy) solution would be to create a post effect for that. render to a 2D plane in front of the camera, transform the coordinates to world space and compare their y values to a reference value (where fog should start). blend with the results of GrabPass with a fog value of your choice.
this sounds probably very cryptic, but maybe it gets you on the right track.
have a look at Unity - Manual: ShaderLab command: GrabPass
if i have the time next week, i might post a quick and dirty example.
Thanks alot! That seems like a good way to go. It is abit over my head at the moment but atleast I have a direction to start walking in.
I’m using a terrain so I can’t assign a custom shader to it so I guess I need to sample the whole scene in an image effect. hmmm
you can write an own terrain shader or enhance the present one. its base pass and add pass shaders are in the built-in shader zip file you find above in resources - assets