summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGraham Linden <graham@lindenlab.com>2019-04-16 08:41:12 -0700
committerGraham Linden <graham@lindenlab.com>2019-04-16 08:41:12 -0700
commita7e7d4a8185cd63c2f6f87fea992667912999426 (patch)
tree33a94024a5a63fa5865eb8dea3288b62a60962f9
parent479385c97fa2d433c85598f6871274c970a6f9a7 (diff)
Make blended material objects use the same BRDF for spec as everything else.
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl36
1 files changed, 21 insertions, 15 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index d14e67fc73..0819f1b292 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -327,21 +327,27 @@ vec3 post_diffuse = col.rgb;
if (spec.a > 0.0) // specular reflection
{
- // the old infinite-sky shiny reflection
- //
-
- float sa = dot(refnormpersp, light_dir.xyz);
-
- vec3 dumbshiny = sunlit*shadow*(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) / 6;
-
- glare = max(spec_contrib.r, spec_contrib.g);
- glare = max(glare, spec_contrib.b);
-
- col += spec_contrib;
+ vec3 npos = -normalize(pos.xyz);
+
+ //vec3 ref = dot(pos+lv, norm);
+ vec3 h = normalize(light_dir.xyz+npos);
+ float nh = dot(norm.xyz, h);
+ float nv = dot(norm.xyz, 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);
+ vec3 speccol = sun_contrib*scol*spec.rgb;
+ speccol = clamp(speccol, vec3(0), vec3(1));
+ bloom = dot(speccol, speccol) / 6;
+ col += speccol;
+ }
}
vec3 post_spec = col.rgb;