Important Notice: Our web hosting provider recently started charging us for additional visits, which was unexpected. In response, we're seeking donations. Depending on the situation, we may explore different monetization options for our Community and Expert Contributors. It's crucial to provide more returns for their expertise and offer more Expert Validated Answers or AI Validated Answers. Learn more about our hosting issue here.

What do correct texture coordinates look like?

coordinates look Texture
0
10 Posted

What do correct texture coordinates look like?

0

The answer depends on which API it is (Direct3D or OpenGL) and on what kind of texture it is. Direct3D addresses texels at their top-left corner. OpenGL addresses texel centers. In OpenGL, most texture coordinates are normalized to the range (0..1) in each dimension, with the exception that texture rectangles (GL_TEXTURE_RECTANGLE_ARB) use unnormalized coordinates ranging from (0..width, 0..height). The centers of OpenGL texels along the diagonal of a GL_TEXTURE_RECTANGLE_ARB are therefore(0.5, 0.5), (1.5, 1.5), (2.5, 2.5), etc. (To see this try writing WPOS to the output of a shader on a screen-aligned quad.) To get the corresponding texture coordinates for GL_TEXTURE_2D textures, you have to normalize them, meaning you divide by width and height. For a 4-by-4 GL_TEXTURE_2D, that would give us texel centers along the diagonal of (0.125,0.125), (0.375,0.375), (0.625,0.625), and (0.875,0.875). Direct3D texture coordinates are always normalized, so the corresponding Direct3D texel center

Related Questions

What is your question?

*Sadly, we had to bring back ads too. Hopefully more targeted.