🔒 Locked
Bilinear/Trilinear Filtering
Advertisement
Original Post
Hey, I've recently started doing OpenGL, ive created a quite (in my opinion) sweet lighted terrain demo, which will load an arbitryay heightmap and stuff: http://www.geocities.com/ademan420/LitTerrain.zip and anyways, i was wondering how you would do bilinear or trilinear filtering for textureing, is it an extension? or what? i originally thought it might have somethign to do with glTexParameteri() since i saw GL_LINEAR, but i dunno, so how do you do it? is there soemthign very big im not getting? anyways, thanks -Dan
Bilinear filtering is GL_LINEAR
Bilinear mipmaping is GL_LINEAR_MIPMAP_NEAREST
Trilinear is GL_LINEAR_MIPMAP_LINEAR
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
would setup trilinear filtering on the currently bound texture.
These only work for minifaction filtering, for max filtering the best you've got is Bilinear
Bilinear mipmaping is GL_LINEAR_MIPMAP_NEAREST
Trilinear is GL_LINEAR_MIPMAP_LINEAR
glTexParameteri (GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
would setup trilinear filtering on the currently bound texture.
These only work for minifaction filtering, for max filtering the best you've got is Bilinear
Quote:
Original post by Promit
Bilinear means that you use GL_LINEAR for your min and mag filters, and either GL_NEAREST for mipmaps, or no mipmaps.
Sometimes this is referred as "brilinear" filtering. (you get the point of the wording issue).
Note that if you use mipmaps in minification, you have to fill all mipmap levels otherwise the texture will be considered "incomplete" and all sampled texels will be white. To fill the mipmap levels, either use the gluBuild2DMipmaps function or use the GL_SGIS_generate_mipmap extension (I personnaly prefer the latter, which is more elegant ans faster to execute).
Quote:
Original post by vincoof
To fill the mipmap levels, either use the gluBuild2DMipmaps function or use the GL_SGIS_generate_mipmap extension (I personnaly prefer the latter, which is more elegant ans faster to execute).
Yes, i've just switched to that as well :)
Quote:
Original post by vincoof Quote:
Original post by Promit
Bilinear means that you use GL_LINEAR for your min and mag filters, and either GL_NEAREST for mipmaps, or no mipmaps.
Sometimes this is referred as "brilinear" filtering. (you get the point of the wording issue).
Not true. Brilinear filtering is a hybrid of trilinear and bilinear mipmap filtering. The algorithm uses trilinear filtering for fragments which fall midway between the two mipmap levels, but where the fragment is close to one mipmap level (using some threshold value; say >75%), it switches to bilinear filtering for efficiency.
Brilinear is specified by the graphics card drivers. AFAIK there is no way to implement it explicitly through OpenGL. ATi apparently use brilinear as standard instead of trilinear, mainly because it gives the edge on benchmarks.
Quote:
Original post by benjamin bunny
Brilinear filtering is a hybrid of trilinear and bilinear mipmap filtering. The algorithm uses trilinear filtering for fragments which fall midway between the two mipmap levels, but where the fragment is close to one mipmap level (using some threshold value; say >75%), it switches to bilinear filtering for efficiency.
Yes, but LINEAR_MIPMAP_NEAREST is some kind of brilinear, granted that this threshold is pushed to its limits.
Quote:
it hardly looked like any filtering was going on at all when i looked at my terrain close up, ive been using GL_LINEAR for minification and maxification (right word?)
First, the right word is magnification. Secondly, what lines did you call when you say "you've been using GL_LINEAR" and when do you call that ?
Typically it should be done juster after or just before filling the texture data, smtg like :
glGenTextures(1, &texture_id);glBindTexture(GL_TEXTURE_2D, texture_id);glTexImage2D(GL_TEXTURE_2D, ...);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
i should be shot, i was remembering different code than this, i apologize, jeez....
either way, i think its time to plug my terrain (Which does not have bilinear/trilinear filtering)
http://www.geocities.com/ademan420/LitTerrain.zip
a lot of people have told me it looks quite nice, id like to hear what people who deal with that kind of stuff all the time, think abotu it, thanks
-Dan
either way, i think its time to plug my terrain (Which does not have bilinear/trilinear filtering)
http://www.geocities.com/ademan420/LitTerrain.zip
a lot of people have told me it looks quite nice, id like to hear what people who deal with that kind of stuff all the time, think abotu it, thanks
-Dan
Quote:
Original post by vincoof
Yes, but LINEAR_MIPMAP_NEAREST is some kind of brilinear, granted that this threshold is pushed to its limits.
still not. bri suggests filtering sometimes bi- and sometimes trilinear, but the above will never ever filter trilinear, no matter where. else one could apply your reasoning and call nearest to be "mobilinear" with a maximum threshold.
Yeah, but GL_MIPMAP_NEAREST doesn't filter texels from more than one mip level. Ever.
Quote:
Original post by vincoof
Filtering a texel in the same image can not be compared to filtering texels between mipmap levels.
thats the point. what you suggest IS filtering in the same image and even with the image being different the filtering itself is just 2d but never 3d. to be called bri id expect filtering in 3d at least sometimes. but then.. hey, i expect hardware i pay hundreds of dollars for to actually do what it claims when i say "filter trilinear".. and i guess im expecting too much *g*
Quote:
Original post by vincoof
Now that's we're on wording issues, please call it 2.5D, not 3D. 3D texturing is something completely different ;)
*bangs head against wall*
Now now, that won't solve anything. Try this.
*hands gun to benjamin*
*hands gun to benjamin*
Topic Locked
This topic has been locked by a moderator. New replies are not allowed.
Sign in to reply to this topic.
Advertisement