Home Technical Talk

Ground fog.

polycounter lvl 7
Offline / Send Message
underfox polycounter lvl 7
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

  • Brendan
    Options
    Offline / Send Message
    Brendan polycounter lvl 8
    Do you want it to fade out when you're close to it? Then you need the depth at a certain pixel. For what you're wanting, learn up on the worldposition uses in shaders. This allows you to access an opaque shader's position in the world in x,y,z.

    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.
  • underfox
    Options
    Offline / Send Message
    underfox polycounter lvl 7
    Thank you for the answer, but what i want is to see the fading out of the fog once it comes close to the edge of the mesh, not when the camera get close to the mesh .
  • Brendan
    Options
    Offline / Send Message
    Brendan polycounter lvl 8
    That's what you use screendepthdistance for. More specifically, Depth Difference (look for this, too).


    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.
Sign In or Register to comment.