summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders/class3/deferred
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/app_settings/shaders/class3/deferred')
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/materialF.glsl37
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl26
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl56
3 files changed, 79 insertions, 40 deletions
diff --git a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
index 49529860be..6e41df34a4 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -210,9 +210,9 @@ uniform float minimum_alpha;
#endif
#ifdef HAS_NORMAL_MAP
-VARYING vec3 vary_mat0;
-VARYING vec3 vary_mat1;
-VARYING vec3 vary_mat2;
+in vec3 vary_normal;
+in vec3 vary_tangent;
+flat in float vary_sign;
VARYING vec2 vary_texcoord1;
#else
VARYING vec3 vary_normal;
@@ -227,14 +227,17 @@ vec2 encode_normal(vec3 n);
vec3 getNormal(inout float glossiness)
{
#ifdef HAS_NORMAL_MAP
- vec4 norm = texture2D(bumpMap, vary_texcoord1.xy);
- glossiness *= norm.a;
-
- norm.xyz = norm.xyz * 2 - 1;
+ vec4 vNt = texture2D(bumpMap, vary_texcoord1.xy);
+ glossiness *= vNt.a;
+ vNt.xyz = vNt.xyz * 2 - 1;
+ float sign = vary_sign;
+ vec3 vN = vary_normal;
+ vec3 vT = vary_tangent.xyz;
+
+ vec3 vB = sign * cross(vN, vT);
+ vec3 tnorm = normalize( vNt.x * vT + vNt.y * vB + vNt.z * vN );
- return normalize(vec3(dot(norm.xyz,vary_mat0),
- dot(norm.xyz,vary_mat1),
- dot(norm.xyz,vary_mat2)));
+ return tnorm;
#else
return normalize(vary_normal);
#endif
@@ -316,6 +319,7 @@ void main()
//forward rendering, output lit linear color
diffcol.rgb = srgb_to_linear(diffcol.rgb);
spec.rgb = srgb_to_linear(spec.rgb);
+ spec.a = glossiness; // pack glossiness into spec alpha for lighting functions
vec3 pos = vary_position;
@@ -334,16 +338,19 @@ void main()
vec3 atten;
calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
+ vec3 sunlit_linear = srgb_to_linear(sunlit);
+ vec3 amblit_linear = amblit;
+
vec3 ambenv;
vec3 glossenv;
vec3 legacyenv;
sampleReflectionProbesLegacy(ambenv, glossenv, legacyenv, pos.xy*0.5+0.5, pos.xyz, norm.xyz, glossiness, env);
// use sky settings ambient or irradiance map sample, whichever is brighter
- color = max(amblit, ambenv);
+ color = max(amblit_linear, ambenv);
float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
- vec3 sun_contrib = min(da, shadow) * sunlit;
+ vec3 sun_contrib = min(da, shadow) * sunlit_linear;
color.rgb += sun_contrib;
color *= diffcol.rgb;
@@ -354,7 +361,7 @@ void main()
if (glossiness > 0.0) // specular reflection
{
float sa = dot(normalize(refnormpersp), light_dir.xyz);
- vec3 dumbshiny = sunlit * shadow * (texture2D(lightFunc, vec2(sa, glossiness)).r);
+ vec3 dumbshiny = sunlit_linear * shadow * (texture2D(lightFunc, vec2(sa, glossiness)).r);
// add the two types of shiny together
vec3 spec_contrib = dumbshiny * spec.rgb;
@@ -379,8 +386,10 @@ void main()
glare += cur_glare;
}
- color.rgb = mix(atmosFragLightingLinear(color.rgb, additive, atten), fullbrightAtmosTransportFragLinear(color, additive, atten), emissive);
+ color.rgb = linear_to_srgb(color.rgb);
+ color.rgb = atmosFragLightingLinear(color.rgb, additive, atten);
color.rgb = scaleSoftClipFragLinear(color.rgb);
+ color.rgb = srgb_to_linear(color.rgb);
vec3 npos = normalize(-pos.xyz);
vec3 light = vec3(0, 0, 0);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
index 23c6f4d5ae..a6a2543915 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/reflectionProbeF.glsl
@@ -458,28 +458,24 @@ float sphereWeight(vec3 pos, vec3 dir, vec3 origin, float r, float min_da, int i
// dir - pixel normal
// w - weight of sample (distance and angular attenuation)
// dw - weight of sample (distance only)
-// vi - return value of intersection point with influence volume
-// wi - return value of approximate world space position of sampled pixel
-// lod - which mip to bias towards (lower is higher res, sharper reflections)
+// lod - which mip to sample (lower is higher res, sharper reflections)
// c - center of probe
// r2 - radius of probe squared
// i - index of probe
-vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, out vec3 vi, out vec3 wi, float lod, vec3 c, int i)
+vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, float lod, vec3 c, int i)
{
- //lod = max(lod, 1);
// parallax adjustment
-
vec3 v;
if (refIndex[i].w < 0)
- {
+ { // box probe
float d = 0;
v = boxIntersect(pos, dir, i, d);
w = max(d, 0.001);
}
else
- {
+ { // sphere probe
float r = refSphere[i].w;
float rr = r * r;
@@ -491,16 +487,12 @@ vec3 tapRefMap(vec3 pos, vec3 dir, out float w, out float dw, out vec3 vi, out v
w = sphereWeight(pos, dir, refSphere[i].xyz, r, 0.25, i, dw);
}
- vi = v;
-
v -= c;
vec3 d = normalize(v);
v = env_mat * v;
- vec4 ret = textureLod(reflectionProbes, vec4(v.xyz, refIndex[i].x), lod);
-
- wi = d * ret.a * 256.0+c;
+ vec4 ret = textureLod(reflectionProbes, vec4(v.xyz, refIndex[i].x), lod) * refParams[i].y;
return ret.rgb;
}
@@ -568,12 +560,11 @@ vec3 sampleProbes(vec3 pos, vec3 dir, float lod)
float w = 0;
float dw = 0;
- vec3 vi, wi;
vec3 refcol;
{
- refcol = tapRefMap(pos, dir, w, dw, vi, wi, lod, refSphere[i].xyz, i);
+ refcol = tapRefMap(pos, dir, w, dw, lod, refSphere[i].xyz, i);
col[p] += refcol.rgb*w;
wsum[p] += w;
@@ -665,7 +656,7 @@ void sampleReflectionProbes(inout vec3 ambenv, inout vec3 glossenv,
vec2 tc, vec3 pos, vec3 norm, float glossiness)
{
// TODO - don't hard code lods
- float reflection_lods = max_probe_lod;
+ float reflection_lods = max_probe_lod-1;
preProbeSample(pos);
vec3 refnormpersp = reflect(pos.xyz, norm.xyz);
@@ -690,6 +681,9 @@ void sampleReflectionProbesWater(inout vec3 ambenv, inout vec3 glossenv,
vec2 tc, vec3 pos, vec3 norm, float glossiness)
{
sampleReflectionProbes(ambenv, glossenv, tc, pos, norm, glossiness);
+
+ // fudge factor to get PBR water at a similar luminance ot legacy water
+ glossenv *= 0.25;
}
void debugTapRefMap(vec3 pos, vec3 dir, float depth, int i, inout vec4 col)
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index 8d48e6f596..dfd1d47b3e 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -85,6 +85,8 @@ float getDepth(vec2 pos_screen);
vec3 linear_to_srgb(vec3 c);
vec3 srgb_to_linear(vec3 c);
+uniform vec4 waterPlane;
+
#ifdef WATER_FOG
vec4 applyWaterFogViewLinear(vec3 pos, vec4 color);
#endif
@@ -153,6 +155,24 @@ void main()
calcAtmosphericVarsLinear(pos.xyz, norm.xyz, light_dir, sunlit, amblit, additive, atten);
+ vec3 sunlit_linear = srgb_to_linear(sunlit);
+ vec3 amblit_linear = amblit;
+
+ bool do_atmospherics = false;
+
+#ifndef WATER_FOG
+ // when above water, mask off atmospherics below water
+ if (dot(pos.xyz, waterPlane.xyz) + waterPlane.w > 0.0)
+ {
+ do_atmospherics = true;
+ }
+#else
+ do_atmospherics = true;
+#endif
+
+ vec3 irradiance = vec3(0);
+ vec3 radiance = vec3(0);
+
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
vec3 orm = texture2D(specularRect, tc).rgb;
@@ -161,23 +181,32 @@ void main()
float ao = orm.r * ambocc;
vec3 colorEmissive = texture2D(emissiveRect, tc).rgb;
-
// PBR IBL
float gloss = 1.0 - perceptualRoughness;
- vec3 irradiance = vec3(0);
- vec3 radiance = vec3(0);
+
sampleReflectionProbes(irradiance, radiance, tc, pos.xyz, norm.xyz, gloss);
// Take maximium of legacy ambient vs irradiance sample as irradiance
// NOTE: ao is applied in pbrIbl (see pbrBaseLight), do not apply here
- irradiance = max(amblit,irradiance);
+ irradiance = max(amblit_linear,irradiance);
vec3 diffuseColor;
vec3 specularColor;
calcDiffuseSpecular(baseColor.rgb, metallic, diffuseColor, specularColor);
vec3 v = -normalize(pos.xyz);
- color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
+ color = vec3(1,0,1);
+ color = pbrBaseLight(diffuseColor, specularColor, metallic, v, norm.xyz, perceptualRoughness, light_dir, sunlit_linear, scol, radiance, irradiance, colorEmissive, ao, additive, atten);
+
+
+ if (do_atmospherics)
+ {
+ color = linear_to_srgb(color);
+ color = atmosFragLightingLinear(color, additive, atten);
+ color = srgb_to_linear(color);
+ }
+
+
}
else if (!GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_ATMOS))
{
@@ -199,12 +228,12 @@ void main()
sampleReflectionProbesLegacy(irradiance, glossenv, legacyenv, tc, pos.xyz, norm.xyz, spec.a, envIntensity);
// use sky settings ambient or irradiance map sample, whichever is brighter
- irradiance = max(amblit, irradiance);
+ irradiance = max(amblit_linear, irradiance);
// apply lambertian IBL only (see pbrIbl)
color.rgb = irradiance * ambocc;
- vec3 sun_contrib = min(da, scol) * sunlit;
+ vec3 sun_contrib = min(da, scol) * sunlit_linear;
color.rgb += sun_contrib;
color.rgb *= baseColor.rgb;
@@ -230,9 +259,16 @@ void main()
applyLegacyEnv(color, legacyenv, spec, pos.xyz, norm.xyz, envIntensity);
}
- color = mix(atmosFragLightingLinear(color, additive, atten), fullbrightAtmosTransportFragLinear(color, additive, atten), baseColor.a);
- color = scaleSoftClipFragLinear(color);
- }
+
+ if (do_atmospherics)
+ {
+ color = linear_to_srgb(color);
+ color = atmosFragLightingLinear(color, additive, atten);
+ color = srgb_to_linear(color);
+ }
+ }
+
+
#ifdef WATER_FOG
vec4 fogged = applyWaterFogViewLinear(pos.xyz, vec4(color, bloom));