
178 II Rendering Techniques
// Distance map 2D shape texturing , Stefan Gustavson 2011.
// A re-implementation of Green s method , using a single
// channel high precision distance map and explicit texel
// interpolation. This code is in the public domain .
#version 120
uniform sampler2D disttex ; // Single - channel distance field
uniform float texw , texh ; // Texture width and height ( texels )
varying float oneu , onev ; // 1/ texw and 1/ texh from vertex shader
varying vec2 st ; // Texture coords from vertex shader
void main (void )
{
vec2 uv = st * vec2 (texw , texh ); // Scale to texture rect coords
vec2 uv00 = floor (uv - vec2 (0.5) ); // Lower