diff options
Diffstat (limited to 'indra/newview')
30 files changed, 339 insertions, 310 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl index ae579d7f85..c4d89f29f6 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl @@ -119,9 +119,9 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec //distance attenuation float dist = (la > 0) ? d/la : 1.0f; fa += 1.0f; - float dist_atten = (fa > 0) ? clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0) : 1.0f; + float dist_atten = (fa > 0) ? clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0) : 0.0f; dist_atten *= dist_atten; - dist_atten *= 2.0f; + dist_atten *= 2.2f; // spotlight coefficient. float spot = max(dot(-ln, lv), is_pointlight); @@ -131,18 +131,15 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 diffuse, vec3 v, vec3 n, vec float lit = max(da * dist_atten,0.0); float amb_da = ambiance; - if (da > 0) + if (lit > 0) { col = lit * light_col * diffuse; amb_da += (da*0.5+0.5) * ambiance; + amb_da += (da*da*0.5 + 0.5) * ambiance; + amb_da *= dist_atten; + amb_da = min(amb_da, 1.0f - lit); } - amb_da += (da*da*0.5 + 0.5) * ambiance; - amb_da *= dist_atten; - amb_da = min(amb_da, 1.0f - lit); - -#ifndef NO_AMBIANCE col.rgb += amb_da * 0.5 * light_col * diffuse; -#endif // no spec for alpha shader... } @@ -164,22 +161,26 @@ void main() shadow = sampleDirectionalShadow(pos.xyz, norm.xyz, frag); #endif +#ifdef USE_DIFFUSE_TEX + vec4 diffuse_linear = texture2D(diffuseMap,vary_texcoord0.xy); +#endif + #ifdef USE_INDEXED_TEX - vec4 diff = diffuseLookup(vary_texcoord0.xy); -#else - vec4 diff = texture2D(diffuseMap,vary_texcoord0.xy); + vec4 diffuse_linear = diffuseLookup(vary_texcoord0.xy); #endif + vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); + #ifdef FOR_IMPOSTOR vec4 color; - color.rgb = diff.rgb; + color.rgb = diffuse_srgb.rgb; color.a = 1.0; #ifdef USE_VERTEX_COLOR - float final_alpha = diff.a * vertex_color.a; - diff.rgb *= vertex_color.rgb; + float final_alpha = diffuse_srgb.a * vertex_color.a; + diffuse_srgb.rgb *= vertex_color.rgb; #else - float final_alpha = diff.a; + float final_alpha = diffuse_srgb.a; #endif // Insure we don't pollute depth with invis pixels in impostor rendering @@ -191,16 +192,13 @@ void main() #else #ifdef USE_VERTEX_COLOR - float final_alpha = diff.a * vertex_color.a; - diff.rgb *= vertex_color.rgb; + float final_alpha = diffuse_linear.a * vertex_color.a; + diffuse_srgb.rgb *= vertex_color.rgb; + diffuse_linear.rgb *= vertex_color.rgb; #else - float final_alpha = diff.a; + float final_alpha = diffuse_linear.a; #endif - vec3 gamma_diff = diff.rgb; - - diff.rgb = srgb_to_linear(diff.rgb); - vec3 sunlit; vec3 amblit; vec3 additive; @@ -217,7 +215,7 @@ void main() float final_da = da; final_da = clamp(final_da, 0.0f, 1.0f); - vec4 color = vec4(0,0,0,0); + vec4 color = vec4(0.0); color.rgb = amblit; color.a = final_alpha; @@ -225,6 +223,7 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; + //ambient = max(getAmbientClamp(), ambient); // keeps shadows dark ambient = 1.0 - ambient; vec3 sun_contrib = min(final_da, shadow) * sunlit; @@ -237,14 +236,12 @@ vec3 post_ambient = color.rgb; vec3 post_sunlight = color.rgb; - color.rgb *= diff.rgb; + color.rgb *= diffuse_linear.rgb; vec3 post_diffuse = color.rgb; - color.rgb = mix(diff.rgb, color.rgb, final_alpha); - - //color.rgb = srgb_to_linear(color.rgb); - + //color.rgb = mix(diffuse_srgb.rgb, color.rgb, final_alpha); + color.rgb = atmosFragLighting(color.rgb, additive, atten); color.rgb = scaleSoftClipFrag(color.rgb); @@ -252,7 +249,10 @@ vec3 post_atmo = color.rgb; vec4 light = vec4(0,0,0,0); - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diff.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5); + // to linear! + color.rgb = srgb_to_linear(color.rgb); + + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, diffuse_linear.rgb, pos.xyz, norm, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, light_attenuation[i].w * 0.5); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -262,15 +262,29 @@ vec3 post_atmo = color.rgb; LIGHT_LOOP(6) LIGHT_LOOP(7) + // sum local light contrib in linear colorspace + color.rgb += light.rgb; + + // back to sRGB as we're going directly to the final RT post-deferred gamma correction color.rgb = linear_to_srgb(color.rgb); - color.rgb += light.rgb; -#endif + +//color.rgb = amblit; +//color.rgb = vec3(ambient); +//color.rgb = sunlit; +//color.rgb = vec3(final_da); +//color.rgb = post_ambient; +//color.rgb = post_sunlight; +//color.rgb = sun_contrib; +//color.rgb = diffuse_srgb.rgb; +//color.rgb = post_diffuse; +//color.rgb = post_atmo; #ifdef WATER_FOG color = applyWaterFogView(pos.xyz, color); -#endif +#endif // WATER_FOG +#endif frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index 9535cd6870..6ff97fd1e9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -1,5 +1,5 @@ /** - * @file WLCloudsF.glsl + * @file class1\deferred\cloudsF.glsl * * $LicenseInfo:firstyear=2005&license=viewerlgpl$ * Second Life Viewer Source Code @@ -120,7 +120,7 @@ void main() vec4 color; color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); color.rgb= max(vec3(0), color.rgb); - color.rgb = linear_to_srgb(color.rgb); + color.rgb *= 2.0; /// Gamma correct for WL (soft clip effect). frag_data[0] = vec4(scaleSoftClip(color.rgb), alpha1); diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl index 61fd43f1ee..f1eb1af90c 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsV.glsl @@ -78,7 +78,7 @@ void main() // Get relative position vec3 P = position.xyz - camPosLocal.xyz + vec3(0,50,0); - altitude_blend_factor = (P.y > -4096.0) ? 1.0 : 1.0 - clamp(abs(P.y) / max_y, 0.0, 1.0); + altitude_blend_factor = (P.y > -4096.0) ? 1.0 : 1.0 - clamp(abs(P.y) / max_y, 0.0, 1.0); // Set altitude if (P.y > 0.) @@ -86,7 +86,6 @@ void main() P *= (max_y / P.y); } else - if (P.y <= 0.0) { P *= (-32000. / P.y); } @@ -103,7 +102,7 @@ void main() vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; - float dens_mul = density_multiplier; + float dens_mul = density_multiplier * 0.45; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -127,6 +126,7 @@ void main() // compiler gets confused. temp1 = exp(-temp1 * temp2.z); + // Compute haze glow temp2.x = dot(Pn, lightnorm.xyz); temp2.x = 1. - temp2.x; @@ -138,7 +138,7 @@ void main() temp2.x = pow(temp2.x, glow.z); // glow.z should be negative, so we're doing a sort of (1 / "angle") function - temp2.x *= sun_moon_glow_factor; + temp2.x *= sun_moon_glow_factor; // Add "minimum anti-solar illumination" temp2.x += .25; @@ -179,7 +179,7 @@ void main() // Texture coords vary_texcoord0 = texcoord0; vary_texcoord0.xy -= 0.5; - vary_texcoord0.xy /= max(0.001, cloud_scale); + vary_texcoord0.xy /= cloud_scale; vary_texcoord0.xy += 0.5; vary_texcoord1 = vary_texcoord0; diff --git a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl index 828c325c9d..ccd1df84f9 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/diffuseIndexedF.glsl @@ -36,11 +36,12 @@ VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; vec2 encode_normal(vec3 n); +vec3 linear_to_srgb(vec3 c); void main() { vec3 col = vertex_color.rgb * diffuseLookup(vary_texcoord0.xy).rgb; - + vec3 spec; spec.rgb = vec3(vertex_color.a); diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl index f7af3647a1..64cdacd4a2 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl @@ -120,6 +120,7 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe fa += 1.0f; float dist_atten = ( fa > 0) ? clamp(1.0-(dist-1.0*(1.0-fa))/fa, 0.0, 1.0) : 1.0f; dist_atten *= dist_atten; + dist_atten *= 2.2f; if (dist_atten <= 0) { @@ -142,13 +143,10 @@ vec3 calcPointLightOrSpotLight(vec3 light_col, vec3 npos, vec3 diffuse, vec4 spe { col = light_col*lit*diffuse; amb_da += (da*0.5 + 0.5) * ambiance; + amb_da += (da*da*0.5+0.5) * ambiance; + amb_da = min(amb_da, 1.0f - lit); } - amb_da += (da*da*0.5+0.5) * ambiance; - amb_da = min(amb_da, 1.0f - lit); - -#ifndef NO_AMBIANCE - col.rgb += amb_da * 0.5 * light_col * diffuse; -#endif + col.rgb += amb_da * 0.25 * light_col * diffuse; if (spec.a > 0.0) { @@ -226,19 +224,17 @@ void main() { vec2 pos_screen = vary_texcoord0.xy; - vec4 diffcol = texture2D(diffuseMap, vary_texcoord0.xy); - diffcol.rgb *= vertex_color.rgb; + vec4 diffuse_linear = texture2D(diffuseMap, vary_texcoord0.xy); + vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_MASK) - if (diffcol.a < minimum_alpha) + if (diffuse_linear.a < minimum_alpha) { discard; } #endif -#if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) - vec3 gamma_diff = diffcol.rgb; -#endif + diffuse_linear.rgb *= vertex_color.rgb; #ifdef HAS_SPECULAR_MAP vec4 spec = texture2D(specularMap, vary_texcoord2.xy); @@ -247,17 +243,19 @@ void main() vec4 spec = vec4(specular_color.rgb, 1.0); #endif -#ifdef HAS_NORMAL_MAP - vec4 norm = texture2D(bumpMap, vary_texcoord1.xy); + vec4 norm = vec4(0,0,0,1.0); + vec3 tnorm; +#ifdef HAS_NORMAL_MAP + norm = texture2D(bumpMap, vary_texcoord1.xy); norm.xyz = norm.xyz * 2 - 1; - vec3 tnorm = vec3(dot(norm.xyz,vary_mat0), - dot(norm.xyz,vary_mat1), - dot(norm.xyz,vary_mat2)); + // tangent space norm + tnorm = vec3(dot(norm.xyz,vary_mat0), + dot(norm.xyz,vary_mat1), + dot(norm.xyz,vary_mat2)); #else - vec4 norm = vec4(0,0,0,1.0); - vec3 tnorm = vary_normal; + tnorm = vary_normal; #endif norm.xyz = tnorm; @@ -265,7 +263,7 @@ void main() vec2 abnormal = encode_normal(norm.xyz); - vec4 final_color = diffcol; + vec4 final_color = diffuse_linear; #if (DIFFUSE_ALPHA_MODE != DIFFUSE_ALPHA_MODE_EMISSIVE) final_color.a = emissive_brightness; @@ -274,14 +272,15 @@ void main() #endif vec4 final_specular = spec; + final_specular.a = specular_color.a; #ifdef HAS_SPECULAR_MAP - vec4 final_normal = vec4(encode_normal(normalize(tnorm)), env_intensity * spec.a, 0.0); - final_specular.a = specular_color.a * norm.a; -#else + final_specular.a *= norm.a; +#endif + vec4 final_normal = vec4(encode_normal(normalize(tnorm)), env_intensity, 0.0); - final_specular.a = specular_color.a; +#ifdef HAS_SPECULAR_MAP + final_normal.z *= spec.a; #endif - #if (DIFFUSE_ALPHA_MODE == DIFFUSE_ALPHA_MODE_BLEND) //forward rendering, output just lit RGBA @@ -294,13 +293,10 @@ void main() #endif spec = final_specular; - vec4 diffuse = final_color; - - diffuse.rgb = srgb_to_linear(diffuse.rgb); float envIntensity = final_normal.z; - vec3 col = vec3(0.0f,0.0f,0.0f); + vec3 color = vec3(0.0); float bloom = 0.0; vec3 sunlit; @@ -314,7 +310,7 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - float da = dot(norm.xyz, light_dir.xyz); + float da = dot(normalize(norm.xyz), normalize(light_dir.xyz)); da = clamp(da, -1.0, 1.0); float final_da = da; @@ -323,22 +319,23 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; + //ambient = max(getAmbientClamp(), ambient); ambient = 1.0 - ambient; vec3 sun_contrib = min(final_da, shadow) * sunlit; - col.rgb = amblit; - col.rgb *= ambient; + color.rgb = amblit; + color.rgb *= ambient; -vec3 post_ambient = col.rgb; +vec3 post_ambient = color.rgb; - col.rgb += sun_contrib; + color.rgb += sun_contrib; -vec3 post_sunlight = col.rgb; +vec3 post_sunlight = color.rgb; - col.rgb *= diffuse.rgb; + color.rgb *= diffuse_linear.rgb; -vec3 post_diffuse = col.rgb; +vec3 post_diffuse = color.rgb; float glare = 0.0; @@ -360,47 +357,47 @@ vec3 post_diffuse = col.rgb; if (nh > 0.0) { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - vec3 speccol = sun_contrib*scol*spec.rgb; + vec3 speccol = sun_contrib*scol*spec.rgb*0.25; speccol = clamp(speccol, vec3(0), vec3(1)); - bloom = dot(speccol, speccol) / 6; - col += speccol; + bloom = dot(speccol, speccol); + color += speccol; } } -vec3 post_spec = col.rgb; +vec3 post_spec = color.rgb; - col = mix(col.rgb, diffuse.rgb, diffuse.a); + //color = mix(color.rgb, diffuse_srgb.rgb, diffuse_srgb.a); if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; - vec3 refcol = textureCube(environmentMap, env_vec).rgb; + vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; - col = mix(col.rgb, refcol, - envIntensity); + color = mix(color.rgb, reflected_color, envIntensity); - float cur_glare = max(refcol.r, refcol.g); - cur_glare = max(cur_glare, refcol.b); + float cur_glare = max(reflected_color.r, reflected_color.g); + cur_glare = max(cur_glare, reflected_color.b); cur_glare *= envIntensity*4.0; glare += cur_glare; } -vec3 post_env = col.rgb; +vec3 post_env = color.rgb; + + color = atmosFragLighting(color, additive, atten); + color = scaleSoftClipFrag(color); + +vec3 post_atmo = color.rgb; - col = atmosFragLighting(col, additive, atten); - col = scaleSoftClipFrag(col); + //convert to linear space before adding local lights + color = srgb_to_linear(color); vec3 npos = normalize(-pos.xyz); vec3 light = vec3(0,0,0); -vec3 post_atmo = col.rgb; - - //col.rgb = srgb_to_linear(col.rgb); - - #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w * 0.5); + #define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse_linear.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w); LIGHT_LOOP(1) LIGHT_LOOP(2) @@ -410,27 +407,39 @@ vec3 post_atmo = col.rgb; LIGHT_LOOP(6) LIGHT_LOOP(7) -vec3 postlight_linear = col.rgb; glare = min(glare, 1.0); - float al = max(diffcol.a,glare)*vertex_color.a; + float al = max(diffuse_linear.a,glare)*vertex_color.a; + + color.rgb += light.rgb; + + // (only) post-deferred needs inline gamma correction + color.rgb = linear_to_srgb(color.rgb); + +//color.rgb = amblit; +//color.rgb = vec3(ambient); +//color.rgb = sunlit; +//color.rgb = post_ambient; +//color.rgb = vec3(final_da); +//color.rgb = sun_contrib; +//color.rgb = post_sunlight; +//color.rgb = diffuse_srgb.rgb; +//color.rgb = post_diffuse; +//color.rgb = post_spec; +//color.rgb = post_env; +//color.rgb = post_atmo; #ifdef WATER_FOG - vec4 temp = applyWaterFogView(pos, vec4(col.rgb, al)); - col.rgb = temp.rgb; + vec4 temp = applyWaterFogView(pos, vec4(color.rgb, al)); + color.rgb = temp.rgb; al = temp.a; #endif -//col.rgb = post_atmo; - - col.rgb = linear_to_srgb(col.rgb); - - col.rgb += light.rgb; - - frag_color.rgb = col.rgb; + frag_color.rgb = color.rgb; frag_color.a = al; #else + // deferred path 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/moonF.glsl b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl index 187b5a62dd..80f232948a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/moonF.glsl @@ -44,17 +44,21 @@ uniform sampler2D altDiffuseMap; uniform float blend_factor; // interp factor between moon A/B VARYING vec2 vary_texcoord0; +vec3 srgb_to_linear(vec3 c); void main() { vec4 moonA = texture2D(diffuseMap, vary_texcoord0.xy); vec4 moonB = texture2D(altDiffuseMap, vary_texcoord0.xy); vec4 c = mix(moonA, moonB, blend_factor); + c.rgb = srgb_to_linear(c.rgb); + // mix factor which blends when sunlight is brighter // and shows true moon color at night vec3 luma_weights = vec3(0.3, 0.5, 0.3); - float mix = 1.0 - dot(normalize(sunlight_color.rgb), luma_weights); + vec4 light_color = max(sunlight_color, moonlight_color); + float mix = 1.0 - dot(normalize(light_color.rgb), luma_weights); vec3 exp = vec3(1.0 - mix * moon_brightness) * 2.0 - 1.0; c.rgb = pow(c.rgb, exp); diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl index 6489508c00..2569e49743 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl @@ -72,8 +72,6 @@ uniform vec2 screen_res; uniform mat4 inv_proj; vec3 getNorm(vec2 pos_screen); -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { diff --git a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl index c2cb0eb8c3..14cd805d10 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/shadowUtil.glsl @@ -50,7 +50,7 @@ float pcfShadow(sampler2DShadow shadowMap, vec3 norm, vec4 stc, float bias_mul, { float offset = shadow_bias * bias_mul; stc.xyz /= stc.w; - stc.z += offset * 4.0; + stc.z += offset * 2.0; stc.x = floor(stc.x*shadow_res.x + fract(stc.y*shadow_res.y))/shadow_res.x; // add some chaotic jitter to X sample pos according to Y to disguise the snapping going on here float cs = shadow2D(shadowMap, stc.xyz).x; float shadow = cs * 4.0; @@ -124,7 +124,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.y, 0.0)/transition_domain.y; w -= max(near_split.z-spos.z, 0.0)/transition_domain.z; - w = clamp(w, 0.25, 1.0); + w = clamp(w, 0.0, 1.0); shadow += pcfShadow(shadowMap2, norm, lpos, 1.0, pos_screen, light_dir)*w; weight += w; } @@ -136,7 +136,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(spos.z-far_split.x, 0.0)/transition_domain.x; w -= max(near_split.y-spos.z, 0.0)/transition_domain.y; - w = clamp(w, 0.5, 1.0); + w = clamp(w, 0.0, 1.0); shadow += pcfShadow(shadowMap1, norm, lpos, 1.0, pos_screen, light_dir)*w; weight += w; } @@ -147,7 +147,7 @@ float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen) float w = 1.0; w -= max(near_split.x-spos.z, 0.0)/transition_domain.x; - w = clamp(w, 0.75, 1.0); + w = clamp(w, 0.0, 1.0); shadow += pcfShadow(shadowMap0, norm, lpos, 1.0, pos_screen, light_dir)*w; weight += w; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl index bee8e2dab5..4603c69f2a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/skyV.glsl @@ -87,7 +87,7 @@ void main() vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; - float dens_mul = density_multiplier; + float dens_mul = density_multiplier * 0.45; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl index bcd93d9a2d..981a50769a 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/softenLightF.glsl @@ -36,7 +36,6 @@ out vec4 frag_color; uniform sampler2DRect diffuseRect; uniform sampler2DRect specularRect; -uniform sampler2DRect positionMap; uniform sampler2DRect normalMap; uniform sampler2DRect lightMap; uniform sampler2DRect depthMap; @@ -47,13 +46,7 @@ uniform float blur_size; uniform float blur_fidelity; // Inputs -uniform vec4 morphFactor; -uniform vec3 camPosLocal; -//uniform vec4 camPosWorld; -uniform vec4 gamma; -uniform float global_gamma; uniform mat3 env_mat; -uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; uniform vec3 moon_dir; @@ -63,21 +56,20 @@ VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; uniform vec2 screen_res; -#ifdef WATER_FOG -vec4 applyWaterFogView(vec3 pos, vec4 color); -#endif - vec3 getNorm(vec2 pos_screen); -vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); +vec4 getPositionWithDepth(vec2 pos_screen, float depth); -float getAmbientClamp(); void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); - +float getAmbientClamp(); +vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); -vec3 srgb_to_linear(vec3 c); + vec3 linear_to_srgb(vec3 c); +vec3 srgb_to_linear(vec3 c); -vec4 getPositionWithDepth(vec2 pos_screen, float depth); +#ifdef WATER_FOG +vec4 applyWaterFogView(vec3 pos, vec4 color); +#endif void main() { @@ -88,50 +80,49 @@ void main() float envIntensity = norm.z; norm.xyz = getNorm(tc); - float light_gamma = 1.0/1.3; vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - float da = dot(normalize(norm.xyz), light_dir.xyz); da = clamp(da, -1.0, 1.0); float final_da = da; final_da = clamp(final_da, 0.0, 1.0); - //final_da = pow(final_da, light_gamma); - vec4 gamma_diff = texture2DRect(diffuseRect, tc); - vec4 diffuse = gamma_diff; - diffuse.rgb = srgb_to_linear(gamma_diff.rgb); + vec4 diffuse_linear = texture2DRect(diffuseRect, tc); + vec4 diffuse_srgb = vec4(linear_to_srgb(diffuse_linear.rgb), diffuse_linear.a); vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); - vec3 col; + vec3 color = vec3(0); float bloom = 0.0; { + float ambocc = 1.0; // no AO... + vec3 sunlit; vec3 amblit; vec3 additive; vec3 atten; - - calcAtmosphericVars(pos.xyz, 1.0, sunlit, amblit, additive, atten); + + calcAtmosphericVars(pos.xyz, ambocc, sunlit, amblit, additive, atten); float ambient = da; ambient *= 0.5; ambient *= ambient; + //ambient = max(getAmbientClamp(), ambient); ambient = 1.0 - ambient; vec3 sun_contrib = final_da * sunlit; - col.rgb = amblit; - col.rgb *= ambient; + color.rgb = amblit; + color.rgb *= ambient; -vec3 post_ambient = col.rgb; +vec3 post_ambient = color.rgb; - col.rgb += sun_contrib; + color.rgb += sun_contrib; -vec3 post_sunlight = col.rgb; +vec3 post_sunlight = color.rgb; - col.rgb *= gamma_diff.rgb; + color.rgb *= diffuse_linear.rgb; -vec3 post_diffuse = col.rgb; +vec3 post_diffuse = color.rgb; vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); @@ -152,40 +143,59 @@ vec3 post_diffuse = col.rgb; if (nh > 0.0) { - float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - vec3 speccol = sun_contrib*scol*spec.rgb; + float scontrib = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); + vec3 speccol = sun_contrib*scontrib*spec.rgb*0.25; speccol = clamp(speccol, vec3(0), vec3(1)); - bloom = dot(speccol, speccol) / 6; - col += speccol; + bloom += dot(speccol, speccol); + color += speccol; } } - vec3 post_spec = col.rgb; + vec3 post_spec = color.rgb; - col.rgb += diffuse.a * diffuse.rgb; + color.rgb += diffuse_srgb.a * diffuse_srgb.rgb; if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; - vec3 refcol = textureCube(environmentMap, env_vec).rgb; - col = mix(col.rgb, refcol, envIntensity); + vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; + color = mix(color.rgb, reflected_color, envIntensity); } - + +vec3 post_env = color.rgb; + if (norm.w < 1) { - col = atmosFragLighting(col, additive, atten); - col = scaleSoftClipFrag(col); + color = atmosFragLighting(color, additive, atten); + color = scaleSoftClipFrag(color); } -vec3 post_atmo = col.rgb; +vec3 post_atmo = color.rgb; #ifdef WATER_FOG - vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom)); - col = fogged.rgb; + vec4 fogged = applyWaterFogView(pos.xyz,vec4(color, bloom)); + color = fogged.rgb; bloom = fogged.a; #endif + +//color.rgb = amblit; +//color.rgb = vec3(ambient); +//color.rgb = sunlit; +//color.rgb = post_ambient; +//color.rgb = vec3(final_da); +//color.rgb = sun_contrib; +//color.rgb = post_sunlight; +//color.rgb = diffuse_srgb.rgb; +//color.rgb = post_diffuse; +//color.rgb = post_spec; +//color.rgb = post_env; +//color.rgb = post_atmo; + +// convert to linear as fullscreen lights need to sum in linear colorspace +// and will be gamma (re)corrected downstream... + color.rgb = srgb_to_linear(color.rgb); } - frag_color.rgb = col.rgb; + frag_color.rgb = color.rgb; frag_color.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl index 571e9d9326..454af2a9bc 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/sunDiscF.glsl @@ -33,6 +33,7 @@ out vec4 frag_data[3]; #define frag_data gl_FragData #endif +vec3 srgb_to_linear(vec3 c); vec3 fullbrightAtmosTransport(vec3 light); vec3 fullbrightScaleSoftClip(vec3 light); @@ -47,6 +48,8 @@ void main() vec4 sunDiscA = texture2D(diffuseMap, vary_texcoord0.xy); vec4 sunDiscB = texture2D(altDiffuseMap, vary_texcoord0.xy); vec4 c = mix(sunDiscA, sunDiscB, blend_factor); + + c.rgb = srgb_to_linear(c.rgb); c.rgb = clamp(c.rgb, vec3(0), vec3(1)); c.rgb = pow(c.rgb, vec3(0.7f)); diff --git a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl index cd1e2d6e32..a3041fccdc 100644 --- a/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl +++ b/indra/newview/app_settings/shaders/class1/windlight/atmosphericsFuncs.glsl @@ -137,7 +137,7 @@ void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, o + tmpAmbient)); //brightness of surface both sunlight and ambient - sunlit = sunlight.rgb; + sunlit = sunlight.rgb * 0.5; amblit = tmpAmbient.rgb * .25; additive *= vec3(1.0 - temp1); } diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl index 9cd5592d7c..54ec534d14 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl @@ -71,12 +71,21 @@ uniform vec2 screen_res; uniform mat4 inv_proj; +vec3 srgb_to_linear(vec3 cs); +vec3 linear_to_srgb(vec3 cl); + vec3 getNorm(vec2 pos_screen); -vec3 scaleDownLight(vec3 light); + + +vec4 correctWithGamma(vec4 col) +{ + return vec4(srgb_to_linear(col.rgb), col.a); +} + vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - + ret = correctWithGamma(ret); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); float det = min(lod/(proj_lod*0.5), 1.0); @@ -95,6 +104,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -112,6 +122,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -213,21 +224,18 @@ void main() col = dlit*lit*diff_tex*shadow; // unshadowed for consistency between forward and deferred? - amb_da += (da*0.5+0.5) * (1.0-shadow) * proj_ambiance; + amb_da += (da*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance; } //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod); // use unshadowed for consistency between forward and deferred? - amb_da += (da*da*0.5+0.5) * (1.0-shadow) * proj_ambiance; + amb_da += (da*da*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance; amb_da *= dist_atten * noise; amb_da = min(amb_da, 1.0-lit); -#ifndef NO_AMBIANCE col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; -#endif - } @@ -288,8 +296,6 @@ void main() //not sure why, but this line prevents MATBUG-194 col = max(col, vec3(0.0)); - col = scaleDownLight(col); - frag_color.rgb = col; frag_color.a = 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 a8eb7102ed..bd0ca0a46e 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/skyF.glsl @@ -117,7 +117,7 @@ void main() vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; - float dens_mul = density_multiplier; + float dens_mul = density_multiplier * 0.45; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl index 7368b8d80c..f6f8f56103 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl @@ -45,40 +45,27 @@ uniform float blur_size; uniform float blur_fidelity; // Inputs -uniform vec4 morphFactor; -uniform vec3 camPosLocal; -//uniform vec4 camPosWorld; -uniform float cloud_shadow; -uniform float max_y; -uniform float global_gamma; -uniform float display_gamma; uniform mat3 env_mat; -uniform vec4 shadow_clip; -uniform mat3 ssao_effect_mat; uniform vec3 sun_dir; uniform vec3 moon_dir; uniform int sun_up_factor; - VARYING vec2 vary_fragcoord; uniform mat4 inv_proj; uniform vec2 screen_res; vec3 getNorm(vec2 pos_screen); +vec4 getPositionWithDepth(vec2 pos_screen, float depth); +void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); +float getAmbientClamp(); vec3 atmosFragLighting(vec3 l, vec3 additive, vec3 atten); vec3 scaleSoftClipFrag(vec3 l); -void calcAtmosphericVars(vec3 inPositionEye, float ambFactor, out vec3 sunlit, out vec3 amblit, out vec3 additive, out vec3 atten); -float getAmbientClamp(); -vec3 atmosTransportFrag(vec3 light, vec3 additive, vec3 atten); vec3 linear_to_srgb(vec3 c); vec3 srgb_to_linear(vec3 c); -vec4 getPositionWithDepth(vec2 pos_screen, float depth); -vec4 getPosition(vec2 pos_screen); - #ifdef WATER_FOG vec4 applyWaterFogView(vec3 pos, vec4 color); #endif @@ -94,24 +81,24 @@ void main() vec3 light_dir = (sun_up_factor == 1) ? sun_dir : moon_dir; - float light_gamma = 1.0/1.3; float scol = 1.0; vec2 scol_ambocc = texture2DRect(lightMap, vary_fragcoord.xy).rg; float da = dot(normalize(norm.xyz), light_dir.xyz); da = clamp(da, -1.0, 1.0); - vec4 gamma_diff = texture2DRect(diffuseRect, tc); - vec4 diffuse = gamma_diff; - diffuse.rgb = srgb_to_linear(diffuse.rgb); - - scol = max(scol_ambocc.r, diffuse.a); + float final_da = da; final_da = clamp(final_da, 0.0, 1.0); + vec4 diffuse_srgb = texture2DRect(diffuseRect, tc); + vec4 diffuse_linear = vec4(srgb_to_linear(diffuse_srgb.rgb), diffuse_srgb.a); + + scol = max(scol_ambocc.r, diffuse_linear.a); + vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy); - vec3 col; + vec3 color = vec3(0); float bloom = 0.0; { float ambocc = scol_ambocc.g; @@ -126,22 +113,23 @@ void main() float ambient = da; ambient *= 0.5; ambient *= ambient; + //ambient = max(getAmbientClamp(), ambient); ambient = 1.0 - ambient; - vec3 sun_contrib = scol * final_da * sunlit; + vec3 sun_contrib = min(scol, final_da) * sunlit; - col.rgb = amblit; - col.rgb *= ambient; + color.rgb = amblit; + color.rgb *= ambient; -vec3 post_ambient = col.rgb; +vec3 post_ambient = color.rgb; - col.rgb += sun_contrib; + color.rgb += sun_contrib; -vec3 post_sunlight = col.rgb; +vec3 post_sunlight = color.rgb; - col.rgb *= gamma_diff.rgb; + color.rgb *= diffuse_srgb.rgb; -vec3 post_diffuse = col.rgb; +vec3 post_diffuse = color.rgb; vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz)); @@ -163,34 +151,58 @@ vec3 post_diffuse = col.rgb; if (nh > 0.0) { float scontrib = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); - vec3 speccol = sun_contrib*scontrib*spec.rgb; + vec3 speccol = sun_contrib*scontrib*spec.rgb * 0.25; speccol = clamp(speccol, vec3(0), vec3(1)); - bloom += dot (speccol, speccol) / 6; - col += speccol; + bloom += dot (speccol, speccol); + color += speccol; } } - - col.rgb += diffuse.a * gamma_diff.rgb; + + vec3 post_spec = color.rgb; + + color.rgb += diffuse_srgb.a * diffuse_srgb.rgb; if (envIntensity > 0.0) { //add environmentmap vec3 env_vec = env_mat * refnormpersp; - vec3 refcol = textureCube(environmentMap, env_vec).rgb; - col = mix(col.rgb, refcol, envIntensity); + vec3 reflected_color = textureCube(environmentMap, env_vec).rgb; + color = mix(color.rgb, reflected_color, envIntensity); } +vec3 post_env = color.rgb; + if (norm.w < 1) { - col = atmosFragLighting(col, additive, atten); - col = scaleSoftClipFrag(col); + color = atmosFragLighting(color, additive, atten); + color = scaleSoftClipFrag(color); } +vec3 post_atmo = color.rgb; + #ifdef WATER_FOG - vec4 fogged = applyWaterFogView(pos.xyz,vec4(col, bloom)); - col = fogged.rgb; + vec4 fogged = applyWaterFogView(pos.xyz,vec4(color, bloom)); + color = fogged.rgb; bloom = fogged.a; #endif + +//color.rgb = amblit; +//color.rgb = vec3(ambient); +//color.rgb = sunlit; +//color.rgb = post_ambient; +//color.rgb = vec3(final_da); +//color.rgb = sun_contrib; +//color.rgb = post_sunlight; +//color.rgb = diffuse_srgb.rgb; +//color.rgb = post_diffuse; +//color.rgb = post_spec; +//color.rgb = post_env; +//color.rgb = post_atmo; + +// convert to linear as fullscreen lights need to sum in linear colorspace +// and will be gamma (re)corrected downstream... + color.rgb = srgb_to_linear(color.rgb); } - frag_color.rgb = col.rgb; + + frag_color.rgb = color.rgb; frag_color.a = bloom; } diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl index 957ce579c0..2ef7cffe9d 100644 --- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl @@ -72,12 +72,17 @@ uniform vec2 screen_res; uniform mat4 inv_proj; vec3 getNorm(vec2 pos_screen); -vec3 scaleDownLight(vec3 c); +vec3 srgb_to_linear(vec3 c); +vec4 correctWithGamma(vec4 col) +{ + return vec4(srgb_to_linear(col.rgb), col.a); +} vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - + ret = correctWithGamma(ret); + vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); float det = min(lod/(proj_lod*0.5), 1.0); @@ -96,6 +101,7 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -113,6 +119,7 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); + ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -213,19 +220,17 @@ void main() col = dlit*lit*diff_tex*shadow; - amb_da += (da*0.5+0.5) * (1.0-shadow) * proj_ambiance; + amb_da += (da*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance; } //float diff = clamp((proj_range-proj_focus)/proj_range, 0.0, 1.0); vec4 amb_plcol = texture2DLodAmbient(projectionMap, proj_tc.xy, proj_lod); - amb_da += (da*da*0.5+0.5)*(1.0-shadow)*proj_ambiance; + amb_da += (da*da*0.5+0.5) /* * (1.0-shadow) */ * proj_ambiance; amb_da *= dist_atten * noise; amb_da = min(amb_da, 1.0-lit); -#ifndef NO_AMBIANCE col += amb_da*color.rgb*diff_tex.rgb*amb_plcol.rgb*amb_plcol.a; -#endif } @@ -290,8 +295,6 @@ void main() //not sure why, but this line prevents MATBUG-194 col = max(col, vec3(0.0)); - col = scaleDownLight(col); - frag_color.rgb = col; frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl index 94e776d51d..36703ea742 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/atmosphericsF.glsl @@ -44,7 +44,6 @@ uniform mat3 ssao_effect_mat; uniform int no_atmo; uniform float sun_moon_glow_factor; -vec3 srgb_to_linear(vec3 c); vec3 scaleSoftClipFrag(vec3 light); vec3 atmosFragLighting(vec3 light, vec3 additive, vec3 atten) diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl index e31bdf610c..1de919bf30 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsF.glsl @@ -86,14 +86,14 @@ void main() vec2 disturbance2 = vec2(cloudNoise((uv1 + uv3) / 4.0f).x, cloudNoise((uv4 + uv2) / 8.0f).x) * cloud_variance * (1.0f - cloud_scale * 0.25f); // Offset texture coords - uv1 += cloud_pos_density1.xy + (disturbance * 0.02); //large texture, visible density + uv1 += cloud_pos_density1.xy;// + (disturbance * 0.02); //large texture, visible density uv2 += cloud_pos_density1.xy; //large texture, self shadow uv3 += cloud_pos_density2.xy; //small texture, visible density uv4 += cloud_pos_density2.xy; //small texture, self shadow float density_variance = min(1.0, (disturbance.x* 2.0 + disturbance.y* 2.0 + disturbance2.x + disturbance2.y)); - cloudDensity *= 1.0 - (density_variance * density_variance); + //cloudDensity *= 1.0 - (density_variance * density_variance); // Compute alpha1, the main cloud opacity @@ -104,12 +104,12 @@ void main() alpha1 = 1. - alpha1 * alpha1; alpha1 = 1. - alpha1 * alpha1; - alpha1 *= altitude_blend_factor; + //alpha1 *= altitude_blend_factor; - if (alpha1 < 0.001f) - { - discard; - } + //if (alpha1 < 0.001f) + //{ + // discard; + //} // Compute alpha2, for self shadowing effect // (1 - alpha2) will later be used as percentage of incoming sunlight diff --git a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl index 64156bd3bf..43500bc5e3 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/cloudsV.glsl @@ -103,7 +103,7 @@ void main() vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; - float dens_mul = density_multiplier; + float dens_mul = density_multiplier * 0.45; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes @@ -180,7 +180,8 @@ void main() // Texture coords vary_texcoord0 = texcoord0; vary_texcoord0.xy -= 0.5; - vary_texcoord0.xy /= max(0.001, cloud_scale); + vary_texcoord0.xy /= cloud_scale; + //vary_texcoord0.xy /= max(0.001, cloud_scale); vary_texcoord0.xy += 0.5; vary_texcoord1 = vary_texcoord0; diff --git a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl index 6d6b3dafa7..f6bef3e6bc 100644 --- a/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl +++ b/indra/newview/app_settings/shaders/class2/windlight/skyV.glsl @@ -87,7 +87,7 @@ void main() vec4 sunlight = (sun_up_factor == 1) ? sunlight_color : moonlight_color; vec4 light_atten; - float dens_mul = density_multiplier; + float dens_mul = density_multiplier * 0.45; // Sunlight attenuation effect (hue and brightness) due to atmosphere // this is used later for sunlight modulation at various altitudes diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl index abb6a3a5d8..52de7ceaad 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl @@ -71,19 +71,11 @@ uniform vec2 screen_res; uniform mat4 inv_proj; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); vec3 getNorm(vec2 pos_screen); -vec4 correctWithGamma(vec4 col) -{ - return vec4(srgb_to_linear(col.rgb), col.a); -} - vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -103,7 +95,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -121,7 +112,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -260,10 +250,6 @@ void main() //col += spec.rgb; } } - - - - if (envIntensity > 0.0) { @@ -297,6 +283,8 @@ void main() //not sure why, but this line prevents MATBUG-194 col = max(col, vec3(0.0)); + col = scaleDownLight(col); + frag_color.rgb = col; frag_color.a = 0.0; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl index ad721a80d6..6400e5169e 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl @@ -146,8 +146,8 @@ void main() vec3 dumbshiny = scol * texture2D(lightFunc, vec2(sa, spec.a)).r * atmo_color; // add the two types of shiny together - vec3 spec_contrib = dumbshiny * spec.rgb; - bloom = dot(spec_contrib, spec_contrib) / 6; + vec3 spec_contrib = dumbshiny * spec.rgb * 0.25; + bloom = dot(spec_contrib, spec_contrib); col += spec_contrib; } diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl index afc542b8bc..bccd819a43 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl @@ -72,18 +72,10 @@ uniform vec2 screen_res; uniform mat4 inv_proj; vec3 getNorm(vec2 pos_screen); -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); - -vec4 correctWithGamma(vec4 col) -{ - return vec4(srgb_to_linear(col.rgb), col.a); -} vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret.rgb = srgb_to_linear(ret.rgb); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -103,7 +95,6 @@ vec4 texture2DLodSpecular(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); vec2 dist = vec2(0.5) - abs(tc-vec2(0.5)); @@ -121,7 +112,6 @@ vec4 texture2DLodDiffuse(sampler2D projectionMap, vec2 tc, float lod) vec4 texture2DLodAmbient(sampler2D projectionMap, vec2 tc, float lod) { vec4 ret = texture2DLod(projectionMap, tc, lod); - ret = correctWithGamma(ret); vec2 dist = tc-vec2(0.5); @@ -256,7 +246,6 @@ void main() { float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da); col += dlit*scol*spec.rgb*shadow; - //col += spec.rgb; } } diff --git a/indra/newview/app_settings/shaders/class3/deferred/underWaterF.glsl b/indra/newview/app_settings/shaders/class3/deferred/underWaterF.glsl index 9d18d1afd8..540226e672 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/underWaterF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/underWaterF.glsl @@ -58,9 +58,6 @@ VARYING vec4 refCoord; VARYING vec4 littleWave; VARYING vec4 view; -vec3 srgb_to_linear(vec3 cs); -vec3 linear_to_srgb(vec3 cl); - vec2 encode_normal(vec3 n); vec4 applyWaterFog(vec4 color, vec3 viewVec) diff --git a/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl b/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl index 2a144ba23a..c65cf48c67 100644 --- a/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl +++ b/indra/newview/app_settings/shaders/class3/deferred/waterF.glsl @@ -61,7 +61,6 @@ VARYING vec4 view; VARYING vec4 vary_position; vec3 scaleSoftClip(vec3 c); -vec3 srgb_to_linear(vec3 cs); vec2 encode_normal(vec3 n); vec3 BlendNormal(vec3 bump1, vec3 bump2) diff --git a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl index f5428077fa..69267621a3 100644 --- a/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl +++ b/indra/newview/app_settings/shaders/class3/lighting/lightV.glsl @@ -31,8 +31,8 @@ vec4 sumLights(vec3 pos, vec3 norm, vec4 color); vec4 calcLighting(vec3 pos, vec3 norm, vec4 color) { - vec4 c = sumLights(pos, norm, color) * 2.0; - c.rgb += atmosAmbient() * color.rgb * 0.5; - return c; + vec4 c = sumLights(pos, norm, color * 2.0); + c.rgb += atmosAmbient() * color.rgb; + return c * 2.0; } diff --git a/indra/newview/lldrawpoolwlsky.cpp b/indra/newview/lldrawpoolwlsky.cpp index 9039c8cbcb..b9bc7678e6 100644 --- a/indra/newview/lldrawpoolwlsky.cpp +++ b/indra/newview/lldrawpoolwlsky.cpp @@ -484,9 +484,6 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() { sun_shader->bind(); - gGL.getTexUnit(0)->setTextureColorSpace(LLTexUnit::TCS_SRGB); - gGL.getTexUnit(1)->setTextureColorSpace(LLTexUnit::TCS_SRGB); - if (tex_a && (!tex_b || (tex_a == tex_b))) { // Bind current and next sun textures @@ -535,9 +532,6 @@ void LLDrawPoolWLSky::renderHeavenlyBodies() { moon_shader->bind(); - gGL.getTexUnit(0)->setTextureColorSpace(LLTexUnit::TCS_SRGB); - gGL.getTexUnit(1)->setTextureColorSpace(LLTexUnit::TCS_SRGB); - if (tex_a && (!tex_b || (tex_a == tex_b))) { // Bind current and next sun textures diff --git a/indra/newview/llsettingsvo.cpp b/indra/newview/llsettingsvo.cpp index 628666c3ed..d307e1a947 100644 --- a/indra/newview/llsettingsvo.cpp +++ b/indra/newview/llsettingsvo.cpp @@ -707,6 +707,9 @@ void LLSettingsVOSky::applySpecial(void *ptarget) shader->uniform4fv(LLShaderMgr::SUNLIGHT_COLOR, 1, sunDiffuse.mV); shader->uniform4fv(LLShaderMgr::MOONLIGHT_COLOR, 1, moonDiffuse.mV); + + LLColor4 cloud_color(psky->getCloudColor(), 1.0); + shader->uniform4fv(LLShaderMgr::CLOUD_COLOR, 1, cloud_color.mV); } F32 g = getGamma(); @@ -736,14 +739,17 @@ LLSettingsSky::parammapping_t LLSettingsVOSky::getParameterMap() const // Following values are always present, so we can just zero these ones, but used values from defaults() LLSD sky_defaults = LLSettingsSky::defaults(); - param_map[SETTING_CLOUD_COLOR] = DefaultParam(LLShaderMgr::CLOUD_COLOR, sky_defaults[SETTING_CLOUD_COLOR]); + param_map[SETTING_CLOUD_POS_DENSITY2] = DefaultParam(LLShaderMgr::CLOUD_POS_DENSITY2, sky_defaults[SETTING_CLOUD_POS_DENSITY2]); param_map[SETTING_CLOUD_SCALE] = DefaultParam(LLShaderMgr::CLOUD_SCALE, sky_defaults[SETTING_CLOUD_SCALE]); param_map[SETTING_CLOUD_SHADOW] = DefaultParam(LLShaderMgr::CLOUD_SHADOW, sky_defaults[SETTING_CLOUD_SHADOW]); param_map[SETTING_CLOUD_VARIANCE] = DefaultParam(LLShaderMgr::CLOUD_VARIANCE, sky_defaults[SETTING_CLOUD_VARIANCE]); param_map[SETTING_GLOW] = DefaultParam(LLShaderMgr::GLOW, sky_defaults[SETTING_GLOW]); param_map[SETTING_MAX_Y] = DefaultParam(LLShaderMgr::MAX_Y, sky_defaults[SETTING_MAX_Y]); + //param_map[SETTING_SUNLIGHT_COLOR] = DefaultParam(LLShaderMgr::SUNLIGHT_COLOR, sky_defaults[SETTING_SUNLIGHT_COLOR]); + //param_map[SETTING_CLOUD_COLOR] = DefaultParam(LLShaderMgr::CLOUD_COLOR, sky_defaults[SETTING_CLOUD_COLOR]); + param_map[SETTING_MOON_BRIGHTNESS] = DefaultParam(LLShaderMgr::MOON_BRIGHTNESS, sky_defaults[SETTING_MOON_BRIGHTNESS]); param_map[SETTING_SKY_MOISTURE_LEVEL] = DefaultParam(LLShaderMgr::MOISTURE_LEVEL, sky_defaults[SETTING_SKY_MOISTURE_LEVEL]); param_map[SETTING_SKY_DROPLET_RADIUS] = DefaultParam(LLShaderMgr::DROPLET_RADIUS, sky_defaults[SETTING_SKY_DROPLET_RADIUS]); diff --git a/indra/newview/llviewershadermgr.cpp b/indra/newview/llviewershadermgr.cpp index 0bd4a5eae0..ff7ba6b284 100644 --- a/indra/newview/llviewershadermgr.cpp +++ b/indra/newview/llviewershadermgr.cpp @@ -1340,6 +1340,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredDiffuseProgram.mName = "Deferred Diffuse Shader"; gDeferredDiffuseProgram.mFeatures.encodesNormal = true; + gDeferredDiffuseProgram.mFeatures.hasSrgb = true; gDeferredDiffuseProgram.mShaderFiles.clear(); gDeferredDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseIndexedF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1389,6 +1390,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredNonIndexedDiffuseProgram.mName = "Non Indexed Deferred Diffuse Shader"; gDeferredNonIndexedDiffuseProgram.mShaderFiles.clear(); gDeferredNonIndexedDiffuseProgram.mFeatures.encodesNormal = true; + gDeferredNonIndexedDiffuseProgram.mFeatures.hasSrgb = true; gDeferredNonIndexedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredNonIndexedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER_ARB)); gDeferredNonIndexedDiffuseProgram.mShaderLevel = mShaderLevel[SHADER_DEFERRED]; @@ -1401,6 +1403,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredSkinnedDiffuseProgram.mName = "Deferred Skinned Diffuse Shader"; gDeferredSkinnedDiffuseProgram.mFeatures.hasObjectSkinning = true; gDeferredSkinnedDiffuseProgram.mFeatures.encodesNormal = true; + gDeferredSkinnedDiffuseProgram.mFeatures.hasSrgb = true; gDeferredSkinnedDiffuseProgram.mShaderFiles.clear(); gDeferredSkinnedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseSkinnedV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredSkinnedDiffuseProgram.mShaderFiles.push_back(make_pair("deferred/diffuseF.glsl", GL_FRAGMENT_SHADER_ARB)); @@ -1829,10 +1832,12 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() { gDeferredAlphaImpostorProgram.mName = "Deferred Alpha Impostor Shader"; +// Begin Hack gDeferredAlphaImpostorProgram.mFeatures.calculatesLighting = false; gDeferredAlphaImpostorProgram.mFeatures.hasLighting = false; + + gDeferredAlphaImpostorProgram.mFeatures.hasSrgb = true; gDeferredAlphaImpostorProgram.mFeatures.isAlphaLighting = true; - gDeferredAlphaImpostorProgram.mFeatures.disableTextureIndex = true; //hack to disable auto-setup of gDeferredAlphaImpostorProgram.mFeatures.hasSrgb = true; gDeferredAlphaImpostorProgram.mFeatures.encodesNormal = true; gDeferredAlphaImpostorProgram.mFeatures.hasShadows = use_sun_shadow; @@ -1864,7 +1869,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() success = gDeferredAlphaImpostorProgram.createShader(NULL, NULL); llassert(success); - // Hack +// End Hack gDeferredAlphaImpostorProgram.mFeatures.calculatesLighting = true; gDeferredAlphaImpostorProgram.mFeatures.hasLighting = true; } @@ -2514,6 +2519,7 @@ BOOL LLViewerShaderMgr::loadShadersDeferred() gDeferredWLSunProgram.mFeatures.hasAtmospherics = true; gDeferredWLSunProgram.mFeatures.isFullbright = true; gDeferredWLSunProgram.mFeatures.disableTextureIndex = true; + gDeferredWLSunProgram.mFeatures.hasSrgb = true; gDeferredWLSunProgram.mShaderFiles.clear(); gDeferredWLSunProgram.mShaderFiles.push_back(make_pair("deferred/sunDiscV.glsl", GL_VERTEX_SHADER_ARB)); gDeferredWLSunProgram.mShaderFiles.push_back(make_pair("deferred/sunDiscF.glsl", GL_FRAGMENT_SHADER_ARB)); diff --git a/indra/newview/pipeline.cpp b/indra/newview/pipeline.cpp index 4cd63de70c..9d8f5721d2 100644 --- a/indra/newview/pipeline.cpp +++ b/indra/newview/pipeline.cpp @@ -7544,7 +7544,7 @@ void LLPipeline::renderBloom(bool for_snapshot, F32 zoom_factor, int subfield) gGL.setSceneBlendType(LLRender::BT_ADD_WITH_ALPHA); - mScreen.bindTexture(0, 0); + mScreen.bindTexture(0, 0, LLTexUnit::TFO_BILINEAR); gGL.color4f(1,1,1,1); gPipeline.enableLightsFullbright(LLColor4(1,1,1,1)); @@ -7777,7 +7777,7 @@ void LLPipeline::renderBloom(bool for_snapshot, F32 zoom_factor, int subfield) S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); if (channel > -1) { - mScreen.bindTexture(0, channel); + mScreen.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } shader->uniform1f(LLShaderMgr::DOF_FOCAL_DISTANCE, -subject_distance/1000.f); @@ -7816,7 +7816,7 @@ void LLPipeline::renderBloom(bool for_snapshot, F32 zoom_factor, int subfield) S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredLight.getUsage()); if (channel > -1) { - mDeferredLight.bindTexture(0, channel); + mDeferredLight.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } shader->uniform1f(LLShaderMgr::DOF_MAX_COF, CameraMaxCoF); @@ -7860,8 +7860,7 @@ void LLPipeline::renderBloom(bool for_snapshot, F32 zoom_factor, int subfield) S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); if (channel > -1) { - mScreen.bindTexture(0, channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + mScreen.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } if (!LLViewerCamera::getInstance()->cameraUnderWater()) @@ -7909,7 +7908,7 @@ void LLPipeline::renderBloom(bool for_snapshot, F32 zoom_factor, int subfield) S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mScreen.getUsage()); if (channel > -1) { - mScreen.bindTexture(0, channel); + mScreen.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } if (!LLViewerCamera::getInstance()->cameraUnderWater()) @@ -7956,7 +7955,7 @@ void LLPipeline::renderBloom(bool for_snapshot, F32 zoom_factor, int subfield) S32 channel = shader->enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, mDeferredLight.getUsage()); if (channel > -1) { - mDeferredLight.bindTexture(0, channel); + mDeferredLight.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } gGL.begin(LLRender::TRIANGLE_STRIP); @@ -7978,8 +7977,7 @@ void LLPipeline::renderBloom(bool for_snapshot, F32 zoom_factor, int subfield) channel = shader->enableTexture(LLShaderMgr::DIFFUSE_MAP, mFXAABuffer.getUsage()); if (channel > -1) { - mFXAABuffer.bindTexture(0, channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_BILINEAR); + mFXAABuffer.bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } gGLViewport[0] = gViewerWindow->getWorldViewRectRaw().mLeft; @@ -8144,25 +8142,19 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ channel = shader.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, deferred_target->getUsage()); if (channel > -1) { - deferred_target->bindTexture(0,channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - gGL.getTexUnit(channel)->setTextureColorSpace(LLTexUnit::TCS_SRGB); + deferred_target->bindTexture(0,channel, LLTexUnit::TFO_POINT); } channel = shader.enableTexture(LLShaderMgr::DEFERRED_SPECULAR, deferred_target->getUsage()); if (channel > -1) { - deferred_target->bindTexture(1, channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - gGL.getTexUnit(channel)->setTextureColorSpace(LLTexUnit::TCS_SRGB); + deferred_target->bindTexture(1, channel, LLTexUnit::TFO_POINT); } channel = shader.enableTexture(LLShaderMgr::DEFERRED_NORMAL, deferred_target->getUsage()); if (channel > -1) { - deferred_target->bindTexture(2, channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); - gGL.getTexUnit(channel)->setTextureColorSpace(LLTexUnit::TCS_LINEAR); + deferred_target->bindTexture(2, channel, LLTexUnit::TFO_POINT); } channel = shader.enableTexture(LLShaderMgr::DEFERRED_DEPTH, deferred_depth_target->getUsage()); @@ -8212,14 +8204,13 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ channel = shader.enableTexture(LLShaderMgr::DEFERRED_LIGHT, light_target->getUsage()); if (channel > -1) { - light_target->bindTexture(0, channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + light_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); } channel = shader.enableTexture(LLShaderMgr::DEFERRED_BLOOM); if (channel > -1) { - mGlow[1].bindTexture(0, channel); + mGlow[1].bindTexture(0, channel, LLTexUnit::TFO_BILINEAR); } stop_glerror(); @@ -8285,7 +8276,7 @@ void LLPipeline::bindDeferredShader(LLGLSLShader& shader, LLRenderTarget* light_ stop_glerror(); - channel = shader.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP, LLTexUnit::TCS_SRGB); + channel = shader.enableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); if (channel > -1) { LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; @@ -8784,7 +8775,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) mCubeVB->setBuffer(LLVertexBuffer::MAP_VERTEX); - gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION, LLTexUnit::TT_TEXTURE, LLTexUnit::TCS_SRGB); + gDeferredSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); for (LLDrawable::drawable_list_t::iterator iter = spot_lights.begin(); iter != spot_lights.end(); ++iter) { @@ -8812,7 +8803,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) mCubeVB->drawRange(LLRender::TRIANGLE_FAN, 0, 7, 8, get_box_fan_indices(camera, center)); } - gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION, LLTexUnit::TT_TEXTURE, LLTexUnit::TCS_SRGB); + gDeferredSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); unbindDeferredShader(gDeferredSpotLightProgram); } @@ -8868,7 +8859,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) bindDeferredShader(gDeferredMultiSpotLightProgram); - gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION, LLTexUnit::TT_TEXTURE, LLTexUnit::TCS_SRGB); + gDeferredMultiSpotLightProgram.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); mDeferredVB->setBuffer(LLVertexBuffer::MAP_VERTEX); @@ -8899,7 +8890,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) mDeferredVB->drawArrays(LLRender::TRIANGLES, 0, 3); } - gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION, LLTexUnit::TT_TEXTURE, LLTexUnit::TCS_SRGB); + gDeferredMultiSpotLightProgram.disableTexture(LLShaderMgr::DEFERRED_PROJECTION); unbindDeferredShader(gDeferredMultiSpotLightProgram); gGL.popMatrix(); @@ -8936,8 +8927,7 @@ void LLPipeline::renderDeferredLighting(LLRenderTarget* screen_target) channel = gDeferredPostGammaCorrectProgram.enableTexture(LLShaderMgr::DEFERRED_DIFFUSE, screen_target->getUsage()); if (channel > -1) { - screen_target->bindTexture(0,channel); - gGL.getTexUnit(channel)->setTextureFilteringOption(LLTexUnit::TFO_POINT); + screen_target->bindTexture(0, channel, LLTexUnit::TFO_POINT); } gDeferredPostGammaCorrectProgram.uniform2f(LLShaderMgr::DEFERRED_SCREEN_RES, screen_target->getWidth(), screen_target->getHeight()); @@ -9144,7 +9134,7 @@ void LLPipeline::setupSpotLight(LLGLSLShader& shader, LLDrawable* drawablep) img = LLViewerFetchedTexture::sWhiteImagep; } - S32 channel = shader.enableTexture(LLShaderMgr::DEFERRED_PROJECTION, LLTexUnit::TT_TEXTURE, LLTexUnit::TCS_SRGB); + S32 channel = shader.enableTexture(LLShaderMgr::DEFERRED_PROJECTION); if (channel > -1) { @@ -9196,7 +9186,7 @@ void LLPipeline::unbindDeferredShader(LLGLSLShader &shader) shader.disableTexture(LLShaderMgr::DEFERRED_NOISE); shader.disableTexture(LLShaderMgr::DEFERRED_LIGHTFUNC); - S32 channel = shader.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP, LLTexUnit::TCS_SRGB); + S32 channel = shader.disableTexture(LLShaderMgr::ENVIRONMENT_MAP, LLTexUnit::TT_CUBE_MAP); if (channel > -1) { LLCubeMap* cube_map = gSky.mVOSkyp ? gSky.mVOSkyp->getCubeMap() : NULL; @@ -10191,7 +10181,8 @@ void LLPipeline::generateSunShadow(LLCamera& camera) //LLVector3 n = RenderShadowNearDist; //F32 nearDist[] = { n.mV[0], n.mV[1], n.mV[2], n.mV[2] }; - LLVector3 caster_dir(environment.getIsSunUp() ? mSunDir : mMoonDir); + LLVector3 caster_dir(environment.getIsSunUp() ? LLVector3(environment.getClampedSunNorm()) : + environment.getIsMoonUp() ? LLVector3(environment.getClampedMoonNorm()) : LLVector3(0,0,1)); //put together a universal "near clip" plane for shadow frusta LLPlane shadow_near_clip; @@ -10280,7 +10271,6 @@ void LLPipeline::generateSunShadow(LLCamera& camera) //far_clip = llmin(far_clip, 128.f); far_clip = llmin(far_clip, camera.getFar()); - far_clip = llmax(far_clip, 256.0f); F32 range = far_clip-near_clip; |