|
From: Frank C <li...@si...> - 2004-06-03 23:34:31
|
NOTE: I tired to send this to the list earlier but ran into some list troubles - I've already sent Joe some changes that implement mipmapping and filtering as discussed below. I apologize if this is a duplicate message! On 2-Jun-04, at 10:53 PM, Joseph J. Strout wrote: > OK, let's talk about this issue: > >> 1. Proper mipmap filtering >> <http://sourceforge.net/tracker/index.php? >> func=detail&aid=905678&group_id=45158&atid=442052>. There are several >> ideas in this request, but the most important one is to automatically >> generate mipmaps from a Pixmap texture, just as QD3D 1.6 does. (And >> then of course if you don't want mipmaps generated for you, you can >> use a MipMap texture instead.) > > My understanding is that in QD3D 1.6, when you use a PixmapTexture, > mipmaps are generated under the hood for you, and the renderer then > selects the one most suited to the object's usage in the scene. > ... > That suggests that maybe the renderer code is the right place to look > -- perhaps IRTexture.c? Perhaps modify ir_texture_convert_pixmap so > that it generates an OpenGL mipmap set, as ir_texture_convert_mipmap > does? If we do it here, is all that scaling and conversion going to > happen on every frame, or just once for each time the texture is > edited? And if there are multiple objects sharing the same texture, > will it happen just once for the whole lot? Easiest way is to replace the glTexImage2D call with a call to gluBuild2DMipmaps and they'll be created auto-magically. You can minimize them manually and call glTexImage2D multiple times as well, which is often preferred since the result will be more predictable regardless of OS, hardware, or OGL implementation. A custom algorithm can also be tweaked to give better results than gluBuild2DMipmaps. Creating the mipmaps is only the first step however. The cachedTexture->qualityFilter settings in the ir_texture_set_state function have to be changed to take advantage of mipmaps. This can be done in a couple ways, though I'd recommend the following: Create a new private struct: typedef struct TQ3QualityFilter { GLuint magFilter; GLuint minFilter; } TQ3QualityFilter; Then replace the qualityFilter member of the TQ3CachedTexture struct with TQ3QualityFilter and modify the affected routines accordingly; ir_texture_convert_rave_filter, ir_texture_set_state, IRRenderer_Texture_Rebuild, and ir_texture_cache_add. The actual values of the mag/min filters would follow the recommendations outlined in the bug report. I've actually gone ahead and did this on a local copy and it seems to work just fine (currently using gluBuild2DMipmaps). Frank. |