mirror of
https://github.com/lubosz/overte.git
synced 2025-04-23 12:14:00 +02:00
TAA now operates on tonemapped input and performs inverse tone map before bloom
This commit is contained in:
parent
6dd6218b77
commit
0085a6cfc0
4 changed files with 20 additions and 29 deletions
|
@ -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 };
|
||||
|
|
|
@ -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@>
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
Loading…
Reference in a new issue