Support rectangle textures
|Assignee:||Mike Wozniewski||% Done:||
Non-power of two rectangle textures are necessary when dealing with real-world video resolutions, such as 640x480 and 1920x1080. If using non-rectangle power-of-two textures, it is simply impossible to get the right one-to-one ratio between input and output pixels.
According to a post in the thread http://www.gamedev.net/topic/404768-square-vs-rectangular-textures/ :
"if they are deemed neccessary, by all means, use them"
Updated by Mike Wozniewski about 1 year ago
Can you clarify the exact problem? SPIN fully supports non-power of two textures (NPOT). By default, when SPIN loads an ImageTexture with non-power of two resolution, it resizes it to the nearest power-of-two. Then it doesn't need to use any ARB extensions. For VideoTexture and especially for SharedVideoTexture, it's too expensive to resize the image each frame, so the resizing is turned off. See setResizeNonPowerOfTwoHint(). Then, we rely on OpenGL extensions on newer graphics cards: http://www.opengl.org/registry/specs/ARB/texture_rectangle.txt
Certain things won't work: mipmapping, texture repeat, etc. But this is the price for fast, NPOT textures.
Unless... Do you mean use TextureRectangle instead of Texture2D? I suppose this could make shader coding easier (ie, being able to address pixels by number).
However, using TextureRectangle will imply that texture coordinates for existing geometry won't be correct anymore, and we won't be able to swap non-normalized statesets (shaders) with normalized ones. I think it should be an option (and I've started prototyping this with ImageTexture - see latest commit). But, I think we should try to use one standard and write all shaders and create all models with that standard in mind.
Updated by Alexandre Quessy about 1 year ago
Yes, use TextureRectangle instead of Texture2D.
As far as I know, it allows arbitrary size textures, whereas Texture2D doesn't.