summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl')
-rwxr-xr-xindra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl52
1 files changed, 32 insertions, 20 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index 9df9d75905..10a598a85c 100755
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -60,6 +60,7 @@ uniform float density_multiplier;
uniform float distance_multiplier;
uniform float max_y;
uniform vec4 glow;
+uniform float global_gamma;
uniform float scene_light_strength;
uniform mat3 env_mat;
uniform vec4 shadow_clip;
@@ -79,6 +80,17 @@ vec3 vary_AmblitColor;
vec3 vary_AdditiveColor;
vec3 vary_AtmosAttenuation;
+vec3 decode_normal (vec2 enc)
+{
+ vec2 fenc = enc*4-2;
+ float f = dot(fenc,fenc);
+ float g = sqrt(1-f/4);
+ vec3 n;
+ n.xy = fenc*g;
+ n.z = 1-f/2;
+ return n;
+}
+
vec4 getPosition_d(vec2 pos_screen, float depth)
{
vec2 sc = pos_screen.xy*2.0;
@@ -222,9 +234,9 @@ void calcAtmospherics(vec3 inPositionEye, float ambFactor) {
+ tmpAmbient)));
//brightness of surface both sunlight and ambient
- setSunlitColor(vec3(sunlight * .5));
- setAmblitColor(vec3(tmpAmbient * .25));
- setAdditiveColor(getAdditiveColor() * vec3(1.0 - temp1));
+ setSunlitColor(pow(vec3(sunlight * .5), vec3(global_gamma)) * global_gamma);
+ setAmblitColor(pow(vec3(tmpAmbient * .25), vec3(global_gamma)) * global_gamma);
+ setAdditiveColor(pow(getAdditiveColor() * vec3(1.0 - temp1), vec3(global_gamma)) * global_gamma);
}
vec3 atmosLighting(vec3 light)
@@ -278,17 +290,16 @@ void main()
vec2 tc = vary_fragcoord.xy;
float depth = texture2DRect(depthMap, tc.xy).r;
vec3 pos = getPosition_d(tc, depth).xyz;
- vec3 norm = texture2DRect(normalMap, tc).xyz;
- norm = (norm.xyz-0.5)*2.0; // unpack norm
-
+ vec4 norm = texture2DRect(normalMap, tc);
+ float envIntensity = norm.z;
+ norm.xyz = decode_normal(norm.xy);
float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
-
+
vec4 diffuse = texture2DRect(diffuseRect, tc);
vec3 col;
float bloom = 0.0;
- if (diffuse.a < 0.9)
{
vec4 spec = texture2DRect(specularRect, vary_fragcoord.xy);
@@ -299,38 +310,39 @@ void main()
calcAtmospherics(pos.xyz, ambocc);
col = atmosAmbient(vec3(0));
- col += atmosAffectDirectionalLight(max(min(da, scol), diffuse.a));
+ col += atmosAffectDirectionalLight(max(min(da, scol) * 2.6, diffuse.a));
col *= diffuse.rgb;
+ vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+
if (spec.a > 0.0) // specular reflection
{
// the old infinite-sky shiny reflection
//
- vec3 refnormpersp = normalize(reflect(pos.xyz, norm.xyz));
+
float sa = dot(refnormpersp, sun_dir.xyz);
- vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(6 * texture2D(lightFunc, vec2(sa, spec.a)).r);
+ vec3 dumbshiny = vary_SunlitColor*scol_ambocc.r*(texture2D(lightFunc, vec2(sa, spec.a)).r);
// add the two types of shiny together
vec3 spec_contrib = dumbshiny * spec.rgb;
- bloom = dot(spec_contrib, spec_contrib) / 4;
+ bloom = dot(spec_contrib, spec_contrib) / 6;
col += spec_contrib;
+ }
- //add environmentmap
+ if (envIntensity > 0.0)
+ { //add environmentmap
vec3 env_vec = env_mat * refnormpersp;
- col = mix(col.rgb, textureCube(environmentMap, env_vec).rgb,
- max(spec.a-diffuse.a*2.0, 0.0));
+ col = mix(col.rgb, pow(textureCube(environmentMap, env_vec).rgb, vec3(2.2)) * 2.2,
+ envIntensity);
}
col = atmosLighting(col);
col = scaleSoftClip(col);
- col = mix(col, diffuse.rgb, diffuse.a);
- }
- else
- {
- col = diffuse.rgb;
+ col = mix(col.rgb, diffuse.rgb, diffuse.a);
}
+
frag_color.rgb = col;
frag_color.a = bloom;