diff options
19 files changed, 54 insertions, 32 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index b4de492abc..7dc2fb4cc0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -239,7 +239,7 @@ void main() vec3 sun_contrib = min(final_da, shadow) * sunlit; #if !defined(AMBIENT_KILL) - color.rgb = amblit * 2.0; + color.rgb = amblit; color.rgb *= ambient; #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index 6ff97fd1e9..d6bd0a7917 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -55,7 +55,6 @@ VARYING float altitude_blend_factor; /// Soft clips the light with a gamma correction vec3 scaleSoftClip(vec3 light); -vec3 linear_to_srgb(vec3 c); vec4 cloudNoise(vec2 uv) { @@ -121,10 +120,13 @@ void main() color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); color.rgb= max(vec3(0), color.rgb); color.rgb *= 2.0; + color.rgb = scaleSoftClip(color.rgb); /// Gamma correct for WL (soft clip effect). - frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1); + frag_data[0] = vec4(color.rgb, alpha1); frag_data[1] = vec4(0.0,0.0,0.0,0.0); - frag_data[2] = vec4(0,0,1,0); + frag_data[2] = vec4(0,0,0,1); + + gl_FragDepth = 0.99995f; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index 1f0fa97297..571d0dd17a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -326,7 +326,7 @@ void main() vec3 sun_contrib = min(final_da, shadow) * sunlit; #if !defined(AMBIENT_KILL) - color.rgb = amblit * 2.0; + color.rgb = amblit; color.rgb *= ambient; #endif diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl index 367680556a..3607f5a086 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiPointLightF.glsl @@ -58,6 +58,7 @@ uniform mat4 inv_proj; vec4 getPosition(vec2 pos_screen); vec3 getNorm(vec2 pos_screen); +vec3 srgb_to_linear(vec3 c); void main() { @@ -77,6 +78,7 @@ void main() vec4 spec = texture2DRect(specularRect, frag.xy); vec3 diff = texture2DRect(diffuseRect, frag.xy).rgb; + diff.rgb = srgb_to_linear(diff.rgb); float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 npos = normalize(-pos); diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index c81d633880..e28506dcff 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -178,6 +178,8 @@ void main() vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + diff_tex.rgb = srgb_to_linear(diff_tex.rgb); + vec3 dlit = vec3(0, 0, 0); float noise = texture2D(noiseMap, frag.xy/128.0).b; diff --git a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl index 73bc1141b0..b3ce1ce2e0 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/pointLightF.glsl @@ -89,6 +89,7 @@ void main() float noise = texture2D(noiseMap, frag.xy/128.0).b; vec3 col = texture2DRect(diffuseRect, frag.xy).rgb; + float fa = falloff+1.0; float dist_atten = clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0); dist_atten *= dist_atten; diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl index 72b7aa9036..894ce8a5e9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyF.glsl @@ -41,6 +41,8 @@ uniform vec4 gamma; /// Soft clips the light with a gamma correction vec3 scaleSoftClip(vec3 light); +vec3 srgb_to_linear(vec3 c); +vec3 linear_to_srgb(vec3 c); void main() { @@ -51,10 +53,12 @@ void main() vec4 color; color = vary_HazeColor; - color *= 2.; + color.rgb *= 2.0f; + //color.rgb = scaleSoftClip(color.rgb); + //color.rgb = linear_to_srgb(color.rgb); /// Gamma correct for WL (soft clip effect). - frag_data[0] = vec4(scaleSoftClip(color.rgb), 1.0); + frag_data[0] = vec4(color.rgb, 1.0); frag_data[1] = vec4(0.0,0.0,0.0,0.0); frag_data[2] = vec4(0.5,0.5,0.0,1.0); //1.0 in norm.w masks off fog diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index 1ab0bc4c20..bdc2a676da 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -49,6 +49,7 @@ uniform float haze_density; uniform float cloud_shadow; uniform float density_multiplier; +uniform float distance_multiplier; uniform float max_y; uniform vec4 glow; @@ -88,6 +89,7 @@ void main() vec4 light_atten; float dens_mul = density_multiplier; + float dist_mul = distance_multiplier; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -109,7 +111,7 @@ void main() // Transparency (-> temp1) // ATI Bugfix -- can't store temp1*temp2.z in a variable because the ati // compiler gets confused. - temp1 = exp(-temp1 * temp2.z); + temp1 = exp(-temp1 * temp2.z * dist_mul); // Compute haze glow @@ -153,7 +155,7 @@ void main() // At horizon, blend high altitude sky color towards the darker color below the clouds vary_HazeColor += (additiveColorBelowCloud - vary_HazeColor) * (1. - sqrt(temp1)); - + // won't compile on mac without this being set //vary_AtmosAttenuation = vec3(0.0,0.0,0.0); } diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index 8c0f74d679..aa55b36d4a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -111,8 +111,8 @@ void main() vec3 sun_contrib = final_da * sunlit; #if !defined(AMBIENT_KILL) - color.rgb = amblit; - color.rgb *= ambient; + color.rgb = amblit * 2.0; + color.rgb *= ambient * 0.5; #endif vec3 post_ambient = color.rgb; diff --git a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl index 55c740d100..5e985618f7 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/spotLightF.glsl @@ -177,6 +177,8 @@ void main() float da = dot(norm, lv); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; + diff_tex.rgb = srgb_to_linear(diff_tex.rgb); + vec4 spec = texture2DRect(specularRect, frag.xy); float noise = texture2D(noiseMap, frag.xy/128.0).b; diff --git a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl index a9161b2a20..fd5b6989eb 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/waterF.glsl @@ -144,7 +144,6 @@ void main() vec4 baseCol = texture2D(refTex, refvec4); refcol = mix(baseCol*df2, refcol, dweight); - refcol.rgb = srgb_to_linear(refcol.rgb); //get specular component float spec = clamp(dot(lightDir, (reflect(viewVec,wavef))),0.0,1.0); @@ -159,7 +158,7 @@ void main() //mix with reflection // Note we actually want to use just df1, but multiplying by 0.999999 gets around an nvidia compiler bug - color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.4 + 0.6); + color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.999999); vec4 pos = vary_position; @@ -167,7 +166,7 @@ void main() //color.rgb = atmosTransport(color.rgb); color.rgb = scaleSoftClip(color.rgb); - + color.a = spec * sunAngle2; vec3 screenspacewavef = normalize((norm_mat*vec4(wavef, 1.0)).xyz); diff --git a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl index f033c0e7c4..4e550b8284 100644 --- a/indra/newview/app_settings/shaders/class1/environment/waterF.glsl +++ b/indra/newview/app_settings/shaders/class1/environment/waterF.glsl @@ -150,11 +150,9 @@ void main() //mix with reflection // Note we actually want to use just df1, but multiplying by 0.999999 gets around and nvidia compiler bug - color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.4 + 0.6); + color.rgb = mix(fb.rgb, refcol.rgb, df1 * 0.9999999); color.rgb += spec * specular; - - //color.rgb = atmosTransport(color.rgb); - color.rgb = scaleSoftClip(color.rgb * 0.5); + color.a = spec * sunAngle2; #if defined(WATER_EDGE) diff --git a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl index 751e7da53d..5e39d1629d 100644 --- a/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class1/lighting/lightV.glsl @@ -35,7 +35,7 @@ vec4 calcLighting(vec3 pos, vec3 norm, vec4 color) vec4 c = sumLights(pos, norm, color); #if !defined(AMBIENT_KILL) - c.rgb += atmosAmbient() * color.rgb * getAmbientClamp(); + c.rgb += atmosAmbient() * color.rgb * 0.5 * getAmbientClamp(); #endif return c; diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index bcce4c041a..8cad21d5b4 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -191,7 +191,8 @@ void main() float da = dot(norm, lv); vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb; - + diff_tex.rgb = srgb_to_linear(diff_tex.rgb); + vec4 spec = texture2DRect(specularRect, frag.xy); vec3 dlit = vec3(0, 0, 0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl index 921f87cf14..0f33bac3c6 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl @@ -88,7 +88,6 @@ vec3 halo22(float d) /// Soft clips the light with a gamma correction vec3 scaleSoftClip(vec3 light); -vec3 srgb_to_linear(vec3 c); void main() { @@ -198,7 +197,6 @@ void main() color.rgb *= 2.; color.rgb = scaleSoftClip(color.rgb); - color.rgb = srgb_to_linear(color.rgb); /// Gamma correct for WL (soft clip effect). frag_data[0] = vec4(color.rgb, 1.0); diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index da85786317..53cdce4cb1 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -91,8 +91,8 @@ void main() float final_da = da; final_da = clamp(final_da, 0.0, 1.0); - vec4 diffuse_linear = texture2DRect(diffuseRect, tc); - vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); + vec4 diffuse_srgb = texture2DRect(diffuseRect, tc); + vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); // clamping to alpha value kills underwater shadows... //scol = max(scol_ambocc.r, diffuse_linear.a); @@ -120,7 +120,7 @@ void main() #if !defined(AMBIENT_KILL) color.rgb = amblit * 2.0; - color.rgb *= ambient; + color.rgb *= ambient * 0.5; #endif vec3 post_ambient = color.rgb; @@ -131,7 +131,7 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diffuse_linear.rgb; + color.rgb *= diffuse_srgb.rgb; vec3 post_diffuse = color.rgb; @@ -183,8 +183,10 @@ vec3 post_env = color.rgb; if (norm.w < 1) { +#if !defined(SUNLIGHT_KILL) color = atmosFragLighting(color, additive, atten); color = scaleSoftClipFrag(color); +#endif } vec3 post_atmo = color.rgb; @@ -216,6 +218,7 @@ vec3 post_atmo = color.rgb; //color.rgb = vec3(final_da); //color.rgb = vec3(ambient); //color.rgb = vec3(scol); +//color.rgb = diffuse_linear.rgb; frag_color.rgb = color.rgb; frag_color.a = bloom; diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index 396ceacd19..e7ae2d52e3 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -123,11 +123,12 @@ void main() // Combine vec4 color; color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); - color *= 2.; + color.rgb *= 2.; + color.rgb = scaleSoftClip(color.rgb); /// Gamma correct for WL (soft clip effect). - frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1); + frag_data[0] = vec4(color.rgb, alpha1); frag_data[1] = vec4(0.0,0.0,0.0,0.0); - frag_data[2] = vec4(0,0,1,0); + frag_data[2] = vec4(0,0,0,1); } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 0542e39db4..22fb38f2eb 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -43,6 +43,7 @@ #include "pipeline.h" #include "llsky.h" #include "llvowlsky.h" +#include "llsettingsvo.h" static LLStaticHashedString sCamPosLocal("camPosLocal"); static LLStaticHashedString sCustomAlpha("custom_alpha"); @@ -181,6 +182,8 @@ void LLDrawPoolWLSky::renderSkyHazeDeferred(const LLVector3& camPosLocal, F32 ca sky_shader->bindTexture(LLShaderMgr::RAINBOW_MAP, rainbow_tex); sky_shader->bindTexture(LLShaderMgr::HALO_MAP, halo_tex); + ((LLSettingsVOSky*)psky.get())->updateShader(sky_shader); + F32 moisture_level = (float)psky->getSkyMoistureLevel(); F32 droplet_radius = (float)psky->getSkyDropletRadius(); F32 ice_level = (float)psky->getSkyIceLevel(); @@ -397,6 +400,8 @@ void LLDrawPoolWLSky::renderSkyCloudsDeferred(const LLVector3& camPosLocal, F32 cloudshader->uniform1f(LLShaderMgr::CLOUD_VARIANCE, cloud_variance); cloudshader->uniform1f(LLShaderMgr::SUN_MOON_GLOW_FACTOR, psky->getSunMoonGlowFactor()); + ((LLSettingsVOSky*)psky.get())->updateShader(cloudshader); + /// Render the skydome renderDome(camPosLocal, camHeightLocal, cloudshader); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index ea43203f1c..21de974ad5 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1744,6 +1744,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredLightProgram.mName = "Deferred Light Shader"; gDeferredLightProgram.mFeatures.isDeferred = true; gDeferredLightProgram.mFeatures.hasShadows = true; + gDeferredLightProgram.mFeatures.hasSrgb = true; gDeferredLightProgram.mShaderFiles.clear(); gDeferredLightProgram.mShaderFiles.push_back(make_pair("deferred/pointLightV.glsl", GL_VERTEX_SHADER_ARB)); @@ -1778,6 +1779,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredMultiLightProgram[i].mName = llformat("Deferred MultiLight Shader %d", i); gDeferredMultiLightProgram[i].mFeatures.isDeferred = true; gDeferredMultiLightProgram[i].mFeatures.hasShadows = true; + gDeferredMultiLightProgram[i].mFeatures.hasSrgb = true; gDeferredMultiLightProgram[i].clearPermutations(); gDeferredMultiLightProgram[i].mShaderFiles.clear(); @@ -2693,7 +2695,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredWLSkyProgram.mShaderFiles.push_back(make_pair("deferred/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredWLSkyProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; + gDeferredWLSkyProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLSkyProgram.mShaderGroup = LLGLSLShader::SG_SKY; success = gDeferredWLSkyProgram.createShader(NULL, NULL); @@ -2711,7 +2713,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredWLCloudProgram.mShaderFiles.push_back(make_pair("deferred/cloudsF.glsl", GL_FRAGMENT_SHADER_ARB)); - gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; + gDeferredWLCloudProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; gDeferredWLCloudProgram.mShaderGroup = LLGLSLShader::SG_SKY; success = gDeferredWLCloudProgram.createShader(NULL, NULL); llassert(success); @@ -4096,11 +4098,11 @@ BOOL LLViewerShaderMgr::loadShadersWindLight() if (success) { gWLSkyProgram.mName = "Windlight Sky Shader"; - //gWLSkyProgram.mFeatures.hasGamma = true; gWLSkyProgram.mShaderFiles.clear(); gWLSkyProgram.mFeatures.calculatesAtmospherics = true; gWLSkyProgram.mFeatures.hasTransport = true; gWLSkyProgram.mFeatures.hasGamma = true; + gWLSkyProgram.mFeatures.hasSrgb = true; gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyV.glsl", GL_VERTEX_SHADER_ARB)); gWLSkyProgram.mShaderFiles.push_back(make_pair("windlight/skyF.glsl", GL_FRAGMENT_SHADER_ARB)); gWLSkyProgram.mShaderLevel = mShaderLevel[SHADER_WINDLIGHT]; |