opengl texture lod bias adjusting via opengl function call?
-
19-09-2019 - |
Question
how is it possible to change the lod bias via an opengl function call? i dont like the default settings, changes the miplevels too early and makes the nearby ground look ugly.
i couldnt find any codes to do this, every topic was about some external programs that does the job...
Edit: This is my texture settings:
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST_MIPMAP_NEAREST);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST_MIPMAP_NEAREST);
Solution
Use:
glTexEnvf(GL_TEXTURE_FILTER_CONTROL, GL_TEXTURE_LOD_BIAS, bias);
More details here: http://www.opengl.org/sdk/docs/man/xhtml/glTexEnv.xml and there: http://oss.sgi.com/projects/ogl-sample/registry/EXT/texture_lod_bias.txt
EDIT:
Ok, I see. First GL_TEXTURE_MAG_FILTER
can only take two possible values:
- either
GL_NEAREST
- or
GL_LINEAR
So use GL_LINEAR
for the best result.
Then for GL_TEXTURE_MIN_FILTER
, with GL_NEAREST_MIPMAP_NEAREST
you are using no texture interpolation, only mipmaping (you take the nearest mipmap that suits the best, but inside this mipmap you take the nearest texel only, without interpolation between this texel and his neighbours).
So use GL_NEAREST_MIPMAP_LINEAR
for doing this weighted average between the texels.
With GL_LINEAR_MIPMAP_LINEAR
you can have even more rendering quality since it will use a linear interpolation between the result of the texture fetch for two mipmaps (mipmap N and N+1) instead of just taking the result of the texture fetch for mipmap N, like previously.
GL_LINEAR_MIPMAP_LINEAR
is also known as trilinear filtering.
OTHER TIPS
i tried that function, but it didnt help at all, i wanted to change the angle when the miplevel changes, not the distance... is there some way to do this angle fix?
i wasnt sure which is the correct word so i used "lod bias" ... which was the only thing about miplevel changing i found