diff options
Diffstat (limited to 'indra/newview')
-rw-r--r-- | indra/newview/app_settings/logcontrol.xml | 1 | ||||
-rw-r--r-- | indra/newview/app_settings/settings.xml | 2 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/skyF.glsl | 28 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class3/deferred/skyV.glsl | 14 | ||||
-rw-r--r-- | indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl | 17 | ||||
-rw-r--r-- | indra/newview/lldrawpoolground.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lldrawpoolsky.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwater.cpp | 2 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwlsky.cpp | 87 | ||||
-rw-r--r-- | indra/newview/lldrawpoolwlsky.h | 2 | ||||
-rw-r--r-- | indra/newview/llglsandbox.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llpanelprimmediacontrols.cpp | 6 | ||||
-rw-r--r-- | indra/newview/llviewercamera.cpp | 25 | ||||
-rw-r--r-- | indra/newview/llviewercamera.h | 8 | ||||
-rw-r--r-- | indra/newview/llviewerdisplay.cpp | 26 | ||||
-rw-r--r-- | indra/newview/llvieweroctree.cpp | 2 | ||||
-rw-r--r-- | indra/newview/llviewershadermgr.cpp | 65 | ||||
-rw-r--r-- | indra/newview/pipeline.cpp | 126 | ||||
-rw-r--r-- | indra/newview/pipeline.h | 9 |
19 files changed, 182 insertions, 244 deletions
diff --git a/indra/newview/app_settings/logcontrol.xml b/indra/newview/app_settings/logcontrol.xml index 380d7762d6..951c8edcc7 100644 --- a/indra/newview/app_settings/logcontrol.xml +++ b/indra/newview/app_settings/logcontrol.xml @@ -51,6 +51,7 @@ <key>tags</key> <array> <!-- sample entry for debugging specific items + <string>ShaderLoading</string> <string>Avatar</string> <string>Inventory</string> <string>SceneLoadTiming</string> diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml index c3097589ea..0d9042a301 100644 --- a/indra/newview/app_settings/settings.xml +++ b/indra/newview/app_settings/settings.xml @@ -10143,7 +10143,7 @@ <key>Type</key> <string>Boolean</string> <key>Value</key> - <integer>0</integer> + <integer>1</integer> </map> <key>RenderUseTriStrips</key> <map> diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl index 0223f94e55..5185a9f8f4 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyF.glsl @@ -29,11 +29,12 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif +in vec3 view_pos; in vec3 view_dir; uniform vec3 cameraPosLocal; -uniform vec3 sun_direction; -uniform vec2 sun_size; +uniform vec3 sun_dir; +uniform float sun_size; uniform sampler2D cloud_noise_texture; uniform sampler2D transmittance_texture; @@ -50,20 +51,35 @@ void main() { vec3 view_direction = normalize(view_dir); + vec3 sun_direction = sun_dir; + vec3 camPos = cameraPosLocal + vec3(0, 0, 6360.0f); vec3 transmittance; + vec3 sky_illum; vec3 radiance = GetSkyLuminance(camPos, view_direction, 0.0f, sun_direction, transmittance); + vec3 radiance2 = GetSunAndSkyIlluminance(camPos, view_direction, sun_direction, sky_illum); + + radiance *= transmittance; + + vec3 solar_luminance = transmittance * GetSolarLuminance(); // If the view ray intersects the Sun, add the Sun radiance. - if (dot(view_direction, sun_direction) >= sun_size.y) + if (dot(view_direction, sun_direction) >= sun_size) { - radiance = radiance + (transmittance * GetSolarLuminance()); + radiance = radiance + solar_luminance; } - vec3 color = vec3(1.0) - exp(-radiance); - color = pow(color, vec3(1.0 / 2.2)); + vec3 color = radiance; + + color = vec3(1.0) - exp(-color * 0.0001); + + //float d = dot(view_direction, sun_direction); + //frag_color.rgb = vec3(d, d >= sun_size ? 1.0f : 0.0f, 0.0f); frag_color.rgb = color; + //frag_color.rgb = vec3(dot(view_direction, sun_direction) > 0.95f ? 1.0 : 0.0, 0,0); + frag_color.rgb = normalize(view_pos); + frag_color.a = 1.0; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl index 52a7595379..cf3eb658fc 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/skyV.glsl @@ -23,21 +23,29 @@ * $/LicenseInfo$ */ +uniform vec3 cameraPosLocal; uniform mat4 modelview_projection_matrix; +uniform mat4 modelview_matrix; +uniform mat4 inv_proj; +uniform mat4 inv_modelview; ATTRIBUTE vec3 position; // Inputs uniform vec3 camPosLocal; +out vec3 view_pos; out vec3 view_dir; void main() { - // World / view / projection - gl_Position = modelview_projection_matrix * vec4(position.xyz, 1.0); + // pass through untransformed fullscreen pos (clipspace) + gl_Position = vec4(position.xyz, 1.0); + + view_pos = (inv_proj * vec4(position, 1.0f)).xyz; // this will be normalized in the frag shader... - view_dir = position.xyz - camPosLocal.xyz; + //view_dir = (inv_modelview * view_pos).xyz; + view_dir = view_pos - camPosLocal; } diff --git a/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl b/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl index 014ab9d11b..fed3edf7de 100644 --- a/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl +++ b/indra/newview/app_settings/shaders/class3/windlight/advancedAtmoF.glsl @@ -32,12 +32,13 @@ out vec4 frag_color; in vec3 view_dir; uniform vec3 cameraPosLocal; -uniform vec3 sun_direction; +uniform vec3 sun_dir; uniform float sun_size; uniform sampler2D transmittance_texture; uniform sampler3D scattering_texture; uniform sampler3D mie_scattering_texture; +uniform sampler2D irradiance_texture; vec3 GetSolarLuminance(); vec3 GetSkyLuminance(vec3 camPos, vec3 view_dir, float shadow_length, vec3 sun_dir, out vec3 transmittance); @@ -50,20 +51,22 @@ void main() vec3 camPos = cameraPosLocal; vec3 transmittance; - vec3 radiance = GetSkyLuminance(camPos, view_direction, 0.0f, sun_direction, transmittance); + vec3 sky_illum; + vec3 radiance = GetSkyLuminance(camPos, view_direction, 0.0f, sun_dir, transmittance); + vec3 radiance2 = GetSunAndSkyIlluminance(camPos, view_direction, sun_dir, sky_illum); - radiance *= transmittance; + //radiance *= transmittance; // If the view ray intersects the Sun, add the Sun radiance. - if (dot(view_direction, sun_direction) >= sun_size) + if (dot(view_direction, sun_dir) >= sun_size) { radiance = radiance + transmittance * GetSolarLuminance(); } - vec3 color = vec3(1.0) - exp(-radiance); - color = pow(color, vec3(1.0 / 2.2)); + //vec3 color = vec3(1.0) - exp(-radiance); + //color = pow(color, vec3(1.0 / 2.2)); - frag_color.rgb = color; + frag_color.rgb = radiance; frag_color.a = 1.0; } diff --git a/indra/newview/lldrawpoolground.cpp b/indra/newview/lldrawpoolground.cpp index 59c3fbf7a1..e5ce0413b1 100644 --- a/indra/newview/lldrawpoolground.cpp +++ b/indra/newview/lldrawpoolground.cpp @@ -68,7 +68,7 @@ void LLDrawPoolGround::render(S32 pass) LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - LLGLSquashToFarClip far_clip(glh_get_current_projection()); + LLGLSquashToFarClip far_clip(get_current_projection()); F32 water_height = gAgent.getRegion()->getWaterHeight(); gGL.pushMatrix(); diff --git a/indra/newview/lldrawpoolsky.cpp b/indra/newview/lldrawpoolsky.cpp index bdb16abc78..2e4506ce47 100644 --- a/indra/newview/lldrawpoolsky.cpp +++ b/indra/newview/lldrawpoolsky.cpp @@ -102,7 +102,7 @@ void LLDrawPoolSky::render(S32 pass) LLGLDepthTest gls_depth(GL_TRUE, GL_FALSE); - LLGLSquashToFarClip far_clip(glh_get_current_projection()); + LLGLSquashToFarClip far_clip(get_current_projection()); LLGLEnable fog_enable( (mVertexShaderLevel < 1 && LLViewerCamera::getInstance()->cameraUnderWater()) ? GL_FOG : 0); diff --git a/indra/newview/lldrawpoolwater.cpp b/indra/newview/lldrawpoolwater.cpp index 493c619a99..bdf04bd436 100644 --- a/indra/newview/lldrawpoolwater.cpp +++ b/indra/newview/lldrawpoolwater.cpp @@ -705,7 +705,7 @@ void LLDrawPoolWater::shade() } else { - LLGLSquashToFarClip far_clip(glh_get_current_projection()); + LLGLSquashToFarClip far_clip(get_current_projection()); face->renderIndexed(); } } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 01d10502a1..789e79bb31 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -128,17 +128,10 @@ void LLDrawPoolWLSky::endDeferredPass(S32 pass) void LLDrawPoolWLSky::renderFsSky(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const { - gGL.pushMatrix(); - gGL.matrixMode(LLRender::MM_PROJECTION); - gGL.loadIdentity(); - gGL.matrixMode(LLRender::MM_MODELVIEW); - gGL.loadIdentity(); - // Draw WL Sky w/ normal cam pos (where you are) for adv atmo sky + //gGL.syncMatrices(); sky_shader->uniform3f(sCamPosLocal, camPosLocal.mV[0], camPosLocal.mV[1], camPosLocal.mV[2]); gSky.mVOWLSkyp->drawFsSky(); - - gGL.popMatrix(); } void LLDrawPoolWLSky::renderDome(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const @@ -174,54 +167,63 @@ void LLDrawPoolWLSky::renderDome(const LLVector3& camPosLocal, F32 camHeightLoca gGL.popMatrix(); } -void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const +void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const { - if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) - { - LLGLDisable blend(GL_BLEND); - + if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders() && gAtmosphere) + { sky_shader->bind(); - LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + // bind precomputed textures necessary for calculating sun and sky luminance + sky_shader->bindTexture(LLShaderMgr::TRANSMITTANCE_TEX, gAtmosphere->getTransmittance()); + sky_shader->bindTexture(LLShaderMgr::SCATTER_TEX, gAtmosphere->getScattering()); + sky_shader->bindTexture(LLShaderMgr::SINGLE_MIE_SCATTER_TEX, gAtmosphere->getMieScattering()); + sky_shader->bindTexture(LLShaderMgr::ILLUMINANCE_TEX, gAtmosphere->getIlluminance()); - if (gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders() && gAtmosphere) - { - // bind precomputed textures necessary for calculating sun and sky luminance - sky_shader->bindTexture(LLShaderMgr::TRANSMITTANCE_TEX, gAtmosphere->getTransmittance()); - sky_shader->bindTexture(LLShaderMgr::SCATTER_TEX, gAtmosphere->getScattering()); - sky_shader->bindTexture(LLShaderMgr::SINGLE_MIE_SCATTER_TEX, gAtmosphere->getMieScattering()); + static float sunSize = (float)cos(0.0005); - static float sunSize = (float)cos(0.0005); + sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize); - sky_shader->uniform1f(LLShaderMgr::SUN_SIZE, sunSize); + static LLVector3 solDir(-0.935f, 0.23f, 0.27f); - static LLVector3 solDir(0.7f, 0.2f, 0.2f); + static bool fooA = false; + static bool fooB = false; - //neither of these appear to track with the env settings, would the real sun please stand up. - //sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, gPipeline.mTransformedSunDir.mV); - //sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, gSky.mVOSkyp->getSun().getDirection().mV); - solDir.normalize(); + //neither of these appear to track with the env settings, would the real sun please stand up. + if (fooA) solDir = gPipeline.mTransformedSunDir; + if (fooB) solDir = gSky.mVOSkyp->getSun().getDirection(); - sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, solDir.mV); + solDir.normalize(); - // clouds are rendered along with sky in adv atmo - if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && sCloudNoiseTexture.notNull()) - { - sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, sCloudNoiseTexture); - } + sky_shader->uniform3fv(LLShaderMgr::DEFERRED_SUN_DIR, 1, solDir.mV); - renderFsSky(origin, camHeightLocal, sky_shader); - } - else + // clouds are rendered along with sky in adv atmo + if (gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_CLOUDS) && sCloudNoiseTexture.notNull()) { - /// Render the skydome - renderDome(origin, camHeightLocal, sky_shader); + sky_shader->bindTexture(LLShaderMgr::CLOUD_NOISE_MAP, sCloudNoiseTexture); } + renderFsSky(camPosLocal, camHeightLocal, sky_shader); + sky_shader->unbind(); } } +void LLDrawPoolWLSky::renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const +{ + LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); + + if (gPipeline.canUseWindLightShaders() && gPipeline.hasRenderType(LLPipeline::RENDER_TYPE_SKY)) + { + LLGLDisable blend(GL_BLEND); + sky_shader->bind(); + + /// Render the skydome + renderDome(origin, camHeightLocal, sky_shader); + + sky_shader->unbind(); + } +} + void LLDrawPoolWLSky::renderStars(void) const { LLGLSPipelineSkyBox gls_sky; @@ -367,18 +369,17 @@ void LLDrawPoolWLSky::renderDeferred(S32 pass) gGL.setColorMask(true, false); - LLGLSquashToFarClip far_clip(glh_get_current_projection()); + LLGLSquashToFarClip far_clip(get_current_projection()); LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); - renderSkyHaze(origin, camHeightLocal); + renderSkyHazeDeferred(origin, camHeightLocal); - if (!gPipeline.useAdvancedAtmospherics() && gPipeline.canUseWindLightShaders()) + if (gPipeline.canUseWindLightShaders()) { LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); gGL.pushMatrix(); - gGL.translatef(origin.mV[0], origin.mV[1], origin.mV[2]); gDeferredStarProgram.bind(); @@ -415,7 +416,7 @@ void LLDrawPoolWLSky::render(S32 pass) LLGLDepthTest depth(GL_TRUE, GL_FALSE); LLGLDisable clip(GL_CLIP_PLANE0); - LLGLSquashToFarClip far_clip(glh_get_current_projection()); + LLGLSquashToFarClip far_clip(get_current_projection()); LLVector3 const & origin = LLViewerCamera::getInstance()->getOrigin(); diff --git a/indra/newview/lldrawpoolwlsky.h b/indra/newview/lldrawpoolwlsky.h index 8d4a749a9c..2beb2867db 100644 --- a/indra/newview/lldrawpoolwlsky.h +++ b/indra/newview/lldrawpoolwlsky.h @@ -76,6 +76,8 @@ private: void renderFsSky(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const; void renderDome(const LLVector3& camPosLocal, F32 camHeightLocal, LLGLSLShader * shader) const; void renderSkyHaze(const LLVector3& camPosLocal, F32 camHeightLocal) const; + void renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 camHeightLocal) const; + void renderStars(void) const; void renderSkyClouds(const LLVector3& camPosLocal, F32 camHeightLocal) const; void renderHeavenlyBodies(); diff --git a/indra/newview/llglsandbox.cpp b/indra/newview/llglsandbox.cpp index 63270e13fe..5111bbb066 100644 --- a/indra/newview/llglsandbox.cpp +++ b/indra/newview/llglsandbox.cpp @@ -1060,7 +1060,7 @@ F32 gpu_benchmark() delete [] pixels; //make a dummy triangle to draw with - LLPointer<LLVertexBuffer> buff = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, GL_STATIC_DRAW_ARB); + LLPointer<LLVertexBuffer> buff = new LLVertexBuffer(LLVertexBuffer::MAP_VERTEX | LLVertexBuffer::MAP_TEXCOORD0, GL_STREAM_DRAW_ARB); if (!buff->allocateBuffer(3, 0, true)) { diff --git a/indra/newview/llpanelprimmediacontrols.cpp b/indra/newview/llpanelprimmediacontrols.cpp index 5f413fc3c0..3d3dccee0b 100644 --- a/indra/newview/llpanelprimmediacontrols.cpp +++ b/indra/newview/llpanelprimmediacontrols.cpp @@ -64,8 +64,8 @@ #include "llvector4a.h" // Functions pulled from pipeline.cpp -glh::matrix4f glh_get_current_modelview(); -glh::matrix4f glh_get_current_projection(); +glh::matrix4f get_current_modelview(); +glh::matrix4f get_current_projection(); // Functions pulled from llviewerdisplay.cpp bool get_hud_matrices(glh::matrix4f &proj, glh::matrix4f &model); @@ -642,7 +642,7 @@ void LLPanelPrimMediaControls::updateShape() glh::matrix4f mat; if (!is_hud) { - mat = glh_get_current_projection() * glh_get_current_modelview(); + mat = get_current_projection() * get_current_modelview(); } else { glh::matrix4f proj, modelview; diff --git a/indra/newview/llviewercamera.cpp b/indra/newview/llviewercamera.cpp index 57a0195d23..de92e68032 100644 --- a/indra/newview/llviewercamera.cpp +++ b/indra/newview/llviewercamera.cpp @@ -81,31 +81,6 @@ glh::matrix4f gl_pick_matrix(GLfloat x, GLfloat y, GLfloat width, GLfloat height return glh::matrix4f(m); } -glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar) -{ - GLfloat f = 1.f/tanf(DEG_TO_RAD*fovy/2.f); - - return glh::matrix4f(f/aspect, 0, 0, 0, - 0, f, 0, 0, - 0, 0, (zFar+zNear)/(zNear-zFar), (2.f*zFar*zNear)/(zNear-zFar), - 0, 0, -1.f, 0); -} - -glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up) -{ - LLVector3 f = center-eye; - f.normVec(); - up.normVec(); - LLVector3 s = f % up; - LLVector3 u = s % f; - - return glh::matrix4f(s[0], s[1], s[2], 0, - u[0], u[1], u[2], 0, - -f[0], -f[1], -f[2], 0, - 0, 0, 0, 1); - -} - // Build time optimization, generate this once in .cpp file template class LLViewerCamera* LLSingleton<class LLViewerCamera>::getInstance(); diff --git a/indra/newview/llviewercamera.h b/indra/newview/llviewercamera.h index f8c973690a..a5216b5275 100644 --- a/indra/newview/llviewercamera.h +++ b/indra/newview/llviewercamera.h @@ -35,14 +35,6 @@ #include "lltrace.h" class LLViewerObject; - -// This rotation matrix moves the default OpenGL reference frame -// (-Z at, Y up) to Cory's favorite reference frame (X at, Z up) -const F32 OGL_TO_CFR_ROTATION[16] = { 0.f, 0.f, -1.f, 0.f, // -Z becomes X - -1.f, 0.f, 0.f, 0.f, // -X becomes Y - 0.f, 1.f, 0.f, 0.f, // Y becomes Z - 0.f, 0.f, 0.f, 1.f }; - const BOOL FOR_SELECTION = TRUE; const BOOL NOT_FOR_SELECTION = FALSE; diff --git a/indra/newview/llviewerdisplay.cpp b/indra/newview/llviewerdisplay.cpp index 950243949f..d1b6decb0d 100644 --- a/indra/newview/llviewerdisplay.cpp +++ b/indra/newview/llviewerdisplay.cpp @@ -729,8 +729,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLGLState::checkTextureChannels(); LLGLState::checkClientArrays(); - glh::matrix4f proj = glh_get_current_projection(); - glh::matrix4f mod = glh_get_current_modelview(); + glh::matrix4f proj = get_current_projection(); + glh::matrix4f mod = get_current_modelview(); glViewport(0,0,512,512); LLVOAvatar::updateFreezeCounter() ; @@ -739,8 +739,8 @@ void display(BOOL rebuild, F32 zoom_factor, int subfield, BOOL for_snapshot) LLVOAvatar::updateImpostors(); } - glh_set_current_projection(proj); - glh_set_current_modelview(mod); + set_current_projection(proj); + set_current_modelview(mod); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.loadMatrix(proj.m); gGL.matrixMode(LLRender::MM_MODELVIEW); @@ -1078,8 +1078,8 @@ void render_hud_attachments() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.pushMatrix(); - glh::matrix4f current_proj = glh_get_current_projection(); - glh::matrix4f current_mod = glh_get_current_modelview(); + glh::matrix4f current_proj = get_current_projection(); + glh::matrix4f current_mod = get_current_modelview(); // clamp target zoom level to reasonable values gAgentCamera.mHUDTargetZoom = llclamp(gAgentCamera.mHUDTargetZoom, 0.1f, 1.f); @@ -1171,8 +1171,8 @@ void render_hud_attachments() gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.popMatrix(); - glh_set_current_projection(current_proj); - glh_set_current_modelview(current_mod); + set_current_projection(current_proj); + set_current_modelview(current_mod); } LLRect get_whole_screen_region() @@ -1254,11 +1254,11 @@ bool setup_hud_matrices(const LLRect& screen_region) // set up transform to keep HUD objects in front of camera gGL.matrixMode(LLRender::MM_PROJECTION); gGL.loadMatrix(proj.m); - glh_set_current_projection(proj); + set_current_projection(proj); gGL.matrixMode(LLRender::MM_MODELVIEW); gGL.loadMatrix(model.m); - glh_set_current_modelview(model); + set_current_modelview(model); return TRUE; } @@ -1266,13 +1266,13 @@ void render_ui(F32 zoom_factor, int subfield) { LLGLState::checkStates(); - glh::matrix4f saved_view = glh_get_current_modelview(); + glh::matrix4f saved_view = get_current_modelview(); if (!gSnapshot) { gGL.pushMatrix(); gGL.loadMatrix(gGLLastModelView); - glh_set_current_modelview(glh_copy_matrix(gGLLastModelView)); + set_current_modelview(copy_matrix(gGLLastModelView)); } if(LLSceneMonitor::getInstance()->needsUpdate()) @@ -1335,7 +1335,7 @@ void render_ui(F32 zoom_factor, int subfield) if (!gSnapshot) { - glh_set_current_modelview(saved_view); + set_current_modelview(saved_view); gGL.popMatrix(); } } diff --git a/indra/newview/llvieweroctree.cpp b/indra/newview/llvieweroctree.cpp index 023f1b92ba..56e6103f67 100644 --- a/indra/newview/llvieweroctree.cpp +++ b/indra/newview/llvieweroctree.cpp @@ -1272,7 +1272,7 @@ void LLOcclusionCullingGroup::doOcclusion(LLCamera* camera, const LLVector4a* sh { LL_RECORD_BLOCK_TIME(FTM_OCCLUSION_DRAW_WATER); - LLGLSquashToFarClip squash(glh_get_current_projection(), 1); + LLGLSquashToFarClip squash(get_current_projection(), 1); if (camera->getOrigin().isExactlyZero()) { //origin is invalid, draw entire box gPipeline.mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, 0); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 4db039ace3..95e4f27a39 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -2091,6 +2091,31 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredPostNoDoFProgram.createShader(NULL, NULL); } + // this shader uses gather so it can't live with the other basic shaders safely + /*if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3)) + { + gDownsampleMinMaxDepthRectProgram.mName = "DownsampleMinMaxDepthRect Shader"; + gDownsampleMinMaxDepthRectProgram.mShaderFiles.clear(); + gDownsampleMinMaxDepthRectProgram.mShaderFiles.push_back(make_pair("windlight/downsampleMinMaxDepthV.glsl", GL_VERTEX_SHADER_ARB)); + gDownsampleMinMaxDepthRectProgram.mShaderFiles.push_back(make_pair("windlight/downsampleMinMaxDepthRectF.glsl", GL_FRAGMENT_SHADER_ARB)); + gDownsampleMinMaxDepthRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; + success = gDownsampleMinMaxDepthRectProgram.createShader(NULL, NULL); + }*/ + + // this shader uses gather so it can't live with the other basic shaders safely + /*if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3)) + { + gInscatterRectProgram.mName = "Inscatter Shader"; + gInscatterRectProgram.mShaderFiles.clear(); + gInscatterRectProgram.mShaderFiles.push_back(make_pair("windlight/advancedAtmoV.glsl", GL_VERTEX_SHADER_ARB)); + gInscatterRectProgram.mShaderFiles.push_back(make_pair("windlight/advancedAtmoF.glsl", GL_FRAGMENT_SHADER_ARB)); + gInscatterRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; + llassert(gAtmosphere != nullptr); + gInscatterRectProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink(); + success = gInscatterRectProgram.createShader(NULL, NULL); + llassert(success); + }*/ + if (success) { gDeferredWLSkyProgram.mName = "Deferred Windlight Sky Shader"; @@ -2105,9 +2130,10 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLSkyProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink(); } success = gDeferredWLSkyProgram.createShader(NULL, NULL); + llassert(success); } - if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] < 3)) + if (success) { gDeferredWLCloudProgram.mName = "Deferred Windlight Cloud Program"; gDeferredWLCloudProgram.mShaderFiles.clear(); @@ -2115,7 +2141,12 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_DEFERRED]; gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; + if (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3) + { + gDeferredWLSkyProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink(); + } success = gDeferredWLCloudProgram.createShader(NULL, NULL); + llassert(success); } if (success) @@ -3459,31 +3490,7 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() LLAtmosphere::initClass(); } - // this shader uses gather so it can't live with the other basic shaders safely - /*if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3)) - { - gDownsampleMinMaxDepthRectProgram.mName = "DownsampleMinMaxDepthRect Shader"; - gDownsampleMinMaxDepthRectProgram.mShaderFiles.clear(); - gDownsampleMinMaxDepthRectProgram.mShaderFiles.push_back(make_pair("windlight/downsampleMinMaxDepthV.glsl", GL_VERTEX_SHADER_ARB)); - gDownsampleMinMaxDepthRectProgram.mShaderFiles.push_back(make_pair("windlight/downsampleMinMaxDepthRectF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDownsampleMinMaxDepthRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; - success = gDownsampleMinMaxDepthRectProgram.createShader(NULL, NULL); - }*/ - - // this shader uses gather so it can't live with the other basic shaders safely - if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] >= 3)) - { - gInscatterRectProgram.mName = "Inscatter Shader"; - gInscatterRectProgram.mShaderFiles.clear(); - gInscatterRectProgram.mShaderFiles.push_back(make_pair("windlight/advancedAtmoV.glsl", GL_VERTEX_SHADER_ARB)); - gInscatterRectProgram.mShaderFiles.push_back(make_pair("windlight/advancedAtmoF.glsl", GL_FRAGMENT_SHADER_ARB)); - gInscatterRectProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; - llassert(gAtmosphere != nullptr); - gInscatterRectProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink(); - success = gInscatterRectProgram.createShader(NULL, NULL); - } - - if (success) + if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] < 3)) { gWLSkyProgram.mName = "Windlight Sky Shader"; //gWLSkyProgram.mFeatures.hasGamma = true; @@ -3492,12 +3499,10 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLSkyProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; gWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; - if (gAtmosphere != nullptr) - gWLSkyProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink(); success = gWLSkyProgram.createShader(NULL, NULL); } - if (success) + if (success && (mVertexShaderLevel[SHADER_WINDLIGHT] < 3)) { gWLCloudProgram.mName = "Windlight Cloud Program"; //gWLCloudProgram.mFeatures.hasGamma = true; @@ -3506,8 +3511,6 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() gWLCloudProgram.mShaderFiles.push_back(make_pair("windlight/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLCloudProgram.mShaderLevel = mVertexShaderLevel[SHADER_WINDLIGHT]; gWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; - if (gAtmosphere != nullptr) - gWLCloudProgram.mExtraLinkObject = gAtmosphere->getAtmosphericShaderForLink(); success = gWLCloudProgram.createShader(NULL, NULL); } diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4f34f58b76..6ad47386c7 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -298,62 +298,6 @@ void drawBoxOutline(const LLVector3& pos, const LLVector3& size); U32 nhpo2(U32 v); LLVertexBuffer* ll_create_cube_vb(U32 type_mask, U32 usage); -glh::matrix4f glh_copy_matrix(F32* src) -{ - glh::matrix4f ret; - ret.set_value(src); - return ret; -} - -glh::matrix4f glh_get_current_modelview() -{ - return glh_copy_matrix(gGLModelView); -} - -glh::matrix4f glh_get_current_projection() -{ - return glh_copy_matrix(gGLProjection); -} - -glh::matrix4f glh_get_last_modelview() -{ - return glh_copy_matrix(gGLLastModelView); -} - -glh::matrix4f glh_get_last_projection() -{ - return glh_copy_matrix(gGLLastProjection); -} - -void glh_copy_matrix(const glh::matrix4f& src, F32* dst) -{ - for (U32 i = 0; i < 16; i++) - { - dst[i] = src.m[i]; - } -} - -void glh_set_current_modelview(const glh::matrix4f& mat) -{ - glh_copy_matrix(mat, gGLModelView); -} - -void glh_set_current_projection(glh::matrix4f& mat) -{ - glh_copy_matrix(mat, gGLProjection); -} - -glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar) -{ - glh::matrix4f ret( - 2.f/(right-left), 0.f, 0.f, -(right+left)/(right-left), - 0.f, 2.f/(top-bottom), 0.f, -(top+bottom)/(top-bottom), - 0.f, 0.f, -2.f/(zfar-znear), -(zfar+znear)/(zfar-znear), - 0.f, 0.f, 0.f, 1.f); - - return ret; -} - void display_update_camera(); //---------------------------------------- @@ -1445,9 +1389,9 @@ bool LLPipeline::canUseVertexShaders() bool LLPipeline::canUseWindLightShaders() const { - return (!LLPipeline::sDisableShaders && - gWLSkyProgram.mProgramObject != 0 && - LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1); + bool usingWindlight = LLViewerShaderMgr::instance()->getVertexShaderLevel(LLViewerShaderMgr::SHADER_WINDLIGHT) > 1; + bool haveShaders = ((gWLSkyProgram.mProgramObject != 0) || (gDeferredWLSkyProgram.mProgramObject != 0)); + return (!LLPipeline::sDisableShaders && haveShaders && usingWindlight); } bool LLPipeline::canUseWindLightShadersOnObjects() const @@ -2483,8 +2427,8 @@ void LLPipeline::updateCull(LLCamera& camera, LLCullResult& result, S32 water_cl } } - glh::matrix4f modelview = glh_get_last_modelview(); - glh::matrix4f proj = glh_get_last_projection(); + glh::matrix4f modelview = get_last_modelview(); + glh::matrix4f proj = get_last_projection(); LLGLUserClipPlane clip(plane, modelview, proj, water_clip != 0 && LLPipeline::sReflectionRender); LLGLDepthTest depth(GL_TRUE, GL_FALSE); @@ -8269,7 +8213,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n stop_glerror(); - glh::matrix4f projection = glh_get_current_projection(); + glh::matrix4f projection = get_current_projection(); glh::matrix4f inv_proj = projection.inverse(); shader.uniformMatrix4fv(LLShaderMgr::INVERSE_PROJECTION_MATRIX, 1, FALSE, inv_proj.m); @@ -8443,7 +8387,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, U32 light_index, U32 n if (shader.getUniformLocation(LLShaderMgr::DEFERRED_NORM_MATRIX) >= 0) { - glh::matrix4f norm_mat = glh_get_current_modelview().inverse().transpose(); + glh::matrix4f norm_mat = get_current_modelview().inverse().transpose(); shader.uniformMatrix4fv(LLShaderMgr::DEFERRED_NORM_MATRIX, 1, FALSE, norm_mat.m); } } @@ -8513,7 +8457,7 @@ void LLPipeline::renderDeferredLighting() LLGLEnable cull(GL_CULL_FACE); LLGLEnable blend(GL_BLEND); - glh::matrix4f mat = glh_copy_matrix(gGLModelView); + glh::matrix4f mat = copy_matrix(gGLModelView); LLStrider<LLVector3> vert; mDeferredVB->getVertexStrider(vert); @@ -8547,7 +8491,7 @@ void LLPipeline::renderDeferredLighting() mDeferredLight.clear(GL_COLOR_BUFFER_BIT); glClearColor(0,0,0,0); - glh::matrix4f inv_trans = glh_get_current_modelview().inverse().transpose(); + glh::matrix4f inv_trans = get_current_modelview().inverse().transpose(); const U32 slice = 32; F32 offset[slice*3]; @@ -9127,7 +9071,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) LLGLEnable cull(GL_CULL_FACE); LLGLEnable blend(GL_BLEND); - glh::matrix4f mat = glh_copy_matrix(gGLModelView); + glh::matrix4f mat = copy_matrix(gGLModelView); LLStrider<LLVector3> vert; mDeferredVB->getVertexStrider(vert); @@ -9161,7 +9105,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) mDeferredLight.clear(GL_COLOR_BUFFER_BIT); glClearColor(0,0,0,0); - glh::matrix4f inv_trans = glh_get_current_modelview().inverse().transpose(); + glh::matrix4f inv_trans = get_current_modelview().inverse().transpose(); const U32 slice = 32; F32 offset[slice*3]; @@ -9650,7 +9594,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) LLMatrix4 light_mat(quat, LLVector4(origin,1.f)); glh::matrix4f light_to_agent((F32*) light_mat.mMatrix); - glh::matrix4f light_to_screen = glh_get_current_modelview() * light_to_agent; + glh::matrix4f light_to_screen = get_current_modelview() * light_to_agent; glh::matrix4f screen_to_light = light_to_screen.inverse(); @@ -9837,7 +9781,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) gPipeline.pushRenderTypeMask(); - glh::matrix4f projection = glh_get_current_projection(); + glh::matrix4f projection = get_current_projection(); glh::matrix4f mat; stop_glerror(); @@ -9898,11 +9842,11 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) mat.set_scale(glh::vec3f(1,1,-1)); mat.set_translate(glh::vec3f(0,0,height*2.f)); - glh::matrix4f current = glh_get_current_modelview(); + glh::matrix4f current = get_current_modelview(); mat = current * mat; - glh_set_current_modelview(mat); + set_current_modelview(mat); gGL.loadMatrix(mat.m); LLViewerCamera::updateFrustumPlanes(camera, FALSE, TRUE); @@ -10013,7 +9957,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) glCullFace(GL_BACK); gGL.popMatrix(); mWaterRef.flush(); - glh_set_current_modelview(current); + set_current_modelview(current); LLPipeline::sUseOcclusion = occlusion; } @@ -10053,7 +9997,7 @@ void LLPipeline::generateWaterReflection(LLCamera& camera_in) if (!LLPipeline::sUnderWaterRender || LLDrawPoolWater::sNeedsReflectionUpdate) { //clip out geometry on the same side of water as the camera - mat = glh_get_current_modelview(); + mat = get_current_modelview(); LLPlane plane(-pnorm, -(pd+pad)); LLGLUserClipPlane clip_plane(plane, mat, projection); @@ -10686,8 +10630,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) //get sun view matrix //store current projection/modelview matrix - glh::matrix4f saved_proj = glh_get_current_projection(); - glh::matrix4f saved_view = glh_get_current_modelview(); + glh::matrix4f saved_proj = get_current_projection(); + glh::matrix4f saved_view = get_current_modelview(); glh::matrix4f inv_view = saved_view.inverse(); glh::matrix4f view[6]; @@ -10844,8 +10788,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) LLViewerCamera::sCurCameraID = (LLViewerCamera::eCameraID)(LLViewerCamera::CAMERA_SHADOW0+j); //restore render matrices - glh_set_current_modelview(saved_view); - glh_set_current_projection(saved_proj); + set_current_modelview(saved_view); + set_current_projection(saved_proj); LLVector3 eye = camera.getOrigin(); @@ -11158,8 +11102,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) shadow_cam.setOrigin(0,0,0); - glh_set_current_modelview(view[j]); - glh_set_current_projection(proj[j]); + set_current_modelview(view[j]); + set_current_projection(proj[j]); LLViewerCamera::updateFrustumPlanes(shadow_cam, FALSE, FALSE, TRUE); @@ -11172,8 +11116,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) 0.f, 0.f, 0.5f, 0.5f, 0.f, 0.f, 0.f, 1.f); - glh_set_current_modelview(view[j]); - glh_set_current_projection(proj[j]); + set_current_modelview(view[j]); + set_current_projection(proj[j]); for (U32 i = 0; i < 16; i++) { @@ -11252,8 +11196,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) for (S32 i = 0; i < 2; i++) { - glh_set_current_modelview(saved_view); - glh_set_current_projection(saved_proj); + set_current_modelview(saved_view); + set_current_projection(saved_proj); if (mShadowSpotLight[i].isNull()) { @@ -11313,8 +11257,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) 0.f, 0.f, 0.5f, 0.5f, 0.f, 0.f, 0.f, 1.f); - glh_set_current_modelview(view[i+4]); - glh_set_current_projection(proj[i+4]); + set_current_modelview(view[i+4]); + set_current_projection(proj[i+4]); mSunShadowMatrix[i+4] = trans*proj[i+4]*view[i+4]*inv_view; @@ -11358,13 +11302,13 @@ void LLPipeline::generateSunShadow(LLCamera& camera) if (!CameraOffset) { - glh_set_current_modelview(saved_view); - glh_set_current_projection(saved_proj); + set_current_modelview(saved_view); + set_current_projection(saved_proj); } else { - glh_set_current_modelview(view[1]); - glh_set_current_projection(proj[1]); + set_current_modelview(view[1]); + set_current_projection(proj[1]); gGL.loadMatrix(view[1].m); gGL.matrixMode(LLRender::MM_PROJECTION); gGL.loadMatrix(proj[1].m); @@ -11542,7 +11486,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) F32 fov = atanf(tdim.mV[1]/distance)*2.f*RAD_TO_DEG; F32 aspect = tdim.mV[0]/tdim.mV[1]; glh::matrix4f persp = gl_perspective(fov, aspect, 1.f, 256.f); - glh_set_current_projection(persp); + set_current_projection(persp); gGL.loadMatrix(persp.m); gGL.matrixMode(LLRender::MM_MODELVIEW); @@ -11553,7 +11497,7 @@ void LLPipeline::generateImpostor(LLVOAvatar* avatar) mat = glh::matrix4f((GLfloat*) OGL_TO_CFR_ROTATION) * mat; gGL.loadMatrix(mat.m); - glh_set_current_modelview(mat); + set_current_modelview(mat); glClearColor(0.0f,0.0f,0.0f,0.0f); gGL.setColorMask(true, true); diff --git a/indra/newview/pipeline.h b/indra/newview/pipeline.h index 6023a41ca2..75fed7dd39 100644 --- a/indra/newview/pipeline.h +++ b/indra/newview/pipeline.h @@ -61,14 +61,7 @@ bool compute_min_max(LLMatrix4& box, LLVector2& min, LLVector2& max); // Shouldn bool LLRayAABB(const LLVector3 ¢er, const LLVector3 &size, const LLVector3& origin, const LLVector3& dir, LLVector3 &coord, F32 epsilon = 0); bool setup_hud_matrices(); // use whole screen to render hud bool setup_hud_matrices(const LLRect& screen_region); // specify portion of screen (in pixels) to render hud attachments from (for picking) -glh::matrix4f glh_copy_matrix(F32* src); -glh::matrix4f glh_get_current_modelview(); -void glh_set_current_modelview(const glh::matrix4f& mat); -glh::matrix4f glh_get_current_projection(); -void glh_set_current_projection(glh::matrix4f& mat); -glh::matrix4f gl_ortho(GLfloat left, GLfloat right, GLfloat bottom, GLfloat top, GLfloat znear, GLfloat zfar); -glh::matrix4f gl_perspective(GLfloat fovy, GLfloat aspect, GLfloat zNear, GLfloat zFar); -glh::matrix4f gl_lookat(LLVector3 eye, LLVector3 center, LLVector3 up); + extern LLTrace::BlockTimerStatHandle FTM_RENDER_GEOMETRY; extern LLTrace::BlockTimerStatHandle FTM_RENDER_GRASS; |