We need to set the texture parameter before the texture mapping. But how do those parameters control the behavior of the texture mapping? Does it happen within the texture lookup functions? Where can I get some reference about how the texture lookup function use the texture parameters? Thank you.
Look out for the red book.
The parameters guide in designing a texture to be later populated by data. They tell us about the limits imposed on them if the area they bound falls short or exceeds its dimension .It also help us in telling nature of filtering associated useful in interpolation during texture fetch.
eg:.(… WRAP_S, CLAMP) tell to clamp texture coordinate between one and zero in the x direction ( or S direction)
an OpenGL texture object (GLuint id) has startup parameters and stores all parameters you change. you can set them once as those parameters are stored per each texture object. on glBindTexture they are checked and used accordingly. if f.e. you know your texture would end up in GUI rendering and won’t be scaled (or even scaled but would look horrible) you can specify GL_NEAREST filter after loading and forget about it.
Thanks for the repies. But in which stages do the texture filtering and clamping happen? It happened in the rasterization immediately after the vertex shader or in the texure lookup in the fragment shader, or in other stage? How does GL determine whether a texel is magnified or minified? Any mathematical formula involves?
Lots of scary formulas in the core spec.
Section 3.8 is on texturing and filtering lurks just below.
Texture filtering happens before coming to fragment shader. To be exact, filtering happens during tex fetch.
Mathematical formula involvement depends on kind of filtering you are assigning to a texture. Example GL_NEAREST does not filte, GL_LINEAR does linear filtering. similarly, other filtering like cubic, bicubic , all involve different bases, top help in interpolation.