diff options
author | Dave Parks <davep@lindenlab.com> | 2022-09-20 19:09:26 -0500 |
---|---|---|
committer | Dave Parks <davep@lindenlab.com> | 2022-09-20 19:09:26 -0500 |
commit | c466e44334fd60c8270b68c70b8ae999b8dbd395 (patch) | |
tree | 6e5a5e79f9f8af154eee42fb85ed3e1f3c9bb048 /indra/newview/app_settings/shaders/class1 | |
parent | a66a65e047fb662e35eaaa68de6da9e2786db8ed (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/class1')
6 files changed, 15 insertions, 31 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); } // ============================================================================================================= - |