Eevee: Fix post process with Ugly color.
This was cause by some post process not always sampling the highest mipmap. But if there is no need for mipmapping (i.e. no SSR) these levels will be undefined. So forcing all Post FX shader to sample level 0 fix this.
This commit is contained in:
@@ -64,10 +64,10 @@ vec3 downsample_filter_high(sampler2D tex, vec2 uv, vec2 texelSize)
|
||||
/* Downsample with a 4x4 box filter + anti-flicker filter */
|
||||
vec4 d = texelSize.xyxy * vec4(-1, -1, +1, +1);
|
||||
|
||||
vec3 s1 = texture(tex, uv + d.xy).rgb;
|
||||
vec3 s2 = texture(tex, uv + d.zy).rgb;
|
||||
vec3 s3 = texture(tex, uv + d.xw).rgb;
|
||||
vec3 s4 = texture(tex, uv + d.zw).rgb;
|
||||
vec3 s1 = textureLod(tex, uv + d.xy, 0.0).rgb;
|
||||
vec3 s2 = textureLod(tex, uv + d.zy, 0.0).rgb;
|
||||
vec3 s3 = textureLod(tex, uv + d.xw, 0.0).rgb;
|
||||
vec3 s4 = textureLod(tex, uv + d.zw, 0.0).rgb;
|
||||
|
||||
/* Karis's luma weighted average (using brightness instead of luma) */
|
||||
float s1w = 1.0 / (brightness(s1) + 1.0);
|
||||
@@ -85,10 +85,10 @@ vec3 downsample_filter(sampler2D tex, vec2 uv, vec2 texelSize)
|
||||
vec4 d = texelSize.xyxy * vec4(-1, -1, +1, +1);
|
||||
|
||||
vec3 s;
|
||||
s = texture(tex, uv + d.xy).rgb;
|
||||
s += texture(tex, uv + d.zy).rgb;
|
||||
s += texture(tex, uv + d.xw).rgb;
|
||||
s += texture(tex, uv + d.zw).rgb;
|
||||
s = textureLod(tex, uv + d.xy, 0.0).rgb;
|
||||
s += textureLod(tex, uv + d.zy, 0.0).rgb;
|
||||
s += textureLod(tex, uv + d.xw, 0.0).rgb;
|
||||
s += textureLod(tex, uv + d.zw, 0.0).rgb;
|
||||
|
||||
return s * (1.0 / 4);
|
||||
}
|
||||
@@ -99,17 +99,17 @@ vec3 upsample_filter_high(sampler2D tex, vec2 uv, vec2 texelSize)
|
||||
vec4 d = texelSize.xyxy * vec4(1, 1, -1, 0) * sampleScale;
|
||||
|
||||
vec3 s;
|
||||
s = texture(tex, uv - d.xy).rgb;
|
||||
s += texture(tex, uv - d.wy).rgb * 2;
|
||||
s += texture(tex, uv - d.zy).rgb;
|
||||
s = textureLod(tex, uv - d.xy, 0.0).rgb;
|
||||
s += textureLod(tex, uv - d.wy, 0.0).rgb * 2;
|
||||
s += textureLod(tex, uv - d.zy, 0.0).rgb;
|
||||
|
||||
s += texture(tex, uv + d.zw).rgb * 2;
|
||||
s += texture(tex, uv ).rgb * 4;
|
||||
s += texture(tex, uv + d.xw).rgb * 2;
|
||||
s += textureLod(tex, uv + d.zw, 0.0).rgb * 2;
|
||||
s += textureLod(tex, uv , 0.0).rgb * 4;
|
||||
s += textureLod(tex, uv + d.xw, 0.0).rgb * 2;
|
||||
|
||||
s += texture(tex, uv + d.zy).rgb;
|
||||
s += texture(tex, uv + d.wy).rgb * 2;
|
||||
s += texture(tex, uv + d.xy).rgb;
|
||||
s += textureLod(tex, uv + d.zy, 0.0).rgb;
|
||||
s += textureLod(tex, uv + d.wy, 0.0).rgb * 2;
|
||||
s += textureLod(tex, uv + d.xy, 0.0).rgb;
|
||||
|
||||
return s * (1.0 / 16.0);
|
||||
}
|
||||
@@ -120,10 +120,10 @@ vec3 upsample_filter(sampler2D tex, vec2 uv, vec2 texelSize)
|
||||
vec4 d = texelSize.xyxy * vec4(-1, -1, +1, +1) * (sampleScale * 0.5);
|
||||
|
||||
vec3 s;
|
||||
s = texture(tex, uv + d.xy).rgb;
|
||||
s += texture(tex, uv + d.zy).rgb;
|
||||
s += texture(tex, uv + d.xw).rgb;
|
||||
s += texture(tex, uv + d.zw).rgb;
|
||||
s = textureLod(tex, uv + d.xy, 0.0).rgb;
|
||||
s += textureLod(tex, uv + d.zy, 0.0).rgb;
|
||||
s += textureLod(tex, uv + d.xw, 0.0).rgb;
|
||||
s += textureLod(tex, uv + d.zw, 0.0).rgb;
|
||||
|
||||
return s * (1.0 / 4.0);
|
||||
}
|
||||
@@ -136,14 +136,14 @@ vec4 step_blit(void)
|
||||
|
||||
#ifdef HIGH_QUALITY /* Anti flicker */
|
||||
vec3 d = sourceBufferTexelSize.xyx * vec3(1, 1, 0);
|
||||
vec3 s0 = texture(sourceBuffer, uvcoordsvar.xy).rgb;
|
||||
vec3 s1 = texture(sourceBuffer, uvcoordsvar.xy - d.xz).rgb;
|
||||
vec3 s2 = texture(sourceBuffer, uvcoordsvar.xy + d.xz).rgb;
|
||||
vec3 s3 = texture(sourceBuffer, uvcoordsvar.xy - d.zy).rgb;
|
||||
vec3 s4 = texture(sourceBuffer, uvcoordsvar.xy + d.zy).rgb;
|
||||
vec3 s0 = textureLod(sourceBuffer, uvcoordsvar.xy, 0.0).rgb;
|
||||
vec3 s1 = textureLod(sourceBuffer, uvcoordsvar.xy - d.xz, 0.0).rgb;
|
||||
vec3 s2 = textureLod(sourceBuffer, uvcoordsvar.xy + d.xz, 0.0).rgb;
|
||||
vec3 s3 = textureLod(sourceBuffer, uvcoordsvar.xy - d.zy, 0.0).rgb;
|
||||
vec3 s4 = textureLod(sourceBuffer, uvcoordsvar.xy + d.zy, 0.0).rgb;
|
||||
vec3 m = median(median(s0.rgb, s1, s2), s3, s4);
|
||||
#else
|
||||
vec3 s0 = texture(sourceBuffer, uvcoordsvar.xy).rgb;
|
||||
vec3 s0 = textureLod(sourceBuffer, uvcoordsvar.xy, 0.0).rgb;
|
||||
vec3 m = s0.rgb;
|
||||
#endif
|
||||
|
||||
@@ -180,7 +180,7 @@ vec4 step_upsample(void)
|
||||
#else
|
||||
vec3 blur = upsample_filter(sourceBuffer, uvcoordsvar.xy, sourceBufferTexelSize);
|
||||
#endif
|
||||
vec3 base = texture(baseBuffer, uvcoordsvar.xy).rgb;
|
||||
vec3 base = textureLod(baseBuffer, uvcoordsvar.xy, 0.0).rgb;
|
||||
return vec4(base + blur, 1.0);
|
||||
}
|
||||
|
||||
@@ -191,7 +191,7 @@ vec4 step_resolve(void)
|
||||
#else
|
||||
vec3 blur = upsample_filter(sourceBuffer, uvcoordsvar.xy, sourceBufferTexelSize);
|
||||
#endif
|
||||
vec4 base = texture(baseBuffer, uvcoordsvar.xy);
|
||||
vec4 base = textureLod(baseBuffer, uvcoordsvar.xy, 0.0);
|
||||
vec3 cout = base.rgb + blur * bloomIntensity;
|
||||
return vec4(cout, base.a);
|
||||
}
|
||||
|
||||
@@ -180,17 +180,17 @@ vec4 upsample_filter_high(sampler2D tex, vec2 uv, vec2 texelSize)
|
||||
vec4 d = texelSize.xyxy * vec4(1, 1, -1, 0);
|
||||
|
||||
vec4 s;
|
||||
s = texture(tex, uv - d.xy);
|
||||
s += texture(tex, uv - d.wy) * 2;
|
||||
s += texture(tex, uv - d.zy);
|
||||
s = textureLod(tex, uv - d.xy, 0.0);
|
||||
s += textureLod(tex, uv - d.wy, 0.0) * 2;
|
||||
s += textureLod(tex, uv - d.zy, 0.0);
|
||||
|
||||
s += texture(tex, uv + d.zw) * 2;
|
||||
s += texture(tex, uv ) * 4;
|
||||
s += texture(tex, uv + d.xw) * 2;
|
||||
s += textureLod(tex, uv + d.zw, 0.0) * 2;
|
||||
s += textureLod(tex, uv , 0.0) * 4;
|
||||
s += textureLod(tex, uv + d.xw, 0.0) * 2;
|
||||
|
||||
s += texture(tex, uv + d.zy);
|
||||
s += texture(tex, uv + d.wy) * 2;
|
||||
s += texture(tex, uv + d.xy);
|
||||
s += textureLod(tex, uv + d.zy, 0.0);
|
||||
s += textureLod(tex, uv + d.wy, 0.0) * 2;
|
||||
s += textureLod(tex, uv + d.xy, 0.0);
|
||||
|
||||
return s * (1.0 / 16.0);
|
||||
}
|
||||
@@ -201,10 +201,10 @@ vec4 upsample_filter(sampler2D tex, vec2 uv, vec2 texelSize)
|
||||
vec4 d = texelSize.xyxy * vec4(-1, -1, +1, +1) * 0.5;
|
||||
|
||||
vec4 s;
|
||||
s = texture(tex, uv + d.xy);
|
||||
s += texture(tex, uv + d.zy);
|
||||
s += texture(tex, uv + d.xw);
|
||||
s += texture(tex, uv + d.zw);
|
||||
s = textureLod(tex, uv + d.xy, 0.0);
|
||||
s += textureLod(tex, uv + d.zy, 0.0);
|
||||
s += textureLod(tex, uv + d.xw, 0.0);
|
||||
s += textureLod(tex, uv + d.zw, 0.0);
|
||||
|
||||
return s * (1.0 / 4.0);
|
||||
}
|
||||
@@ -213,7 +213,7 @@ vec4 upsample_filter(sampler2D tex, vec2 uv, vec2 texelSize)
|
||||
void step_resolve(void)
|
||||
{
|
||||
/* Recompute Near / Far CoC */
|
||||
float depth = texture(depthBuffer, uvcoord).r;
|
||||
float depth = textureLod(depthBuffer, uvcoord, 0.0).r;
|
||||
float zdepth = linear_depth(depth);
|
||||
float coc_signed = calculate_coc(zdepth);
|
||||
float coc_far = max(-coc_signed, 0.0);
|
||||
@@ -221,7 +221,7 @@ void step_resolve(void)
|
||||
|
||||
/* Recompute Near / Far CoC */
|
||||
vec2 texelSize = 1.0 / vec2(textureSize(farBuffer, 0));
|
||||
vec4 srccolor = texture(colorBuffer, uvcoord);
|
||||
vec4 srccolor = textureLod(colorBuffer, uvcoord, 0.0);
|
||||
vec4 farcolor = upsample_filter_high(farBuffer, uvcoord, texelSize);
|
||||
vec4 nearcolor = upsample_filter_high(nearBuffer, uvcoord, texelSize);
|
||||
|
||||
|
||||
@@ -11,5 +11,5 @@ void main()
|
||||
/* Reconstructing Target uvs like this avoid missing pixels if NPO2 */
|
||||
vec2 uvs = gl_FragCoord.xy * 2.0 / vec2(textureSize(source, 0));
|
||||
|
||||
FragColor = texture(source, uvs);
|
||||
FragColor = textureLod(source, uvs, 0.0);
|
||||
}
|
||||
@@ -59,7 +59,7 @@ void main()
|
||||
|
||||
FragColor = vec4(0.0, 0.0, 0.0, 1.0);
|
||||
for (int j = 0; j < samples && j < MAX_SAMPLE; j++) {
|
||||
FragColor += texture(colorBuffer, uvcoordsvar.xy + motion * i) * inv_samples;
|
||||
FragColor += textureLod(colorBuffer, uvcoordsvar.xy + motion * i, 0.0) * inv_samples;
|
||||
i += inc;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user