diff options
author | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2023-03-13 08:06:17 -0700 |
---|---|---|
committer | Jonathan "Geenz" Goodman <geenz@geenzo.com> | 2023-03-13 08:06:17 -0700 |
commit | 75dea34e3f80b054c56c38c880166d5e610eef88 (patch) | |
tree | 8a8a54cb3e446213b33dcdd64c0c89d3c47369b4 /indra/newview/app_settings/shaders/class1/deferred | |
parent | f3ce17701e8dbbbc7a0e8e73c740b161bb2f36c0 (diff) | |
parent | 0e178e12562b95915a9a775cd40d3bb44729332c (diff) |
Merge branch 'DRTVWR-559' of https://github.com/secondlife/viewer into DRTVWR-559
Diffstat (limited to 'indra/newview/app_settings/shaders/class1/deferred')
6 files changed, 34 insertions, 65 deletions
diff --git a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl index cf9ce646d1..fe796a054d 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/cloudsF.glsl @@ -52,9 +52,6 @@ VARYING vec2 vary_texcoord2; VARYING vec2 vary_texcoord3; VARYING float altitude_blend_factor; -/// Soft clips the light with a gamma correction -vec3 scaleSoftClip(vec3 light); - vec4 cloudNoise(vec2 uv) { vec4 a = texture2D(cloud_noise_texture, uv); @@ -119,7 +116,6 @@ void main() color = (cloudColorSun*(1.-alpha2) + cloudColorAmbient); color.rgb= max(vec3(0), color.rgb); color.rgb *= 2.0; - color.rgb = scaleSoftClip(color.rgb); /// Gamma correct for WL (soft clip effect). frag_data[0] = vec4(color.rgb, alpha1); diff --git a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl index 6ab966ae01..4bf16b50bf 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/deferredUtil.glsl @@ -74,7 +74,6 @@ const float ONE_OVER_PI = 0.3183098861; vec3 srgb_to_linear(vec3 cs); vec3 atmosFragLightingLinear(vec3 light, vec3 additive, vec3 atten); -vec3 scaleSoftClipFragLinear(vec3 light); float calcLegacyDistanceAttenuation(float distance, float falloff) { @@ -396,7 +395,7 @@ vec3 pbrIbl(vec3 diffuseColor, specContrib = specular * ao; - return (diffuse + specular*0.5) * ao; //reduce by half to place in appropriate color space for atmospherics + return (diffuse + specular) * ao; } vec3 pbrIbl(vec3 diffuseColor, @@ -562,16 +561,13 @@ vec3 pbrBaseLight(vec3 diffuseColor, vec3 specularColor, float metallic, vec3 v, float NdotV = clamp(abs(dot(norm, v)), 0.001, 1.0); vec3 ibl_spec; - color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, 0.2, ibl_spec); + color += pbrIbl(diffuseColor, specularColor, radiance, irradiance, ao, NdotV, perceptualRoughness, ibl_spec); color += pbrPunctual(diffuseColor, specularColor, perceptualRoughness, metallic, norm, v, normalize(light_dir), specContrib) * sunlit * 2.75 * scol; specContrib *= sunlit * 2.75 * scol; specContrib += ibl_spec; - color += colorEmissive*0.5; - - color = atmosFragLightingLinear(color, additive, atten); - color = scaleSoftClipFragLinear(color); + color += colorEmissive; return color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl index f0522850de..fb97cd95b4 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/emissiveF.glsl @@ -27,14 +27,9 @@ /*[EXTRA_CODE_HERE]*/ -#ifdef DEFINE_GL_FRAGCOLOR out vec4 frag_color; -#else -#define frag_color gl_FragColor -#endif vec3 fullbrightAtmosTransport(vec3 light); -vec3 fullbrightScaleSoftClip(vec3 light); VARYING vec4 vertex_color; VARYING vec2 vary_texcoord0; @@ -46,8 +41,6 @@ void main() vec4 color = diffuseLookup(vary_texcoord0.xy)*vertex_color; color.rgb = fullbrightAtmosTransport(color.rgb); - color.rgb = fullbrightScaleSoftClip(color.rgb); - frag_color = color; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl index afe504743d..3a15fd1111 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/fullbrightF.glsl @@ -88,8 +88,10 @@ void main() #endif #ifndef IS_HUD + color.rgb = fullbrightAtmosTransport(color.rgb); color.rgb = srgb_to_linear(color.rgb); #endif + frag_color.rgb = color.rgb; frag_color.a = color.a; } diff --git a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl index a1cab87092..d41e0b202b 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/materialV.glsl @@ -59,9 +59,9 @@ ATTRIBUTE vec2 texcoord0; ATTRIBUTE vec4 tangent; ATTRIBUTE vec2 texcoord1; -VARYING vec3 vary_mat0; -VARYING vec3 vary_mat1; -VARYING vec3 vary_mat2; +out vec3 vary_tangent; +flat out float vary_sign; +out vec3 vary_normal; VARYING vec2 vary_texcoord1; #else @@ -111,24 +111,21 @@ void main() vec3 n = normalize((mat*vec4(normal.xyz+position.xyz,1.0)).xyz-pos.xyz); #ifdef HAS_NORMAL_MAP vec3 t = normalize((mat*vec4(tangent.xyz+position.xyz,1.0)).xyz-pos.xyz); - vec3 b = cross(n, t)*tangent.w; - - vary_mat0 = vec3(t.x, b.x, n.x); - vary_mat1 = vec3(t.y, b.y, n.y); - vary_mat2 = vec3(t.z, b.z, n.z); + + vary_tangent = t; + vary_sign = tangent.w; + vary_normal = n; #else //HAS_NORMAL_MAP -vary_normal = n; + vary_normal = n; #endif //HAS_NORMAL_MAP #else //HAS_SKIN vec3 n = normalize(normal_matrix * normal); #ifdef HAS_NORMAL_MAP vec3 t = normalize(normal_matrix * tangent.xyz); - vec3 b = cross(n,t)*tangent.w; - //vec3 t = cross(b,n) * binormal.w; - - vary_mat0 = vec3(t.x, b.x, n.x); - vary_mat1 = vec3(t.y, b.y, n.y); - vary_mat2 = vec3(t.z, b.z, n.z); + + vary_tangent = t; + vary_sign = tangent.w; + vary_normal = n; #else //HAS_NORMAL_MAP vary_normal = n; #endif //HAS_NORMAL_MAP diff --git a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl index 203c3aca4a..87324bca7f 100644 --- a/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl +++ b/indra/newview/app_settings/shaders/class1/deferred/postDeferredGammaCorrect.glsl @@ -45,9 +45,6 @@ vec3 linear_to_srgb(vec3 cl); //=============================================================== // tone mapping taken from Khronos sample implementation //=============================================================== -const float GAMMA = 2.2; -const float INV_GAMMA = 1.0 / GAMMA; - // sRGB => XYZ => D65_2_D60 => AP1 => RRT_SAT const mat3 ACESInputMat = mat3 @@ -66,29 +63,6 @@ const mat3 ACESOutputMat = mat3 -0.07367, -0.00605, 1.07602 ); - -// linear to sRGB approximation -// see http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html -vec3 linearTosRGB(vec3 color) -{ - return pow(color, vec3(INV_GAMMA)); -} - - -// sRGB to linear approximation -// see http://chilliant.blogspot.com/2012/08/srgb-approximations-for-hlsl.html -vec3 sRGBToLinear(vec3 srgbIn) -{ - return vec3(pow(srgbIn.xyz, vec3(GAMMA))); -} - - -vec4 sRGBToLinear(vec4 srgbIn) -{ - return vec4(sRGBToLinear(srgbIn.xyz), srgbIn.w); -} - - // ACES tone map (faster approximation) // see: https://knarkowicz.wordpress.com/2016/01/06/aces-filmic-tone-mapping-curve/ vec3 toneMapACES_Narkowicz(vec3 color) @@ -129,13 +103,13 @@ vec3 toneMapACES_Hill(vec3 color) } uniform float exposure; +uniform float gamma; vec3 toneMap(vec3 color) { color *= exposure; #ifdef TONEMAP_ACES_NARKOWICZ - color *= 0.8; color = toneMapACES_Narkowicz(color); #endif @@ -147,11 +121,12 @@ vec3 toneMap(vec3 color) // boost exposure as discussed in https://github.com/mrdoob/three.js/pull/19621 // this factor is based on the exposure correction of Krzysztof Narkowicz in his // implemetation of ACES tone mapping - color *= 0.85/0.6; + color *= 1.0/0.6; + //color /= 0.6; color = toneMapACES_Hill(color); #endif - return linearTosRGB(color); + return linear_to_srgb(color); } //=============================================================== @@ -194,16 +169,26 @@ float noise(vec2 x) { //============================= + +vec3 legacyGamma(vec3 color) +{ + color = 1. - clamp(color, vec3(0.), vec3(1.)); + color = 1. - pow(color, vec3(gamma)); // s/b inverted already CPU-side + + return color; +} + void main() { //this is the one of the rare spots where diffuseRect contains linear color values (not sRGB) vec4 diff = texture2D(diffuseRect, vary_fragcoord) + texture2D(emissiveRect, vary_fragcoord); diff.rgb = toneMap(diff.rgb); - vec2 tc = vary_fragcoord.xy*screen_res; - + diff.rgb = legacyGamma(diff.rgb); + + vec2 tc = vary_fragcoord.xy*screen_res*4.0; vec3 seed = (diff.rgb+vec3(1.0))*vec3(tc.xy, tc.x+tc.y); vec3 nz = vec3(noise(seed.rg), noise(seed.gb), noise(seed.rb)); - diff.rgb += nz*0.008; + diff.rgb += nz*0.003; //diff.rgb = nz; frag_color = diff; } |