diff options
Diffstat (limited to 'indra')
10 files changed, 49 insertions, 15 deletions
diff --git a/indra/llrender/llshadermgr.cpp b/indra/llrender/llshadermgr.cpp index fea4ee2819..942f6dc86f 100755 --- a/indra/llrender/llshadermgr.cpp +++ b/indra/llrender/llshadermgr.cpp @@ -1138,7 +1138,8 @@ void LLShaderMgr::initAttribsAndUniforms() mReservedUniforms.push_back("global_gamma"); mReservedUniforms.push_back("texture_gamma"); - + mReservedUniforms.push_back("display_gamma"); + mReservedUniforms.push_back("specular_color"); mReservedUniforms.push_back("env_intensity"); diff --git a/indra/llrender/llshadermgr.h b/indra/llrender/llshadermgr.h index c049e935b8..2cbeea5049 100755 --- a/indra/llrender/llshadermgr.h +++ b/indra/llrender/llshadermgr.h @@ -168,7 +168,8 @@ public: GLOBAL_GAMMA, TEXTURE_GAMMA, - + DISPLAY_GAMMA, + SPECULAR_COLOR, ENVIRONMENT_INTENSITY, diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b928761358..e836e9750f 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -35,6 +35,8 @@ out vec4 frag_color; #define frag_color gl_FragColor #endif +uniform float display_gamma; + #if HAS_SHADOW uniform sampler2DShadow shadowMap0; uniform sampler2DShadow shadowMap1; @@ -204,6 +206,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } @@ -295,7 +302,7 @@ void main() #ifdef USE_VERTEX_COLOR float vertex_color_alpha = diff.a * vertex_color.a; #else - float vertex_color_alpha = 1.0; + float vertex_color_alpha = diff.a; #endif vec3 normal = vary_norm; @@ -333,7 +340,7 @@ void main() color.rgb += diff.rgb * vary_pointlight_col_linear * col.rgb; - color.rgb = linear_to_srgb(color.rgb); + color.rgb = pow(color.rgb,vec3(display_gamma)); #ifdef WATER_FOG color = applyWaterFogDeferred(pos.xyz, color); diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index da2585f662..da4ebfea58 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -117,6 +117,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index e028eef900..a46fbd9516 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -53,6 +53,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } @@ -701,7 +706,7 @@ void main() col += spec_contrib; } - col = mix(col.rgb, old_diffcol.rgb, diffuse.a); + col = mix(col.rgb, diffcol.rgb, diffuse.a); if (envIntensity > 0.0) { @@ -754,7 +759,7 @@ void main() frag_color.a = al; #else - //final_color.rgb = vec3(1,0,1); + //final_color.rgb = old_diffcol.rgb; frag_data[0] = final_color; frag_data[1] = final_specular; // XYZ = Specular color. W = Specular exponent. frag_data[2] = final_normal; // XY = Normal. Z = Env. intensity. diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 59b027a045..01f9d99682 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -36,7 +36,7 @@ uniform sampler2DRect diffuseRect; uniform vec2 screen_res; VARYING vec2 vary_fragcoord; -uniform float texture_gamma; +uniform float display_gamma; vec3 linear_to_srgb(vec3 cl) { @@ -45,13 +45,17 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } void main() { vec4 diff = texture2DRect(diffuseRect, vary_fragcoord); - diff.rgb = pow(diff.rgb,vec3(texture_gamma)); + diff.rgb = pow(diff.rgb,vec3(display_gamma)); frag_color = diff; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 6f11e8427c..045b449bbf 100755 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -101,6 +101,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } @@ -403,9 +408,7 @@ void main() ambient = (1.0-ambient); col.rgb *= ambient; - - col += atmosAffectDirectionalLight(max(min(da, 1.0), 0.0)); - + col += atmosAffectDirectionalLight(max(min(da, 1.0), 0.0)); col *= diffuse.rgb; vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index dbb32c40f4..fa67c4ecea 100755 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -100,6 +100,11 @@ vec3 linear_to_srgb(vec3 cl) cs = { 1.055 * cl^0.41666 - 0.055, 0.0031308 <= cl < 1 { 1.0, cl >= 1*/ + cl = clamp(cl, vec3(0), vec3(1)); + + if ((cl.r+cl.g+cl.b) < 0.0031308) + return 12.92 * cl; + return 1.055 * pow(cl, vec3(0.41666)) - 0.055; } @@ -467,8 +472,6 @@ void main() bloom = fogged.a; #endif - - col = srgb_to_linear(col); //col = vec3(1,0,1); diff --git a/indra/newview/lldrawpoolalpha.cpp b/indra/newview/lldrawpoolalpha.cpp index 973e263572..6302cf6b00 100755 --- a/indra/newview/lldrawpoolalpha.cpp +++ b/indra/newview/lldrawpoolalpha.cpp @@ -103,13 +103,18 @@ void LLDrawPoolAlpha::beginPostDeferredPass(S32 pass) simple_shader = &gDeferredAlphaProgram; fullbright_shader = &gDeferredFullbrightProgram; } + + F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); fullbright_shader->bind(); fullbright_shader->uniform1f(LLShaderMgr::TEXTURE_GAMMA, 2.2f); + fullbright_shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); fullbright_shader->unbind(); //prime simple shader (loads shadow relevant uniforms) gPipeline.bindDeferredShader(*simple_shader); + + simple_shader->uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); } else { diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index c593c85ce7..165b28beb5 100755 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -8833,7 +8833,7 @@ void LLPipeline::renderDeferredLighting() F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); @@ -9382,7 +9382,7 @@ void LLPipeline::renderDeferredLightingToRT(LLRenderTarget* target) F32 gamma = gSavedSettings.getF32("RenderDeferredDisplayGamma"); - gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::TEXTURE_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); + gDeferredPostGammaCorrectProgram.uniform1f(LLShaderMgr::DISPLAY_GAMMA, (gamma > 0.1f) ? 1.0f / gamma : (1.0f/2.2f)); gGL.begin(LLRender::TRIANGLE_STRIP); gGL.texCoord2f(tc1.mV[0], tc1.mV[1]); |