summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-05-24 10:34:47 -0500
committerDave Parks <davep@lindenlab.com>2022-05-24 10:34:47 -0500
commit0940e8871894e08da80730d11c31cbd252a05b35 (patch)
treea73b1ce8c7539c0c71d3eb4670e77311507a56f0 /indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
parent6eaf8521abae0deeb1162f9c61747183110176b0 (diff)
SL-17472 Add checkbox to preferences for enabling "PBR" that uses "class3" deferred shaders. Move reflection probe shaders to class3 and restore class2 shaders to non-reflection probe versions.
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred/materialF.glsl')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl64
1 files changed, 31 insertions, 33 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index c5b1937cfb..02d83925ea 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -64,13 +64,6 @@ out vec4 frag_color;
float sampleDirectionalShadow(vec3 pos, vec3 norm, vec2 pos_screen);
#endif
-#ifdef HAS_REFLECTION_PROBES
-void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv,
- vec3 pos, vec3 norm, float glossiness, float envIntensity);
-void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 norm);
-void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity);
-#endif
-
uniform samplerCube environmentMap;
uniform sampler2D lightFunc;
@@ -329,16 +322,6 @@ void main()
// lighting from the sun stays sharp
float da = clamp(dot(normalize(norm.xyz), light_dir.xyz), 0.0, 1.0);
da = pow(da, 1.0 / 1.3);
- vec3 sun_contrib = min(da, shadow) * sunlit;
-
-#ifdef HAS_REFLECTION_PROBES
- vec3 ambenv;
- vec3 glossenv;
- vec3 legacyenv;
- sampleReflectionProbes(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity);
- amblit = max(ambenv, amblit);
- color.rgb = amblit;
-#else
color = amblit;
@@ -350,8 +333,9 @@ void main()
ambient *= ambient;
ambient = (1.0 - ambient);
+ vec3 sun_contrib = min(da, shadow) * sunlit;
+
color *= ambient;
-#endif
color += sun_contrib;
@@ -361,6 +345,35 @@ void main()
if (spec.a > 0.0) // specular reflection
{
+ /* // Reverting this specular calculation to previous 'dumbshiny' version - DJH 6/17/2020
+ // Preserving the refactored version as a comment for potential reconsideration,
+ // overriding the general rule to avoid pollutiong the source with commented code.
+ //
+ // If you're reading this in 2021+, feel free to obliterate.
+
+ 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 sp = sun_contrib*scol / 6.0f;
+ sp = clamp(sp, vec3(0), vec3(1));
+ bloom = dot(sp, sp) / 4.0;
+ color += sp * spec.rgb;
+ }
+ */
+
float sa = dot(refnormpersp, sun_dir.xyz);
vec3 dumbshiny = sunlit * shadow * (texture2D(lightFunc, vec2(sa, spec.a)).r);
@@ -372,24 +385,10 @@ void main()
glare = max(glare, spec_contrib.b);
color += spec_contrib;
-
-#ifdef HAS_REFLECTION_PROBES
- applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz);
-#endif
}
-
color = mix(color.rgb, diffcol.rgb, diffuse.a);
-#ifdef HAS_REFLECTION_PROBES
- if (envIntensity > 0.0)
- { // add environmentmap
- //fudge darker
- legacyenv *= 0.5*diffuse.a+0.5;
-
- applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
- }
-#else
if (envIntensity > 0.0)
{
//add environmentmap
@@ -404,7 +403,6 @@ void main()
cur_glare *= envIntensity*4.0;
glare += cur_glare;
}
-#endif
color = atmosFragLighting(color, additive, atten);
color = scaleSoftClipFrag(color);