Archived

This topic is now archived and is closed to further replies.

Lode

Texture filtering algorithms

Recommended Posts

I'd like to smooth a texture manually in a raytracer, what algorithms are used for that? And are there alternatives to the OpenGL and Direct3D filtering algorithm, because I think it sucks, see: I don't like the "crosses" it creates. Damn, I once saw a game that filtered ugly low res colored lightmaps that way, that was TERRIBLE! [edited by - Lode on July 29, 2002 8:28:44 AM]

Share this post


Link to post
Share on other sites
Obtain the December ''01 and January ''02 issues of Game Developer magazine. There were a couple of articles by Jonathan Blow relating to finding the most pleasing filters for generating mipmaps. The source code and .exe''s to those articles is at: http://www.gdmag.com/code.htm

Also, you should be able to find good information in most decent graphics textbooks (Computer Graphics Principles & Practice, Advanced Animation & Rendering etc).

Finally - bear in mind that the bilinear filtering done by consumer 3D hardware (OGL & D3D only expose what hardware does...) is designed solely for speed. IIRC it takes at most 4 samples. More gets better filtering, as does filtering in different spaces (as above).

--
Simon O''Connor
Creative Asylum Ltd
www.creative-asylum.com

Share this post


Link to post
Share on other sites
To get really nice results, you''re going to have to perform your filtering in frequency space.

That means using a two dimensional discrete Fourier transform (DFT, or alternatively FFT). Paul Bourke is the man for this.

Share this post


Link to post
Share on other sites
Since you want to use it for a ratyracer, I guess speed is of importance. While Fourier based filtering is a very good solution in terms of quality, it takes considerable performance.

You should take a look at bicubic, cosine and spline interpolations. Those methods can be reasonably fast and give pretty nice results.

If you use 3D hardware, then your are stuck with bilinear filtering, of course. Anisotropic won''t help you in the magnification case. And the only 3D systems able to perform realtime cubic interpolation of textures are from SGI and very expensive...

/ Yann

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
You don''t actually want to use a DFT, because you don''t really want a "perfect filtering". It turns out that the way we create texture maps is somewhat incompatible with handling them as band-limited signals. So if your filter is "too good", the results will be ugly. There is a sweet spot between "sucky filter" and "perfect filter" that you want to aim for.

I talk about this in my articles (which S1CA has already referred to). Unfortunately they''re only available in print, as I haven''t put electronic versions up yet. I can email them to you though, if you want. jon@bolt-action.com.

The other thing to worry about is to make sure your filtering is gamma-correct. This has a BIG impact on image quality (usually bigger than the filter type you use).

-Jonathan.

Share this post


Link to post
Share on other sites