Hi there.
I’m making a space exploration game that features planets with atmospheres, rendered on a single sphere. I’m pretty happy with how things are looking but I’d like to give the illusion of depth to the cloud layer by simulating shadows on the surface ‘below’.
Just to be clear, both the surface and the cloud layer are rendered on one sphere, using a surface shader. (I did try rendering the cloud layer on a second, slightly larger, ‘transparent’ sphere, but I ran into all kinds of depth sorting issues)
So my idea is, in the shader, to draw the cloud shadows over the surface, by subtracting the Luminance of the cloud layer, then adding the cloud layer in. This I have working; The next part is what I’m struggling with:
To simulate distance between the cloud layer and the planet surface I’d like to ‘offset’ the shadow at areas on the sphere where the normals are perpendicular to the sun direction, ie where the shadows should be ‘long’:
- float offset = 1 - saturate(dot(normalize(_sunDirection), o.Normal));
I’d like to use that inversed dot product value as a multiplier for sampling the cloud layer at a UV location ‘toward’ the direction of the sun. That way the shadow will ‘spread’ more at the areas near sunset.
So my question (finally!) is: How do I get the UVs from a calculated vertex fragment that isn’t the current vertex fragment?
And if I can explain this better, please let me know!