开发者

Texture Address Mode Clamping, how does it work?

开发者 https://www.devze.com 2023-02-24 17:23 出处:网络
I\'m trying to understand how texture clamping works in OpenGL or any other API f开发者_如何学Pythonor that matter. I am aware of the fact that you define the operation as extending the range from [0,

I'm trying to understand how texture clamping works in OpenGL or any other API f开发者_如何学Pythonor that matter. I am aware of the fact that you define the operation as extending the range from [0,1] to anything, but clamping it to the edge.

So, if I have a pseudocode function:

unsigned int clampedTexel(float u, float v)

{

if(u < 0) u = 0;

if(u >= width) u = width-1;

if(v < 0) v = 0;

if(v >= height) v = height-1;

return image[u][v];

}

Texture Address Mode Clamping, how does it work?

(source: sud at wwwx.cs.unc.edu)

Right? So, If I run out of range, like 1.1 in the u direction, why doesn't it get clamped to the black color which is at the end? Rather than black, it goes to white in this example. Have I misunderstood something? Why is the value next to black getting clamped to white?

Or any other extension which is alternating from the edge color. Help me see where I am failing, please.


I think I see the problem. You're overlooking the fact that the top row of the texture is really the "white/black" alternating line, not the "black/white" line it appears to be. So the top row repeating white/black is correct. A similar situation occurs on the right edge where the last column is repeating white/black down rather than black/white.

Here is your texture with its outline:

Texture Address Mode Clamping, how does it work?

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号