diff options
Diffstat (limited to 'indra/newview/pipeline.cpp')
-rw-r--r-- | indra/newview/pipeline.cpp | 48 |
1 files changed, 32 insertions, 16 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index d3b2443116..dce63e06fb 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -2321,7 +2321,7 @@ bool LLPipeline::getVisibleExtents(LLCamera& camera, LLVector3& min, LLVector3& static LLTrace::BlockTimerStatHandle FTM_CULL("Object Culling"); -void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_clip, LLPlane* planep) +void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, LLPlane* planep) { static LLCachedControl<bool> use_occlusion(gSavedSettings,"UseOcclusion"); static bool can_use_occlusion = LLFeatureManager::getInstance()->isFeatureAvailable("UseOcclusion") @@ -2413,7 +2413,7 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl LLVOCachePartition* vo_part = region->getVOCachePartition(); if(vo_part) { - bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe; // && 0 > water_clip + bool do_occlusion_cull = can_use_occlusion && use_occlusion && !gUseWireframe; vo_part->cull(camera, do_occlusion_cull); } } @@ -9158,22 +9158,20 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) //plane params LLPlane plane; LLVector3 pnorm; - S32 water_clip = 0; - if (!camera_is_underwater) + + if (camera_is_underwater) { - //camera is above water, clip plane points up - pnorm.setVec(0,0,1); - plane.setVec(pnorm, -water_height); - water_clip = 1; + //camera is below water, cull above water + pnorm.setVec(0, 0, 1); } else { - //camera is below water, clip plane points down - pnorm = LLVector3(0,0,-1); - plane.setVec(pnorm, water_height); - water_clip = -1; + //camera is above water, cull below water + pnorm = LLVector3(0, 0, -1); } + plane.setVec(LLVector3(0, 0, water_height), pnorm); + if (!camera_is_underwater) { //generate planar reflection map @@ -9271,7 +9269,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLGLUserClipPlane clip_plane(plane, mReflectionModelView, saved_projection); LLGLDisable cull(GL_CULL_FACE); - updateCull(camera, mReflectedObjects, -water_clip, &plane); + updateCull(camera, mReflectedObjects, &plane); stateSort(camera, mReflectedObjects); renderGeom(camera); } @@ -9336,11 +9334,29 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) mWaterDis.clear(); gGL.setColorMask(true, false); - F32 water_dist = water_height * LLPipeline::sDistortionWaterClipPlaneMargin; + F32 water_dist = water_height; //clip out geometry on the same side of water as the camera w/ enough margin to not include the water geo itself, // but not so much as to clip out parts of avatars that should be seen under the water in the distortion map - LLPlane plane(-pnorm, camera_is_underwater ? -water_height : water_dist); + LLPlane plane; + + if (camera_is_underwater) + { + //nudge clip plane below water to avoid visible holes in objects intersecting water surface + water_dist /= LLPipeline::sDistortionWaterClipPlaneMargin; + //camera is below water, clip plane points up + pnorm.setVec(0, 0, -1); + } + else + { + //nudge clip plane above water to avoid visible holes in objects intersecting water surface + water_dist *= LLPipeline::sDistortionWaterClipPlaneMargin; + //camera is above water, clip plane points down + pnorm = LLVector3(0, 0, 1); + } + + plane.setVec(LLVector3(0, 0, water_dist), pnorm); + LLGLUserClipPlane clip_plane(plane, saved_modelview, saved_projection); gGL.setColorMask(true, true); @@ -9349,7 +9365,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) if (reflection_detail >= WATER_REFLECT_NONE_WATER_TRANSPARENT) { - updateCull(camera, mRefractedObjects, water_clip, &plane); + updateCull(camera, mRefractedObjects, &plane); stateSort(camera, mRefractedObjects); renderGeom(camera); } |