Adjust far plane distance so that clouds aren't clipped to close to viewer.

ver1_5_1
Chris Laurel 2002-01-11 19:26:35 +00:00
parent 48febc6f0d
commit a603dcb8c7
1 changed files with 13 additions and 0 deletions

View File

@ -835,6 +835,7 @@ void Renderer::render(const Observer& observer,
bool convex = true;
float radius = 1.0f;
float cullRadius = 1.0f;
float cloudHeight = 0.0f;
if (iter->body != NULL)
{
radius = iter->body->getRadius();
@ -849,7 +850,10 @@ void Renderer::render(const Observer& observer,
cullRadius = radius;
if (iter->body->getAtmosphere() != NULL)
{
cullRadius += iter->body->getAtmosphere()->height;
cloudHeight = iter->body->getAtmosphere()->cloudHeight;
}
}
else if (iter->star != NULL)
{
@ -901,6 +905,15 @@ void Renderer::render(const Observer& observer,
// is spherical, inside the planet.)
iter->farZ = iter->nearZ * 2.0f;
}
if (cloudHeight > 0.0f && d < eradius + cloudHeight)
{
// If there's a cloud layer, we need to move the
// far plane out so that the clouds aren't clipped
float cloudLayerRadius = eradius + cloudHeight;
iter->farZ -= (float) sqrt(square(cloudLayerRadius) -
square(eradius));
}
}
*notCulled = *iter;