PDA

View Full Version : Problem Texturing with GL_TEXTURE_RECTANGLE



bucky
05-07-2008, 10:35 AM
I'm drawing a quad to the screen made up of a triangle strip and have a texture on this using GL_TEXTURE_RECTANGLE, everything looks fine until I move a point on the quad(say to stretch from the corner) the texture on the quad doesn't stretch 'properly', it looks as if it is stretching only 1 triangle of the triangle-stripped quad(the other side remains normal) and this effect happens even if i'm using a quad instead of a triangle strip. Is there limitations to using GL_TEXTURE_RECTANGLE in this way? obviously its not noticeable when the quad remains rectangular but is there some solution to this? I'm not using any normals for the quad but should this effect the texture anyways?

Thanks in advance

kingc8
05-07-2008, 01:13 PM
Someone else may jump right in and tell me I'm wrong but the word on the street is to avoid the GL_TEXTURE_RECTANGLE extension as its performance is ropey or the implementations out there are variable.

You would be fine using the usual GL_TEXTURE_2D even for none-square textures.

Can someone verify the veracity of that opinion?

Personally I use GL_TEXTURE_2D for all my rectangle needs except for OpenGL 1.0 hardware where a none-square texture comes out as a white rectangle.

bucky
05-07-2008, 01:21 PM
My hardware doesn't support non-power of 2 textures so its either this or blit my non power of 2 into a p-o-t texture with wasted space? but regarding my initial problem i guess its caused by the fact that even if you're rendering a quad that its broken down to 2 triangles when rendering so this kind of explains why i'm not getting the behavior i expect when i stretch a point out and see that only half of it is actually being stretched(texture-wise).

-NiCo-
05-07-2008, 03:15 PM
I believe you will experience the same problem whether you use texture rectangles or power-of-2 textures. The problem is that when you're moving the point, the area of the rectangle doesn't align with the texture area anymore, meaning that splitting the quad in to two triangles causes the texture coordinate derivatives to be non-continuous in screen space.

dorbie
05-07-2008, 04:32 PM
As nico says the issue is the linear interpolation within the triangles. It is similar to the issue of perspective correction (or rather the problems you see when you don't perspective correct).

When you grab a vertex what interpolation do you expect accross the quad? This does not have a known solution like a perspective warp, you're applying an arbirtary 2D warp to the coordinates.

You could try fudging the homogeneous vertices based on edge length but I don't think it will work for you. Subdiviaion of the mesh will probably give you the warp you're looking for.

bucky
05-08-2008, 07:34 AM
Thanks for the responses, I get whats happening now and will probably give the subdividing technique a try...another thing, is the performance and implementation of GL_TEXTURE_RECTANGLE really that sketchy that I should avoid using it as the second poster has suggested? If my hardware doesn't support non-power-of-two textures what are my other possible options?

bucky
05-08-2008, 12:31 PM
kingc8, actually I just tested out loading up and rendering a non-power-of-2 tex with GL_TEXTURE_2D and although it worked(my hardware supports 2.0 gl) it was horrendously slow, made my system crawl(ati firegl laptop) but when i used GL_TEXTURE_RECTANGLE everything's fine, what gives?

Seth Hoffert
05-08-2008, 12:41 PM
This is just a sign that your hardware doesn't support NPOT textures and dropped back to software, so you should just stick with a texture rectangle instead. :)

V-man
05-08-2008, 02:08 PM
If you want to know if it is hw accelerated, check the GL version, which should be 2.0 and above.
Then check to see if GL_ARB_texture_non_power_of_two exists.
If it exists : hw accelerated
If not : the driver emulates

Gf 6 and up support it.