Skip to main content
gamedev.net
🔒 Locked

Bilinear/Trilinear Filtering

Started by Ademan555 Jun 29, 2004 at 4:38 PM 15 replies 10.8k views
Original Post
Ademan555
Ademan555
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
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Promit
Promit
Bilinear means that you use GL_LINEAR for your min and mag filters, and either GL_NEAREST for mipmaps, or no mipmaps.

Trilinear means using GL_LINEAR for min and mag filters, as well as using GL_LINEAR for the mipmap min filter.

Nothing special there.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
_the_phantom_
_the_phantom_
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
vincoof
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).

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).
_the_phantom_
_the_phantom_
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 :)
benjamin bunny
benjamin bunny
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.
Ademan555
Ademan555
Thanks all, but i guess, 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?)
thanks
-Dan
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
vincoof
vincoof
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);
Ademan555
Ademan555
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
When General Patton died after World War 2 he went to the gates of Heaven to talk to St. Peter. The first thing he asked is if there were any Marines in heaven. St. Peter told him no, Marines are too rowdy for heaven. He then asked why Patton wanted to know. Patton told him he was sick of the Marines overshadowing the Army because they did more with less and were all hard-core sons of bitches. St. Peter reassured him there were no Marines so Patton went into Heaven. As he was checking out hi
Trienco
Trienco
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.
f@dzhttp://festini.device-zero.de
vincoof
vincoof
[lol]
Not really. "mobilinear" is not to bilinear what brilinear is to trilinear. Filtering a texel in the same image can not be compared to filtering texels between mipmap levels.
python_regious
python_regious
Yeah, but GL_MIPMAP_NEAREST doesn't filter texels from more than one mip level. Ever.
If at first you don't succeed, redefine success.
Trienco
Trienco
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*
f@dzhttp://festini.device-zero.de
vincoof
vincoof
Now that's we're on wording issues, please call it 2.5D, not 3D. 3D texturing is something completely different ;)
benjamin bunny
benjamin bunny
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*
Nemesis2k2
Nemesis2k2
Now now, that won't solve anything. Try this.
*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.