People often forget just how large, and how distant clouds can be. A single cumulus congestus cloud can reach sizes of up to 5km across, and cumulonimbus clouds are even bigger. They’re also a few kilometers up. This all means those little clouds you see on the horizon are really far away. If your scene has a far clip distance of just a few kilometers, then you’re not going to get a realistic scene from SilverLining. Having a far clip plane that’s too close will eliminate most of the clouds in your scene.

For best results, you want to have a far clip distance of 100,000 meters or so when SilverLining’s clouds are in your scene – and cloud layers in SilverLining that are at least 100,000 meters in width and length. In reality, the horizon is even farther than that if you’re above one kilometer in altitude – here’s a handy horizon distance calculator if you’re curious how it works.

Some applications, however, cannot push out their far clip plane that far. Perhaps it’s not under your direct control, or it introduces depth precision issues – or you depend on that clipping plane to keep the performance of your terrain engine under control. Don’t worry – there is a trick for drawing SilverLining’s clouds beyond your far clip plane!

The SilverLining::Atmosphere::DisableFarCulling method exists for this purpose. When this is active, SilverLining won’t take your far clip plane into account when culling the clouds. But, that’s only half the problem – you still need to prevent OpenGL or DirectX from clipping them from the frustum as well.

What you need is “depth clamping” – telling the driver that objects beyond the far clip plane should just have their depth values clamped to the maximum value. In OpenGL, you use glEnable(GL_DEPTH_CLAMP_NV) in conjuction with glDepthFunc(GL_LEQUAL) to set up the desired state prior to calling Atmosphere::DrawObjects() to draw the clouds. Remember to disable that state afterwards!

For example:


glEnable(GL_DEPTH_CLAMP_NV);
glDepthFunc(GL_LEQUAL);
atm->DisableFarCulling(true);

atm->DrawObjects(true, true, true, 0.5f, false, 0, cw);

glDisable(GL_DEPTH_CLAMP_NV);

This trick lets you draw clouds bounded only by the cloud layer sizes you specify. Remember “infinite” cloud layers are centered over the viewpoint, so a 100,000 meter cloud layer actually only extends 50km from the viewpoint.

With this tip, you can keep your far clipping plane close while still drawing distant clouds. It can help a lot with creating a realistic scene!