summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class3')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl26
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/materialF.glsl49
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl31
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl25
4 files changed, 46 insertions, 85 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
index 67f1fc4c18..c0a1491446 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
@@ -55,13 +55,11 @@ 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,
+void sampleReflectionProbesLegacy(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
@@ -87,35 +85,21 @@ void main()
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
+ sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, env_intensity);
applyLegacyEnv(color.rgb, legacyenv, spec, pos, norm, env_intensity);
-#endif
+
color.rgb = fullbrightAtmosTransportFrag(color.rgb, additive, atten);
color.rgb = fullbrightScaleSoftClip(color.rgb);
}
-/*
- // NOTE: HUD objects will be full bright. Uncomment if you want "some" environment lighting effecting these HUD objects.
- else
- {
- vec3 envColor = textureCube(environmentMap, vary_texcoord1.xyz).rgb;
- float env_intensity = vertex_color.a;
- color.rgb = mix(color.rgb, envColor.rgb, env_intensity);
- }
-*/
-
color.a = 1.0;
-
+
color.rgb = srgb_to_linear(color.rgb);
frag_color = color;
}
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
index 07f50af7e3..27eb0b9888 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -64,12 +64,10 @@ 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,
+void sampleReflectionProbesLegacy(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;
@@ -326,27 +324,12 @@ void main()
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);
+ sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity);
amblit = max(ambenv, amblit);
color.rgb = amblit;
-#else
-
- color = amblit;
-
- //darken ambient for normals perpendicular to light vector so surfaces in shadow
- // and facing away from light still have some definition to them.
- // do NOT gamma correct this dot product so ambient lighting stays soft
- float ambient = min(abs(dot(norm.xyz, sun_dir.xyz)), 1.0);
- ambient *= 0.5;
- ambient *= ambient;
- ambient = (1.0 - ambient);
-
- color *= ambient;
-#endif
color += sun_contrib;
@@ -368,37 +351,14 @@ void main()
color += spec_contrib;
-#ifdef HAS_REFLECTION_PROBES
applyGlossEnv(color, glossenv, spec, pos.xyz, norm.xyz);
-#endif
}
-#ifdef HAS_REFLECTION_PROBES
+ color = atmosFragLighting(color, additive, atten);
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
- vec3 env_vec = env_mat * refnormpersp;
-
- vec3 reflected_color = textureCube(environmentMap, env_vec).rgb;
-
- color = mix(color, reflected_color, envIntensity);
-
- float cur_glare = max(reflected_color.r, reflected_color.g);
- cur_glare = max(cur_glare, reflected_color.b);
- cur_glare *= envIntensity*4.0;
- glare += cur_glare;
- }
-#endif
-
- color = atmosFragLighting(color, additive, atten);
color = scaleSoftClipFrag(color);
//convert to linear before adding local lights
@@ -410,6 +370,8 @@ void main()
final_specular.rgb = srgb_to_linear(final_specular.rgb); // SL-14035
+ color = mix(color.rgb, srgb_to_linear(diffcol.rgb), diffuse.a);
+
#define LIGHT_LOOP(i) light.rgb += calcPointLightOrSpotLight(light_diffuse[i].rgb, npos, diffuse.rgb, final_specular, pos.xyz, norm.xyz, light_position[i], light_direction[i].xyz, light_attenuation[i].x, light_attenuation[i].y, light_attenuation[i].z, glare, light_attenuation[i].w );
LIGHT_LOOP(1)
@@ -431,7 +393,6 @@ void main()
al = temp.a;
#endif
- color = mix(color.rgb, srgb_to_linear(diffcol.rgb), diffuse.a);
frag_color = vec4(color, al);
#else // mode is not DIFFUSE_ALPHA_MODE_BLEND, encode to gbuffer
diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
index 463709de9e..beb0f6f2a6 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
@@ -23,8 +23,6 @@
* $/LicenseInfo$
*/
-#extension GL_ARB_shader_texture_lod : enable
-
#define FLT_MAX 3.402823466e+38
#define REFMAP_COUNT 256
@@ -33,6 +31,8 @@
uniform samplerCubeArray reflectionProbes;
uniform samplerCubeArray irradianceProbes;
+vec3 linear_to_srgb(vec3 col);
+
layout (std140) uniform ReflectionProbes
{
// list of OBBs for user override probes
@@ -520,7 +520,22 @@ vec3 brighten(vec3 c)
}
-void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv,
+void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
+ vec3 pos, vec3 norm, float glossiness)
+{
+ // TODO - don't hard code lods
+ float reflection_lods = 7;
+ preProbeSample(pos);
+
+ vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
+
+ ambenv = sampleProbeAmbient(pos, norm);
+
+ float lod = (1.0-glossiness)*reflection_lods;
+ glossenv = sampleProbes(pos, normalize(refnormpersp), lod, 1.f);
+}
+
+void sampleReflectionProbesLegacy(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyenv,
vec3 pos, vec3 norm, float glossiness, float envIntensity)
{
// TODO - don't hard code lods
@@ -531,16 +546,22 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 l
ambenv = sampleProbeAmbient(pos, norm);
- //if (glossiness > 0.0)
+ if (glossiness > 0.0)
{
float lod = (1.0-glossiness)*reflection_lods;
glossenv = sampleProbes(pos, normalize(refnormpersp), lod, 1.f);
+ glossenv = linear_to_srgb(glossenv);
}
if (envIntensity > 0.0)
{
legacyenv = sampleProbes(pos, normalize(refnormpersp), 0.0, 1.f);
+ legacyenv = linear_to_srgb(legacyenv);
}
+
+ // legacy expects values in sRGB space for now
+ ambenv = linear_to_srgb(ambenv);
+
}
void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 norm)
@@ -555,7 +576,7 @@ void applyGlossEnv(inout vec3 color, vec3 glossenv, vec4 spec, vec3 pos, vec3 no
void applyLegacyEnv(inout vec3 color, vec3 legacyenv, vec4 spec, vec3 pos, vec3 norm, float envIntensity)
{
- vec3 reflected_color = legacyenv; //*0.5; //fudge darker
+ vec3 reflected_color = legacyenv;
vec3 lookAt = normalize(pos);
float fresnel = 1.0+dot(lookAt, norm.xyz);
fresnel *= fresnel;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 5c049b6bd6..cfdbbdfe2c 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -76,7 +76,9 @@ vec3 fullbrightAtmosTransportFrag(vec3 light, vec3 additive, vec3 atten);
vec3 fullbrightScaleSoftClip(vec3 light);
// reflection probe interface
-void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv, inout vec3 legacyEnv,
+void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
+ vec3 pos, vec3 norm, float glossiness);
+void sampleReflectionProbesLegacy(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);
@@ -156,7 +158,7 @@ void main()
float gloss = 1.0 - perceptualRoughness;
vec3 irradiance = vec3(0);
vec3 radiance = vec3(0);
- sampleReflectionProbes(irradiance, radiance, legacyenv, pos.xyz, norm.xyz, gloss, 0.0);
+ sampleReflectionProbes(irradiance, radiance, pos.xyz, norm.xyz, gloss);
irradiance = max(srgb_to_linear(amblit),irradiance) * ambocc*4.0;
vec3 f0 = vec3(0.04);
@@ -196,10 +198,8 @@ void main()
//diffuse.rgb = linear_to_srgb(diffuse.rgb); // SL-14035
- sampleReflectionProbes(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity);
- ambenv.rgb = linear_to_srgb(ambenv.rgb);
- glossenv.rgb = linear_to_srgb(glossenv.rgb);
- legacyenv.rgb = linear_to_srgb(legacyenv.rgb);
+ sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xyz, norm.xyz, spec.a, envIntensity);
+ vec3 debug = legacyenv;
amblit = max(ambenv, amblit);
color.rgb = amblit*ambocc;
@@ -227,16 +227,13 @@ void main()
color.rgb = mix(color.rgb, diffuse.rgb, diffuse.a);
- if (envIntensity > 0.0)
- { // add environmentmap
- //fudge darker
- legacyenv *= 0.5*diffuse.a+0.5;
- applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
- }
-
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS))
{
color = mix(atmosFragLighting(color, additive, atten), fullbrightAtmosTransportFrag(color, additive, atten), diffuse.a);
+ if (envIntensity > 0.0)
+ { // add environmentmap
+ applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
+ }
color = mix(scaleSoftClipFrag(color), fullbrightScaleSoftClip(color), diffuse.a);
}
@@ -248,8 +245,6 @@ void main()
// convert to linear as fullscreen lights need to sum in linear colorspace
// and will be gamma (re)corrected downstream...
- //color = ambenv;
- //color.b = diffuse.a;
frag_color.rgb = srgb_to_linear(color.rgb);
}