summaryrefslogtreecommitdiff
path: root/indra/newview/app_settings/shaders
diff options
context:
space:
mode:
authorDave Parks <davep@lindenlab.com>2022-09-20 19:09:26 -0500
committerDave Parks <davep@lindenlab.com>2022-09-20 19:09:26 -0500
commitc466e44334fd60c8270b68c70b8ae999b8dbd395 (patch)
tree6e5a5e79f9f8af154eee42fb85ed3e1f3c9bb048 /indra/newview/app_settings/shaders
parenta66a65e047fb662e35eaaa68de6da9e2786db8ed (diff)
SL-18190 Reduce banding (stay in linear space as much as possible, increase precision of reflection probes). Faster radiance and irradiance map generation.
Diffstat (limited to 'indra/newview/app_settings/shaders')
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl13
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/materialF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl6
-rw-r--r--indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl20
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl2
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/materialF.glsl3
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl8
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl7
-rw-r--r--indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl7
13 files changed, 40 insertions, 47 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
index fc1cee1f59..69a0a41034 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/alphaF.glsl
@@ -292,19 +292,6 @@ void main()
#if !defined(LOCAL_LIGHT_KILL)
color.rgb += light.rgb;
#endif // !defined(LOCAL_LIGHT_KILL)
- // back to sRGB as we're going directly to the final RT post-deferred gamma correction
- color.rgb = linear_to_srgb(color.rgb);
-
-//color.rgb = amblit;
-//color.rgb = vec3(ambient);
-//color.rgb = sunlit;
-//color.rgb = vec3(final_da);
-//color.rgb = post_ambient;
-//color.rgb = post_sunlight;
-//color.rgb = sun_contrib;
-//color.rgb = diffuse_srgb.rgb;
-//color.rgb = post_diffuse;
-//color.rgb = post_atmo;
#ifdef WATER_FOG
color = applyWaterFogView(pos.xyz, color);
diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
index 57420158ca..33b97aefcb 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl
@@ -82,7 +82,7 @@ void main()
color.a = final_alpha;
#endif
- frag_color.rgb = color.rgb;
+ frag_color.rgb = srgb_to_linear(color.rgb);
frag_color.a = color.a;
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
index e87d90aa9e..44bf61be84 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/materialF.glsl
@@ -402,9 +402,6 @@ void main()
glare = min(glare, 1.0);
float al = max(diffcol.a, glare)*vertex_color.a;
- //convert to srgb as this color is being written post gamma correction
- color = linear_to_srgb(color);
-
#ifdef WATER_FOG
vec4 temp = applyWaterFogView(pos, vec4(color, al));
color = temp.rgb;
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl
index 1caf2b2b1a..04be496292 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbralphaF.glsl
@@ -250,5 +250,5 @@ void main()
color += 2.0*additive;
color = scaleSoftClipFrag(color);
- frag_color = vec4(color,albedo.a * vertex_color.a);
+ frag_color = vec4(srgb_to_linear(color.rgb),albedo.a * vertex_color.a);
}
diff --git a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
index ea28cca0cb..7376e9eb47 100644
--- a/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
+++ b/indra/newview/app_settings/shaders/class1/deferred/pbropaqueF.glsl
@@ -98,8 +98,8 @@ void main()
//emissive = vNt * 0.5 + 0.5;
//emissive = tnorm*0.5+0.5;
// See: C++: addDeferredAttachments(), GLSL: softenLightF
- frag_data[0] = vec4(linear_to_srgb(col), 0.0); // Diffuse
- frag_data[1] = vec4(linear_to_srgb(emissive), vertex_color.a); // PBR sRGB Emissive
+ frag_data[0] = vec4(col, 0.0); // Diffuse
+ frag_data[1] = vec4(spec.rgb,vertex_color.a); // PBR linear packed Occlusion, Roughness, Metal.
frag_data[2] = vec4(encode_normal(tnorm), vertex_color.a, GBUFFER_FLAG_HAS_PBR); // normal, environment intensity, flags
- frag_data[3] = vec4(spec.rgb,0); // PBR linear packed Occlusion, Roughness, Metal.
+ frag_data[3] = vec4(emissive,0); // PBR sRGB Emissive
}
diff --git a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl
index 7c175eab5f..bb4a79247d 100644
--- a/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl
+++ b/indra/newview/app_settings/shaders/class1/interface/radianceGenF.glsl
@@ -37,6 +37,10 @@ uniform int sourceIdx;
VARYING vec3 vary_dir;
+//uniform float roughness;
+
+uniform float mipLevel;
+
// =============================================================================================================
// Parts of this file are (c) 2018 Sascha Willems
// SNIPPED FROM https://github.com/SaschaWillems/Vulkan-glTF-PBR/blob/master/data/shaders/prefilterenvmap.frag
@@ -65,11 +69,6 @@ SOFTWARE.
*/
// =============================================================================================================
-
-//uniform float roughness;
-
-uniform float mipLevel;
-
const float PI = 3.1415926536;
// Based omn http://byteblacksmith.com/improvements-to-the-canonical-one-liner-glsl-rand-for-opengl-es-2-0/
@@ -130,11 +129,13 @@ vec3 prefilterEnvMap(vec3 R)
vec3 color = vec3(0.0);
float totalWeight = 0.0;
float envMapDim = 256.0;
- int numSamples = 8;
+ int numSamples = 4;
float numMips = 7.0;
- float roughness = (mipLevel+1)/numMips;
+ float roughness = mipLevel/numMips;
+
+ numSamples = max(int(numSamples*roughness), 1);
for(uint i = 0u; i < numSamples; i++) {
vec2 Xi = hammersley2d(i, numSamples);
@@ -154,8 +155,8 @@ vec3 prefilterEnvMap(vec3 R)
// Solid angle of 1 pixel across all cube faces
float omegaP = 4.0 * PI / (6.0 * envMapDim * envMapDim);
// Biased (+1.0) mip level for better result
- //float mip = roughness == 0.0 ? 0.0 : max(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f);
- float mip = clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f);
+ float mip = roughness == 0.0 ? 0.0 : clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f);
+ //float mip = clamp(0.5 * log2(omegaS / omegaP) + 1.0, 0.0f, 7.f);
color += textureLod(reflectionProbes, vec4(L,sourceIdx), mip).rgb * dotNL;
totalWeight += dotNL;
@@ -170,4 +171,3 @@ void main()
frag_color = vec4(prefilterEnvMap(N), 1.0);
}
// =============================================================================================================
-
diff --git a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
index a04f611440..67f1fc4c18 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/fullbrightShinyF.glsl
@@ -115,8 +115,8 @@ void main()
*/
color.a = 1.0;
- //color.rgb = linear_to_srgb(color.rgb);
+ 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 7f8536cdab..fcda50c4de 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/materialF.glsl
@@ -433,9 +433,6 @@ void main()
glare = min(glare, 1.0);
float al = max(diffcol.a, glare)*vertex_color.a;
- //convert to srgb as this color is being written post gamma correction
- color = linear_to_srgb(color);
-
#ifdef WATER_FOG
vec4 temp = applyWaterFogView(pos, vec4(color, al));
color = temp.rgb;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
index 2ee439f61a..6dd446d9f7 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiPointLightF.glsl
@@ -95,8 +95,8 @@ void main()
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = spec.rgb; // PBR sRGB Emissive. See: pbropaqueF.glsl
- vec3 orm = texture2DRect(emissiveRect, tc).rgb; //orm is packed into "emissiveRect" to keep the data in linear color space
+ vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb;
+ vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
vec3 f0 = vec3(0.04);
@@ -134,6 +134,9 @@ void main()
float noise = texture2D(noiseMap, tc/128.0).b;
+ diffuse = srgb_to_linear(diffuse);
+ spec.rgb = srgb_to_linear(spec.rgb);
+
// As of OSX 10.6.7 ATI Apple's crash when using a variable size loop
for (int i = 0; i < LIGHT_COUNT; ++i)
{
diff --git a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
index 6424e18079..cb8877ebe5 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/multiSpotLightF.glsl
@@ -147,8 +147,8 @@ void main()
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = spec.rgb; // PBR sRGB Emissive. See: pbropaqueF.glsl
- vec3 orm = texture2DRect(emissiveRect, tc).rgb; //orm is packed into "emissiveRect" to keep the data in linear color space
+ vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb;
+ vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
vec3 f0 = vec3(0.04);
@@ -182,6 +182,10 @@ void main()
}
else
{
+
+ diffuse = srgb_to_linear(diffuse);
+ spec.rgb = srgb_to_linear(spec.rgb);
+
float noise = texture2D(noiseMap, tc/128.0).b;
if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 &&
diff --git a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
index 27fca64ab3..cdffcf103d 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/pointLightF.glsl
@@ -99,8 +99,8 @@ void main()
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = spec.rgb; // PBR sRGB Emissive. See: pbropaqueF.glsl
- vec3 orm = texture2DRect(emissiveRect, tc).rgb; //orm is packed into "emissiveRect" to keep the data in linear color space
+ vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb;
+ vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
vec3 f0 = vec3(0.04);
@@ -121,6 +121,9 @@ void main()
discard;
}
+ diffuse = srgb_to_linear(diffuse);
+ spec.rgb = srgb_to_linear(spec.rgb);
+
float noise = texture2D(noiseMap, tc/128.0).b;
float lit = nl * dist_atten * noise;
diff --git a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
index a8a3b5d33f..5c049b6bd6 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/softenLightF.glsl
@@ -145,12 +145,12 @@ void main()
if (hasPBR)
{
norm.xyz = getNorm(tc);
- vec3 orm = texture2DRect(emissiveRect, tc).rgb; //orm is packed into "emissiveRect" to keep the data in linear color space
+ vec3 orm = texture2DRect(specularRect, tc).rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
float ao = orm.r * ambocc;
- vec3 colorEmissive = texture2DRect(specularRect, tc).rgb; //specularRect is sRGB sampler, result is in linear space
+ vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb;
// PBR IBL
float gloss = 1.0 - perceptualRoughness;
@@ -165,7 +165,6 @@ void main()
//baseColor.rgb = vec3(0,0,0);
//colorEmissive = srgb_to_linear(norm.xyz*0.5+0.5);
-
vec3 diffuseColor = baseColor.rgb*(vec3(1.0)-f0);
diffuseColor *= 1.0 - metallic;
@@ -195,7 +194,7 @@ void main()
float da = clamp(dot(norm.xyz, light_dir.xyz), 0.0, 1.0);
da = pow(da, light_gamma);
- diffuse.rgb = linear_to_srgb(diffuse.rgb); // SL-14035
+ //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);
diff --git a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
index c8d45eb429..3274153a46 100644
--- a/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
+++ b/indra/newview/app_settings/shaders/class3/deferred/spotLightF.glsl
@@ -154,8 +154,8 @@ void main()
vec3 amb_rgb = vec3(0);
if (GET_GBUFFER_FLAG(GBUFFER_FLAG_HAS_PBR))
{
- vec3 colorEmissive = spec.rgb; // PBR sRGB Emissive. See: pbropaqueF.glsl
- vec3 orm = texture2DRect(emissiveRect, tc).rgb; //orm is packed into "emissiveRect" to keep the data in linear color space
+ vec3 colorEmissive = texture2DRect(emissiveRect, tc).rgb;
+ vec3 orm = spec.rgb;
float perceptualRoughness = orm.g;
float metallic = orm.b;
vec3 f0 = vec3(0.04);
@@ -189,6 +189,9 @@ void main()
}
else
{
+ diffuse = srgb_to_linear(diffuse);
+ spec.rgb = srgb_to_linear(spec.rgb);
+
float noise = texture2D(noiseMap, tc/128.0).b;
if (proj_tc.z > 0.0 &&
proj_tc.x < 1.0 &&