Adjustments to half texel fix

This commit is contained in:
Olivier Prat 2017-09-07 12:30:20 +02:00
parent b43514fb8b
commit 2003495166

View file

@ -32,14 +32,19 @@ const float OPACITY_EPSILON = 5e-3;
<@func main(IS_FILLED)@>
void main(void) {
float outlinedDepth = texture(outlinedDepthMap, varTexCoord0).x;
// We offset by half a texel to be centered on the depth sample. If we don't do this
// the blur will have a different width between the left / right sides and top / bottom
// sides of the silhouette
vec2 halfTexel = getInvWidthHeight() / 2;
vec2 texCoord0 = varTexCoord0+halfTexel;
float outlinedDepth = texture(outlinedDepthMap, texCoord0).x;
float intensity = 0.0;
if (outlinedDepth < FAR_Z) {
// We're not on the far plane so we are on the outlined object, thus no outline to do!
<@if IS_FILLED@>
// But we need to fill the interior
float sceneDepth = texture(sceneDepthMap, varTexCoord0).x;
float sceneDepth = texture(sceneDepthMap, texCoord0).x;
// Transform to linear depth for better precision
outlinedDepth = -evalZeyeFromZdb(outlinedDepth);
sceneDepth = -evalZeyeFromZdb(sceneDepth);
@ -56,10 +61,7 @@ void main(void) {
} else {
float weight = 0.0;
vec2 deltaUv = params._size / params._blurKernelSize;
// We offset by half a texel to be centered on the depth sample. If we don't do this
// the blur will have a different width between the left / right sides and top / bottom
// sides of the silhouette
vec2 lineStartUv = varTexCoord0 + (getInvWidthHeight() - params._size) / 2.0;
vec2 lineStartUv = texCoord0 - params._size / 2.0;
vec2 uv;
int x;
int y;