Browse Source

TextureTools: improve distance field computation without texelFetch().

GL 3.2 has texelFetch() and layout(pixel_center_integer), which means
that we integer coordinates with no precision loss when addressing
individual pixels in the source texture. In the versions before we have
to craft floating-point coordinates for texture() to grab the value of
wanted pixel with no jumping around or interpolation.

This change improves the behavior *a bit*, but not fully. I'm postponing
this to the point when I have an unit test that compares the output with
ground truth.
pull/118/head
Vladimír Vondruš 11 years ago
parent
commit
6dfcde1f48
  1. 4
      src/Magnum/TextureTools/DistanceFieldShader.frag

4
src/Magnum/TextureTools/DistanceFieldShader.frag

@ -87,7 +87,7 @@ void main() {
#ifdef TEXELFETCH_USABLE #ifdef TEXELFETCH_USABLE
const mediump ivec2 position = ivec2(gl_FragCoord.xy*scaling); const mediump ivec2 position = ivec2(gl_FragCoord.xy*scaling);
#else #else
const mediump vec2 position = gl_FragCoord.xy*scaling*imageSizeInverted; const mediump vec2 position = (gl_FragCoord.xy - vec2(0.5))*scaling*imageSizeInverted;
#endif #endif
/* If pixel at the position is inside (1), we are looking for nearest pixel /* If pixel at the position is inside (1), we are looking for nearest pixel
@ -111,7 +111,7 @@ void main() {
#ifdef TEXELFETCH_USABLE #ifdef TEXELFETCH_USABLE
const lowp ivec2 offset = ivec2(-i+j, i); const lowp ivec2 offset = ivec2(-i+j, i);
#else #else
const lowp vec2 pixelOffset = vec2(float(-i+j), float(i)); const lowp vec2 pixelOffset = vec2(float(-i+j), float(i)) + vec2(0.5);
const lowp vec2 offset = pixelOffset*imageSizeInverted; const lowp vec2 offset = pixelOffset*imageSizeInverted;
#endif #endif

Loading…
Cancel
Save