Perfect Sky/Cloud Plane

Hello,

I am trying to simulate a cloud plane with moving clouds. This is considered to a be simple rectangular plane over the scene with a cloud texture on it. So far it is easy and works fine.

However the gap at the horizon is not that nice. I would like to go and implement an improvement so that there is no gap between the scene and the cloud layer. Of course the far clipping plane shall stay at a reasonable distance (at least while drawing the scene.).

You can see the blue gap in the following image. Sample Image

I haven’t implemented something like this before, so I am looking for good ideas. I can think of :

  1. Using a skirt like inclined planes around the scene. ( I guess in this case the UV animation for the clouds will not be as simple as shifting UV coords. )

  2. Using a skybox model ( too much pixel fill. I want to avoid this. )

  3. Drawing the clouds with a different far clipping plane ( e.g. 20000 ) than the one used for drawing the scene ( e.g. 1500 ). Could this have an unwanted side effects in the OpenGL pipeline ?

I would appreciate any ideas :slight_smile:

Thanks in advance,

MDErdem

  1. Draw you cloud plane again in pre-processing stage.

That is, your first render your clouds with the near clipping plane at the far of your traditional scene.
Say your scene has a near plane of 1 and far plane of 100. So you first render your clouds (and only your clouds) in a frustum which near plane is 100 and far plane is 10000 for instance. The left, right, top and bottom clipping planes remain the same. At this point you have to disable depth writes (or simply disable depth testing). Then you render your normal scene as you did before, including clouds, with near plane set to 1 and far plane set to 100. Additionnally in the pre-render stage you can use fog or alpha blending in order to soften the effet of disappearing clouds in the distance, kind of extremely simple haze.

  1. Don’t draw a plane but draw a (part of a) sphere: http://freespace.virgin.net/hugo.elias/models/m_clouds.htm
  1. Using a skybox model ( too much pixel fill. I want to avoid this. )
  2. Drawing the clouds with a different far clipping plane ( e.g. 20000 ) than the one used for drawing the scene ( e.g. 1500 ). Could this have an unwanted side effects in the OpenGL pipeline ?
    #2 draw it last itll only draw the clear pixels then
    #3 only gonna lessen the error not get rid of it.

skybox is gonna be a hassle with the moving clouds, sphere/hemisphere (as reindeer mentioned) is a easier option,

For pre-calculated images, a sky box is the way to go.

For procedural, I’ve had good results with a sky dome, where the dome is created as the top unit’s worth of a 10 unit radius sphere – i e, it’s very flat and wide. I put the camera 0.5 units below the top, i e in the middle of the dome, height-wise.

To fix the fill issue, use glDepthRange() and draw the sky last to make sure that the sky doesn’t overlap the other geometry, so that Z test will work correctly. Draw the scene with DepthRange [0,0.99] and draw the clouds with DepthRange [0.99,0.99999] after you clear Z to 1 initially.

Note that using a FURTHER far clipping plane for the clouds will make for clouds that are, relatively speaking, NEARER in the Z buffer, because the [near,far] clipping planes map to [low,high] depth range.