So my scene consists of a bunch of procedurally generated particle clouds (not using particle systems, they are just standard meshrenderers) and a textured ground plane. How would one go about casting cloud shadows on this terrain? Obviously the distances are too high to use realtime shadows.
I was personally thinking of a custom shader that takes data from the cloud system (like a noise texture to indicate cloud density?) to calculate light at a pixel. Only problem I can think of right now is continuity as I am using multiple terrain meshes arranged in tiles (made in Blender, not using built in terrain component). I am using the Universal Render Pipeline with Unity 2019.4 LTS. I would like to hear your ideas on the subject. All feedback is welcome. I will be expanding this post in the future to accommodate my own findings.
Generate a top-down cloud shadows texture (render just your clouds into a rendertexture via another camera), but use a replacement material that’ll render them in black/grey, and set the camera clear colour to white. Maybe blur the result, too, to soften the shadows.
Then in your terrain shader, generate UVs from the world X/Z position, sample the cloud texture, use that to darken things (ideally combine it with the directional light shadowing)
If the world is small and the clouds are static, you can create the shadow texture just once on level load. But if the clouds move (or the world is huge and you’re only rendering the clouds shadows for part of it), you’ll have the performance cost of re-rendering.
Thanks! But can’t you just set the color format of the render texture to grayscale? I haven’t checked personally but that should be an option and doesn’t require you to use a replacement material. Also, since I am using perlin noise to position the clouds, would it be a good idea to just use the noise texture? I could use a power function before generating the texture to make it more represent the cloud contours. I’m working on a low poly game so pin-point accuracy provided by a render texture is not necessarily needed.
Upon second thought, the render texture is definitely the route I’m going with. Being of low resolution, the perlin scalar field I’m using would need some sort of interpolation to give smooth results, which sort of removes the benefit for me.