diff --git a/libraries/render-utils/src/AntialiasingEffect.h b/libraries/render-utils/src/AntialiasingEffect.h index 0b497c0cec..6de24dc86a 100644 --- a/libraries/render-utils/src/AntialiasingEffect.h +++ b/libraries/render-utils/src/AntialiasingEffect.h @@ -106,10 +106,10 @@ public: AntialiasingConfig() : render::Job::Config(true) {} float blend{ 0.1f }; - float sharpen{ 0.15f }; + float sharpen{ 0.1f }; bool constrainColor{ true }; - float covarianceGamma{ 0.9f }; + float covarianceGamma{ 1.0f }; bool feedbackColor{ false }; float debugX{ 0.0f }; diff --git a/libraries/render-utils/src/MaterialTextures.slh b/libraries/render-utils/src/MaterialTextures.slh index cff5ec41ee..592aa37461 100644 --- a/libraries/render-utils/src/MaterialTextures.slh +++ b/libraries/render-utils/src/MaterialTextures.slh @@ -235,8 +235,8 @@ vec3 fetchLightmapMap(vec2 uv) { vec3 normalizedTangent = normalize(<$interpolatedTangent$>.xyz); vec3 normalizedBitangent = cross(normalizedNormal, normalizedTangent); // attenuate the normal map divergence from the mesh normal based on distance - // The attenuation range [50,200] meters from the eye is arbitrary for now - vec3 localNormal = mix(<$fetchedNormal$>, vec3(0.0, 1.0, 0.0), smoothstep(50.0, 200.0, (-<$fragPos$>).z)); + // The attenuation range [30,100] meters from the eye is arbitrary for now + vec3 localNormal = mix(<$fetchedNormal$>, vec3(0.0, 1.0, 0.0), smoothstep(30.0, 100.0, (-<$fragPos$>).z)); <$normal$> = vec3(normalizedBitangent * localNormal.x + normalizedNormal * localNormal.y + normalizedTangent * localNormal.z); } <@endfunc@> diff --git a/libraries/render-utils/src/fxaa_blend.slf b/libraries/render-utils/src/fxaa_blend.slf index 7c9b2d0f1b..996344c881 100644 --- a/libraries/render-utils/src/fxaa_blend.slf +++ b/libraries/render-utils/src/fxaa_blend.slf @@ -36,5 +36,8 @@ void main(void) { pixels[8] = texelFetch(colorTexture, ivec2(gl_FragCoord.xy)+ivec2(1,1), 0); sharpenedPixel = pixels[4]*6.8 - (pixels[1]+pixels[3]+pixels[5]+pixels[7]) - (pixels[0]+pixels[2]+pixels[6]+pixels[8])*0.7; - outFragColor = clamp(pixels[4] + sharpenedPixel * sharpenIntensity, pixels[4]/2, pixels[4]*2); + + vec4 minColor = max(vec4(0), pixels[4]-vec4(0.5)); + vec4 maxColor = pixels[4]+vec4(0.5); + outFragColor = clamp(pixels[4] + sharpenedPixel * sharpenIntensity, minColor, maxColor); } diff --git a/libraries/render-utils/src/taa.slh b/libraries/render-utils/src/taa.slh index 0215780953..95e4b49453 100644 --- a/libraries/render-utils/src/taa.slh +++ b/libraries/render-utils/src/taa.slh @@ -76,47 +76,35 @@ vec2 taa_getRegionFXAA() { #define USE_YCOCG 1 vec4 taa_fetchColor(sampler2D map, vec2 uv) { + vec4 c = texture(map, uv); + // Apply rapid pseudo tonemapping as TAA is applied to a tonemapped image + c.rgb = c.rgb / (vec3(1)+c.rgb); #if USE_YCOCG - vec4 c = texture(map, uv); - return vec4(color_LinearToYCoCg(c.rgb), c.a); + return vec4(color_LinearToYCoCg(c.rgb), c.a); #else - return texture(map, uv); + return c; #endif } vec3 taa_resolveColor(vec3 color) { #if USE_YCOCG - return max(vec3(0), color_YCoCgToUnclampedLinear(color)); -#else - return color; + color = max(vec3(0), color_YCoCgToUnclampedLinear(color)); #endif + // Apply rapid inverse tonemapping + color = color / (vec3(1)-color); + return color; } vec4 taa_fetchSourceMap(vec2 uv) { -#if USE_YCOCG - vec4 c = texture(sourceMap, uv); - return vec4(color_LinearToYCoCg(c.rgb), c.a); -#else - return texture(sourceMap, uv); -#endif + return taa_fetchColor(sourceMap, uv); } vec4 taa_fetchHistoryMap(vec2 uv) { -#if USE_YCOCG - vec4 c = texture(historyMap, uv); - return vec4(color_LinearToYCoCg(c.rgb), c.a); -#else - return texture(historyMap, uv); -#endif + return taa_fetchColor(historyMap, uv); } vec4 taa_fetchNextMap(vec2 uv) { -#if USE_YCOCG - vec4 c = texture(nextMap, uv); - return vec4(color_LinearToYCoCg(c.rgb), c.a); -#else - return texture(nextMap, uv); -#endif + return taa_fetchColor(nextMap, uv); } vec2 taa_fetchVelocityMap(vec2 uv) {