summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class2/deferred
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class2/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl31
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl5
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl25
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl1
-rw-r--r--indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl1
5 files changed, 56 insertions, 7 deletions
diff --git a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
index 5621e47ab7..d237ec6236 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/multiSpotLightF.glsl
@@ -39,6 +39,7 @@ uniform samplerCube environmentMap;
uniform sampler2DRect lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
+uniform sampler2D lightFunc;
uniform mat4 proj_mat; //screen space to light space
uniform float proj_near; //near clip for projection
@@ -177,7 +178,7 @@ void main()
lv = proj_origin-pos.xyz;
lv = normalize(lv);
float da = dot(norm, lv);
-
+
vec3 col = vec3(0,0,0);
vec3 diff_tex = texture2DRect(diffuseRect, frag.xy).rgb;
@@ -203,6 +204,8 @@ void main()
lit = da * dist_atten * noise;
+ lit = pow(lit, 0.7);
+
col = lcol*lit*diff_tex*shadow;
amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
}
@@ -241,6 +244,7 @@ void main()
float fatten = clamp(spec.a*spec.a+spec.a*0.5, 0.25, 1.0);
+ //stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
stc.xy = (stc.xy - vec2(0.5)) * fatten + vec2(0.5);
if (stc.x < 1.0 &&
@@ -248,8 +252,29 @@ void main()
stc.x > 0.0 &&
stc.y > 0.0)
{
- vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
- col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow;
+
+ vec3 npos = -normalize(pos);
+ lv = pfinal-pos.xyz;
+ lv = normalize(lv);
+
+ vec3 h = normalize(lv+npos);
+ float nh = dot(norm, h);
+ float nv = dot(norm, npos);
+ float vh = dot(npos, h);
+ float sa = nh;
+ float fres = pow(1 - dot(h, npos), 5)*0.4+0.5;
+
+ float gtdenom = 2 * nh;
+ float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh)));
+
+ if (nh > 0.0)
+ {
+ float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
+ col += scol*color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod).rgb*shadow*spec.rgb;
+ }
+
+ //vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
+ //col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow;
}
}
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
index ff20b63972..eafb7d9c75 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/softenLightF.glsl
@@ -282,7 +282,8 @@ void main()
norm.xyz = (norm.xyz-0.5)*2.0; // unpack norm
float da = max(dot(norm.xyz, sun_dir.xyz), 0.0);
-
+ da = pow(da, 0.7);
+
vec4 diffuse = texture2DRect(diffuseRect, tc);
vec3 col;
@@ -309,7 +310,7 @@ void main()
//
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;
diff --git a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
index 6d6ad6d565..af8089ce67 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/spotLightF.glsl
@@ -39,6 +39,8 @@ uniform samplerCube environmentMap;
uniform sampler2DRect lightMap;
uniform sampler2D noiseMap;
uniform sampler2D projectionMap;
+uniform sampler2D lightFunc;
+
uniform mat4 proj_mat; //screen space to light space
uniform float proj_near; //near clip for projection
@@ -203,6 +205,8 @@ void main()
lit = da * dist_atten * noise;
+ lit = pow(lit, 0.7);
+
col = lcol*lit*diff_tex*shadow;
amb_da += (da*0.5)*(1.0-shadow)*proj_ambiance;
}
@@ -248,8 +252,25 @@ void main()
stc.x > 0.0 &&
stc.y > 0.0)
{
- vec4 scol = texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod);
- col += dist_atten*scol.rgb*color.rgb*scol.a*spec.rgb*shadow;
+ vec3 npos = -normalize(pos);
+ lv = pfinal-pos.xyz;
+ lv = normalize(lv);
+
+ vec3 h = normalize(lv+npos);
+ float nh = dot(norm, h);
+ float nv = dot(norm, npos);
+ float vh = dot(npos, h);
+ float sa = nh;
+ float fres = pow(1 - dot(h, npos), 5)*0.4+0.5;
+
+ float gtdenom = 2 * nh;
+ float gt = max(0,(min(gtdenom * nv / vh, gtdenom * da / vh)));
+
+ if (nh > 0.0)
+ {
+ float scol = fres*texture2D(lightFunc, vec2(nh, spec.a)).r*gt/(nh*da);
+ col += scol*color.rgb*texture2DLodSpecular(projectionMap, stc.xy, proj_lod-spec.a*proj_lod).rgb*shadow*spec.rgb;
+ }
}
}
}
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
index 890486c4b1..147fb4562e 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightF.glsl
@@ -138,6 +138,7 @@ void main()
float shadow = 0.0;
float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz));
+ dp_directional_light = pow(dp_directional_light, 0.7);
vec3 shadow_pos = pos.xyz + displace*norm;
vec3 offset = sun_dir.xyz * (1.0-dp_directional_light);
diff --git a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
index 2dcd3d656f..907b96ffe4 100644
--- a/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
+++ b/indra/newview/app_settings/shaders/class2/deferred/sunLightSSAOF.glsl
@@ -199,6 +199,7 @@ void main()
float shadow = 0.0;
float dp_directional_light = max(0.0, dot(norm, sun_dir.xyz));
+ dp_directional_light = pow(dp_directional_light, 0.7);
vec3 shadow_pos = pos.xyz + displace*norm;
vec3 offset = sun_dir.xyz * (1.0-dp_directional_light);