summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2013-04-02 01:47:12 -0500
committerDave Parks <davep@lindenlab.com>2013-04-02 01:47:12 -0500
commit8da8e05964710bea633af2bee36a7aa89f3a8656 (patch)
tree2d59b455082a342cee23be0d2f9c55bee6ec5308 /indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
parentc7da38eb68249e8178fab645041a450c63a18b28 (diff)
NORSPEC-58 Followup -- put back blinn phong, and do gamma correction approximation in light curves. Fix fresnel math.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl29
1 files changed, 26 insertions, 3 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
index bff87cb6aa..09d23db096 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/multiSpotLightF.glsl
@@ -40,6 +40,7 @@ uniform sampler2DRect normalMap;
uniform samplerCube environmentMap;
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
@@ -142,7 +143,7 @@ void main()
}
vec3 norm = texture2DRect(normalMap, frag.xy).xyz;
- norm = vec3((norm.xy-0.5)*2.0, norm.z);
+ norm = norm = (norm.xyz-0.5)*2.0;
norm = normalize(norm);
float l_dist = -dot(lv, proj_n);
@@ -190,6 +191,8 @@ void main()
vec3 lcol = color.rgb * plcol.rgb * plcol.a;
lit = da * dist_atten * noise;
+
+ lit = pow(lit, 0.7);
col = lcol*lit*diff_tex;
amb_da += (da*0.5)*proj_ambiance;
@@ -236,8 +239,28 @@ 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;
+
+ 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 (sa > 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*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;
}
}
}