#139607 - simonjhall - Sat Sep 08, 2007 2:26 am
Some context: it's Quake-on-the-DS again, and I'm trying to make the brush model textures which have non-standard sizes work correctly. The character models have non-po2 textures, but they're handled differently (and correctly).
In Quake, brush models (eg the world itself and ammo packs, not guns, rockets or players) have their meshes stored as a set of vertices, and the faces to be drawn are extracted from the bsp system at runtime to minimise overdraw etc etc. However to save on memory (I think...) texture co-ordinates are not stored - instead the level designer 'projects' their chosen texture map onto their chosen surface (each surface can have a different texture). This projection (a four-component vector) is then stored per face.
In order to render a textured surface, the Quake software renderer (and QuakeDS) compute these texture co-ordinates at run time (as in every single frame). GLQuake computes the co-ordinates at load time and store them alongside the vertex info.
The problem is that there are a few textures - for instance the Quake logo in the entrance hall and the skill level labels on the sides of the three teleporters - that have non-power-of-two sizes. For instance the Quake logo is 288x64. The designers exploit the fact that the software renderer allows texture wrapping, and often the co-ordinates that are generated don't lie in the range 0.0-1.0 - again the Quake logo has one of it's corners at (-1.778, 5).
So what can I do with this on the DS? I've tried lots of solutions which involve adjusting the UVs to fit into 0.0-1.0, but I can't think of anything which would allow you to draw a quad with co-ords (-0.5, -0.5) (0.5, -0.5) (0.5, 0.5) (-0.5, 0.5).
OpenGL won't allow a texture of 288x64, so GLQuake resamples the texture (ie it stretches it) up to 512x64 and when it generates its texture co-ordinates (at load time) it does some divides to make sure the co-ords are correct.
Does anyone have any suggestions of what I ought to do?
Bear in mind,
- there's not enough memory to pre-generate texture co-ordinates, so it needs to be done at runtime
- textures are loaded from disk on an as-needed basis (ie deferred loading), so any resizing would need to be done per-load or on first-load then stored to disk...
I'm not a graphics person, so I'm not too familiar with dealing with these sorts of problems :-D
_________________
Big thanks to everyone who donated for Quake2
In Quake, brush models (eg the world itself and ammo packs, not guns, rockets or players) have their meshes stored as a set of vertices, and the faces to be drawn are extracted from the bsp system at runtime to minimise overdraw etc etc. However to save on memory (I think...) texture co-ordinates are not stored - instead the level designer 'projects' their chosen texture map onto their chosen surface (each surface can have a different texture). This projection (a four-component vector) is then stored per face.
In order to render a textured surface, the Quake software renderer (and QuakeDS) compute these texture co-ordinates at run time (as in every single frame). GLQuake computes the co-ordinates at load time and store them alongside the vertex info.
The problem is that there are a few textures - for instance the Quake logo in the entrance hall and the skill level labels on the sides of the three teleporters - that have non-power-of-two sizes. For instance the Quake logo is 288x64. The designers exploit the fact that the software renderer allows texture wrapping, and often the co-ordinates that are generated don't lie in the range 0.0-1.0 - again the Quake logo has one of it's corners at (-1.778, 5).
So what can I do with this on the DS? I've tried lots of solutions which involve adjusting the UVs to fit into 0.0-1.0, but I can't think of anything which would allow you to draw a quad with co-ords (-0.5, -0.5) (0.5, -0.5) (0.5, 0.5) (-0.5, 0.5).
OpenGL won't allow a texture of 288x64, so GLQuake resamples the texture (ie it stretches it) up to 512x64 and when it generates its texture co-ordinates (at load time) it does some divides to make sure the co-ords are correct.
Does anyone have any suggestions of what I ought to do?
Bear in mind,
- there's not enough memory to pre-generate texture co-ordinates, so it needs to be done at runtime
- textures are loaded from disk on an as-needed basis (ie deferred loading), so any resizing would need to be done per-load or on first-load then stored to disk...
I'm not a graphics person, so I'm not too familiar with dealing with these sorts of problems :-D
_________________
Big thanks to everyone who donated for Quake2