Reputation: 311
From what I've read in terms pixel center convention, OpenGL considers a pixel's center at its half-pixel location. That makes pixel centers for rasterization "match" texel centers for texturing.
So, if the following 4 conditions hold true:
then:
the matching between a texture's texels and viewport's pixels will be 1-to-1 ?
no need to add/subtract any correction (+/-0.5) ?
any idea on how to check that it's a 1-to-1 match ?
any hints?
Upvotes: 1
Views: 604
Reputation: 862
You can use partial derivative functions in glsl. Partial difference derivative functions.These are fragment shader instructions wich can be used to compute the rate of variation of any value with respect to the screen-space coordinates. This any value can be texture co ordinates So
vec2 dx_vtc = dFdx(texture_coordinate); vec2 dy_vtc = dFdy(texture_coordinate);
float len1 = length(dx_vtc); float len2 = length(dy_vtc);
If difference in length is zero then we can conclude there is one to one mapping.
Upvotes: 1