summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class1/deferred
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
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')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl50
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl64
2 files changed, 48 insertions, 66 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl
index a04f611440..9fcee04c32 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightShinyF.glsl
@@ -35,11 +35,10 @@ out vec4 frag_color;
uniform sampler2D diffuseMap;
#endif
-
VARYING vec4 vertex_color;
VARYING vec2 vary_texcoord0;
VARYING vec3 vary_texcoord1;
-VARYING vec3 vary_position;
+VARYING vec4 vary_position;
uniform samplerCube environmentMap;
@@ -55,14 +54,6 @@ void calcAtmosphericVars(vec3 inPositionEye, vec3 light_dir, float ambFactor, ou
vec3 linear_to_srgb(vec3 c);
vec3 srgb_to_linear(vec3 c);
-#ifdef HAS_REFLECTION_PROBES
-// reflection probe interface
-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
-
// See:
// class1\deferred\fullbrightShinyF.glsl
// class1\lighting\lightFullbrightShinyF.glsl
@@ -79,29 +70,21 @@ void main()
// SL-9632 HUDs are affected by Atmosphere
if (no_atmo == 0)
{
- vec3 sunlit;
- vec3 amblit;
- vec3 additive;
- vec3 atten;
- vec3 pos = vary_position;
- calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten, false);
-
- float env_intensity = vertex_color.a;
-#ifndef HAS_REFLECTION_PROBES
- vec3 envColor = textureCube(environmentMap, vary_texcoord1.xyz).rgb;
- color.rgb = mix(color.rgb, envColor.rgb, env_intensity);
-#else
- vec3 ambenv;
- vec3 glossenv;
- vec3 legacyenv;
- vec3 norm = normalize(vary_texcoord1.xyz);
- vec4 spec = vec4(0,0,0,0);
- sampleReflectionProbes(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, env_intensity);
- legacyenv *= 1.5; // fudge brighter
- applyLegacyEnv(color.rgb, legacyenv, spec, pos, norm, env_intensity);
-#endif
- color.rgb = fullbrightAtmosTransportFrag(color.rgb, additive, atten);
- color.rgb = fullbrightScaleSoftClip(color.rgb);
+ vec3 sunlit;
+ vec3 amblit;
+ vec3 additive;
+ vec3 atten;
+ vec3 pos = vary_position.xyz/vary_position.w;
+
+ calcAtmosphericVars(pos.xyz, vec3(0), 1.0, sunlit, amblit, additive, atten, false);
+
+ vec3 envColor = textureCube(environmentMap, vary_texcoord1.xyz).rgb;
+ float env_intensity = vertex_color.a;
+
+ //color.rgb = srgb_to_linear(color.rgb);
+ color.rgb = mix(color.rgb, envColor.rgb, env_intensity);
+ color.rgb = fullbrightAtmosTransportFrag(color.rgb, additive, atten);
+ color.rgb = fullbrightScaleSoftClip(color.rgb);
}
/*
@@ -115,6 +98,7 @@ void main()
*/
color.a = 1.0;
+
//color.rgb = linear_to_srgb(color.rgb);
frag_color = color;
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);