GPU: disable anti-ringing calculations for mitchell filter

This commit is contained in:
logarithm
2019-11-29 18:03:05 +02:00
parent 6017609882
commit 8572bde25b

View File

@@ -112,9 +112,11 @@ vec4 textureCubic(sampler2D sampler, vec2 texCoords, int mode){
vec4 c; vec4 c;
if (mode == SAMPLING_CATROM)
{
// catrom benefits from anti-ringing
vec4 min_sample = vec4(FLT_MAX); vec4 min_sample = vec4(FLT_MAX);
vec4 max_sample = vec4(FLT_MIN); vec4 max_sample = vec4(FLT_MIN);
for (int m = -1; m <= 2; m++) for (int m = -1; m <= 2; m++)
{ {
for (int n = -1; n <= 2; n++) for (int n = -1; n <= 2; n++)
@@ -125,20 +127,8 @@ vec4 textureCubic(sampler2D sampler, vec2 texCoords, int mode){
min_sample = min(min_sample, vecData); min_sample = min(min_sample, vecData);
max_sample = max(max_sample, vecData); max_sample = max(max_sample, vecData);
float w;
// calculate weight based on distance of the current texel offset from the sub-texel position of the sampling location // calculate weight based on distance of the current texel offset from the sub-texel position of the sampling location
switch (mode){ float w = catmull_rom( d(vec2(m, n), coordFract) );
case SAMPLING_CATROM:
w = catmull_rom( d(vec2(m, n), coordFract) );
break;
case SAMPLING_MITCHELL:
w = mitchell( d(vec2(m, n), coordFract) );
break;
default:
w = 0;
break;
}
// build the weighted average // build the weighted average
nSum += vecData * w; nSum += vecData * w;
@@ -148,12 +138,31 @@ vec4 textureCubic(sampler2D sampler, vec2 texCoords, int mode){
// calculate weighted average // calculate weighted average
c = nSum / nDenom; c = nSum / nDenom;
if (mode == SAMPLING_CATROM) {
// anti-ringing // anti-ringing
vec4 aux = c; vec4 aux = c;
c = clamp(c, min_sample, max_sample); c = clamp(c, min_sample, max_sample);
c = mix(aux, c, CR_AR_STRENGTH); c = mix(aux, c, CR_AR_STRENGTH);
} }
else if (mode == SAMPLING_MITCHELL)
{
for (int m = -1; m <= 2; m++)
{
for (int n = -1; n <= 2; n++)
{
// get the raw texel, bypassing any other filters
vec4 vecData = texelFetch(sampler, texelCoords + ivec2(m, n), 0);
// calculate weight based on distance of the current texel offset from the sub-texel position of the sampling location
float w = mitchell( d(vec2(m, n), coordFract) );
// build the weighted average
nSum += vecData * w;
nDenom += w;
}
}
// calculate weighted average
c = nSum / nDenom;
}
// return the weighted average // return the weighted average
return c; return c;