diff options
author | Michael Pohoreski <ptolemy@lindenlab.com> | 2020-08-27 19:17:00 +0000 |
---|---|---|
committer | Michael Pohoreski <ptolemy@lindenlab.com> | 2020-08-27 19:17:00 +0000 |
commit | 798457fbdd3ae88f96a456bab708cd8193cfde3d (patch) | |
tree | 1d8d60b587778e0674209e9be25d30c18ac0370b | |
parent | 7a2237a3a6815676cdaf3929f7fe36ef2649281a (diff) | |
parent | 71bfdd57d72f5a12ab1a361dd160283acc85a0bb (diff) |
Merged in SL-13721 (pull request #271)
SL-13721 Fix incorrect water reflection
Approved-by: Dave Houlton
-rw-r--r-- | indra/newview/pipeline.cpp | 28 |
1 files changed, 14 insertions, 14 deletions
diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 456b98b1e8..9516273396 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9288,7 +9288,8 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gPipeline.pushRenderTypeMask(); - glh::matrix4f projection = get_current_projection(); + glh::matrix4f saved_modelview = get_current_modelview(); + glh::matrix4f saved_projection = get_current_projection(); glh::matrix4f mat; S32 detail = RenderReflectionDetail; @@ -9327,8 +9328,6 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) //disable occlusion culling for reflection map for now LLPipeline::sUseOcclusion = 0; - glh::matrix4f current = get_current_modelview(); - if (!camera_is_underwater) { //generate planar reflection map @@ -9337,15 +9336,10 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - glh::matrix4f mat; - camera.getOpenGLTransform(mat.m); - - glh::matrix4f scal; - scal.set_scale(glh::vec3f(1, 1, -1)); - mat = scal * mat; + mat.set_scale(glh::vec3f(1, 1, -1)); + mat.set_translate(glh::vec3f(0,0,water_height*2.f)); + mat = saved_modelview * mat; - // convert from CFR to OGL coord sys... - mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat; mReflectionModelView = mat; @@ -9354,6 +9348,12 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) LLViewerCamera::updateFrustumPlanes(camera, FALSE, TRUE); + glh::vec3f origin(0, 0, 0); + glh::matrix4f inv_mat = mat.inverse(); + inv_mat.mult_matrix_vec(origin); + + camera.setOrigin(origin.v); + glCullFace(GL_FRONT); if (LLDrawPoolWater::sNeedsReflectionUpdate) @@ -9406,7 +9406,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) } } - LLGLUserClipPlane clip_plane(plane, mReflectionModelView, projection); + LLGLUserClipPlane clip_plane(plane, mReflectionModelView, saved_projection); LLGLDisable cull(GL_CULL_FACE); updateCull(camera, mReflectedObjects, -water_clip, &plane); stateSort(camera, mReflectedObjects); @@ -9420,7 +9420,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); - set_current_modelview(current); + set_current_modelview(saved_modelview); } //LLPipeline::sUseOcclusion = occlusion; @@ -9476,7 +9476,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) //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, water_dist); - LLGLUserClipPlane clip_plane(plane, current, projection); + LLGLUserClipPlane clip_plane(plane, saved_modelview, saved_projection); gGL.setColorMask(true, true); mWaterDis.clear(); |