I’m trying to work out a really cheap and easy way to generate shadows from a texture, which is mapped to an object based on World-Space Coordinates.
The Texture is a simple greyscale map of tiling clouds. The texture is mapped based on World-Coordinates (WorldAlignedTexture material function) so that it’s completely seamless around the Earth sphere. The idea is that as you get closer to the Earth with the camera, the main cloud layer doesn’t hold enough detail, so I fade to tiling clouds instead which can therefore, be much more detailed. Since you’re so close at that point, you don’t see the tiling either.
What I now want to do is add shadows to those clouds, which is easier said than done. The idea is to use the same texture (or a slightly blurred version), invert it to create black areas where the clouds are and multiply that by the albedo/diffuse channel to create faked shadows. Of course all this would do right now is multiply straight underneath the clouds and you wouldn’t see anything, so instead I need to offset and distort the UV’s slightly to create ‘projected’ shadows.
This is where I’m at so far. All this does is offset the Side and Top layers of the World-Aligned Texture to create offset shadows. Basically This works fine for the top and sides of the Earth, but doesn’t work for the area facing the sun. (The reason for the Multiply * -1 is because my Light Vector faces the negative X axis, so I have to flip the direction).
Now, I had a version which DID distort the UV’s facing the sun, which multiplied the UV’s of the front-facing texture so that it ‘skewed’ outwards. This works, but because the texture at the top and sides isn’t also being skewed, I get seams because the top & sides and the front don’t line up.
I’ve attached a hastily drawn image of what I’m trying to achieve with the UV’s, which essentially skews them over the earth from the Light Vectors direction. The trickiest part is mixing that with the seamless tiling, and where I’m getting lost.
Inevitably somebody is going to suggest just layering the clouds as a translucent sphere and turning on shadow casting instead, but that would be horrifically expensive since I’d be overdrawing practically every pixel on screen at that point, and the detail isn’t high enough anyway.