ekremer
ekremer

Reputation: 311

texel / pixel matching in OpenGL 3.x / 4x

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:

  1. the "world" coordinate system "exactly" matches the viewport resolution (ex. both 1920x1080)
  2. projection is orthographic (glm::ortho )
  3. every texture's width/height matches 1 to 1 (texel to pixel) those defined by its corresponding quaternion's vertices
  4. UV [0,1] used for texture mapping

then:

any hints?

Upvotes: 1

Views: 604

Answers (1)

Paritosh Kulkarni
Paritosh Kulkarni

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

Related Questions