First of all hello everyone, it is my first post on this forum ( but definitly not my first visit ) and i need a little help about something i'm trying to make for my game.
what i need to make is a ground fog effect. my first attempt was to basicaly create a fog texture with an alpha to simulate the density of the fog but there is a problem to this, the probleme is that when i want to animate the texture so it gently move down the hill until it softly disapear on the edge, well.. i just can't see how i can make it so it softly disapear on the edge of the mesh since it already receive an opacity map from the texture. is there a possibility to add more than 1 opacity map to a material?
the engine i'm try to use it on is " ogre3D " just in case it helps.
If any of you know a solution around that, i would greatly apreciate.
PS: oh, and i'am sorry for the bad english, i'm not a native english speaker :S
Replies
For the fog, have a plane/shape/(could define a form in the shader), and sample it's y position, then saturate that (if you need to adjust based on the height of the fog above 0,0, do it here).
ScreenDepthDistance can also be good, because when you're flat on the ground looking at fog it gives you the illusion of depth. Again, saturate that if you need to.
While I'm not sure what Ogre's like with shaders or access to depth, if you're familiar with the engine, learn up on WorldPosition, ScreenDepthDistance and Saturate functions in your chosen shader language and you'll be fine.
Make sure your fog plane does NOT write to depth.
Then your fog shader should compare the fog pixel's position away from the camera, and the (object behind it's) pixel position away from the camera. So if a pixel of fog is x from the camera and a pixel of the ground beneath it is y from the camera, it'll spit out y-x.
You can plug this into transparency, because as the fog and ground get closer, the depth difference will approach 0. Therefore, your fog will fade out as it gets closer to intersecting something.