Jump to content
  • Advertisement
Sign in to follow this  
schupf

Terrain cloud shadows

This topic is 2511 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hello,

I have a terrain and I want to render moving cloud shadows onto this terrain. Something like this:


Anyone has an idea how this effect could be achieved in a simple way with DirectX 9?

Share this post


Link to post
Share on other sites
Advertisement
I haven't done anything with projected textures, so I am not quite sure how to do it.

I understand I could use a orthographic projection (with a huuuge box) to project a texture with many cloud shapes onto the terrain. But isn't this overly complicated? Plus, how do I make the clouds move? I need some scrolling texture coordinates on my terrain vertices but I can't get up with a good idea how to implement this:/

Share this post


Link to post
Share on other sites

I haven't done anything with projected textures, so I am not quite sure how to do it.

I understand I could use a orthographic projection (with a huuuge box) to project a texture with many cloud shapes onto the terrain. But isn't this overly complicated? Plus, how do I make the clouds move? I need some scrolling texture coordinates on my terrain vertices but I can't get up with a good idea how to implement this:/


If you want a simple solution and don't have separate geometry on-top of the terrain, then you can simply just pass a cloud texture along to your terrain shader and multiply against the output terrain color, then you also pass the current time along to the shader as a variable and use it to offset the cloud texture ... voila, moving cloud shadows on the terrain.

Share this post


Link to post
Share on other sites
Since I have objects on my terrain (houses, trees) that should be in the cloud shadows too, I guess I have to go the projected texture way.

There are still some questions left:
1) I guess I should use a orthographic projection with a frustum box that covers the whole terrain?
2) I guess I can just use one big texture that contains several clouds? Maybe the clouds are just black and everything else in the texture is transparent. Good idea?
3) My biggest question is how to make the projected texture move. If I move the projector (the box) then eventually the terrain will be out of the frustum box. How can I implement infinite scrolling with projected textures? Maybe just add time to the projected texture coordinates?

Share this post


Link to post
Share on other sites

1) I guess I should use a orthographic projection with a frustum box that covers the whole terrain?

Ortho is the easiest to get working, and is close enough to correct anyway when dealing with sunlight. As far as covering the whole terrain, i would instead make it a configurable width/depth on the terrain. See 3)


2) I guess I can just use one big texture that contains several clouds? Maybe the clouds are just black and everything else in the texture is transparent. Good idea?

Yeah, that works. You could use photoshop to cread a perlin noise pattern, and sample the texture multiple times with slightly different projections to get layers of clouds. You can also remap the texture output to make the clouds lighter or denser, if you want a dynamic cloudcover.


3) My biggest question is how to make the projected texture move. If I move the projector (the box) then eventually the terrain will be out of the frustum box. How can I implement infinite scrolling with projected textures? Maybe just add time to the projected texture coordinates?

If your texture sampler is set to repeat, instead of clamp, then its not a problem. By translating the projection matrix in the direction of the wind, you automatically get scrolling textures. This way scrolling cloud cover does not add any additional GPU time to your shader.

To avoid precision issues though, it might be a good idea to snap the projection coordinate system to a stable local center - but thats an afterthought for once its working if you do see precision issues.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!