diff options
author | Graham Linden <graham@lindenlab.com> | 2018-09-19 20:41:14 +0100 |
---|---|---|
committer | Graham Linden <graham@lindenlab.com> | 2018-09-19 20:41:14 +0100 |
commit | bc787063aaa775349bc3afebbdfda6c977dcadff (patch) | |
tree | f6255ae516550dc1d1c7043c1e3f7d025578b8cd /indra/newview | |
parent | 741d283c0e51d96c3f4e3d42284422f856a7b4f7 (diff) |
SL-1505
Prepend dir names to comments in water shaders to differentiate them in nSight captures.
Fix calc of reflection camera modelview mats to properly reflect the environment.
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/shaders/class1/deferred/waterF.glsl | 2 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class1/environment/waterF.glsl | 2 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 46 |
3 files changed, 26 insertions, 24 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index aeec247514..a29acb3e7d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -1,5 +1,5 @@ /** - * @file waterF.glsl + * @file class1/deferred/waterF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index 37f109c637..19158f4505 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -1,5 +1,5 @@ /** - * @file waterF.glsl + * @file class1/environment/waterF.glsl * * $LicenseInfo:firstyear=2007&license=viewerlgpl$ * Second Life Viewer Source Code diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c722c442f1..9531e0a349 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -9806,27 +9806,31 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) stop_glerror(); LLPlane plane; - F32 height = gAgent.getRegion()->getWaterHeight(); - F32 to_clip = fabsf(camera.getOrigin().mV[2]-height); - F32 pad = -to_clip*0.05f; //amount to "pad" clip plane by + F32 water_height = gAgent.getRegion()->getWaterHeight(); + F32 camera_height = camera_in.getOrigin().mV[2]; + F32 distance_to_water = (water_height < camera_height) ? (camera_height - water_height) : (water_height - camera_height); + + LLVector3 reflection_offset = LLVector3(0, 0, distance_to_water * 2.0f); + LLVector3 camera_look_at = camera_in.getAtAxis(); + LLVector3 reflection_look_at = LLVector3(camera_look_at.mV[VX], camera_look_at.mV[VY], -camera_look_at.mV[VZ]); + LLVector3 reflect_origin = camera_in.getOrigin() - reflection_offset; + LLVector3 reflect_interest_point = reflect_origin + (reflection_look_at * 5.0f); + + camera.setOriginAndLookAt(reflect_origin, LLVector3::z_axis, reflect_interest_point); //plane params LLVector3 pnorm; - F32 pd; - S32 water_clip = 0; if (!LLViewerCamera::getInstance()->cameraUnderWater()) { //camera is above water, clip plane points up pnorm.setVec(0,0,1); - pd = -height; - plane.setVec(pnorm, pd); + plane.setVec(pnorm, -distance_to_water); water_clip = -1; } else { //camera is below water, clip plane points down pnorm = LLVector3(0,0,-1); - pd = height; - plane.setVec(pnorm, pd); + plane.setVec(pnorm, distance_to_water); water_clip = 1; } @@ -9860,25 +9864,23 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gGL.pushMatrix(); - mat.set_scale(glh::vec3f(1,1,-1)); - mat.set_translate(glh::vec3f(0,0,height*2.f)); - glh::matrix4f current = get_current_modelview(); - mat = current * mat; + glh::matrix4f mat; + camera.getOpenGLTransform(mat.m); + + glh::matrix4f scal; + scal.set_scale(glh::vec3f(1, 1, -1)); + mat = scal * mat; + + // convert from CFR to OGL coord sys... + mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat; set_current_modelview(mat); gGL.loadMatrix(mat.m); LLViewerCamera::updateFrustumPlanes(camera, FALSE, TRUE); - glh::matrix4f inv_mat = mat.inverse(); - - glh::vec3f origin(0,0,0); - inv_mat.mult_matrix_vec(origin); - - camera.setOrigin(origin.v); - glCullFace(GL_FRONT); static LLCullResult ref_result; @@ -10022,7 +10024,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) { //clip out geometry on the same side of water as the camera mat = get_current_modelview(); - LLPlane plane(-pnorm, -(pd+pad)); + LLPlane plane(-pnorm, -distance_to_water); LLGLUserClipPlane clip_plane(plane, mat, projection); static LLCullResult result; @@ -10087,7 +10089,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gPipeline.popRenderTypeMask(); LLDrawPoolWater::sNeedsReflectionUpdate = FALSE; LLDrawPoolWater::sNeedsDistortionUpdate = FALSE; - LLPlane npnorm(-pnorm, -pd); + LLPlane npnorm(-pnorm, -distance_to_water); LLViewerCamera::getInstance()->setUserClipPlane(npnorm); LLGLState::checkStates(); |