Sign in to follow this  

NPOT reliable?

This topic is 3407 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I'm trying to render a NPOT texture in ortho mode in its original dimensions, and I'm getting some distortion. (You can see some distortion around the '2' and '6'). My graphics card supports the extension GL_ARB_texture_non_power_of_two, so I am rendering the texture normally as I would any other texture. I use GL_TEXTURE_2D, GL_NEAREST, and GL_CLAMP_TO_EDGE to set it up. When I pad the texture myself to powers of 2, this distortion disppears. But I shouldn't have to do this myself if my card supports NPOT textures. Just wondering if anyone else has experience the same problem with NPOT textures.

Share this post


Link to post
Share on other sites
it shouldnt do that,
is the texture mipmapped? (though dont see what difference that could make in ortho projection)
perhaps try rendering the texture at both twice + half the resolution, is the problem still there?
if not perhaps post on opengl.org with a report of what card/drivers youre using

Share this post


Link to post
Share on other sites
Nope, it's not using mipmaps.

I want to render a NPOT texture in its original dimensions, with no stretching, no filtering, no distortion, etc...

I use this to load it:


glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, textureID );

glTexImage2D( GL_TEXTURE_2D, 0, GL_RGBA8, w,h, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer );

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST );

glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE );

// rendering
glBegin(GL_POLYGON);
glNormal3f( 0.0f, 0.0f, 1.0f );

glTexCoord2i( 0,0 );
glVertex2i( 0,0 );

glTexCoord2i( 0,1 );
glVertex2i( 0,h );

glTexCoord2i( 1,1 );
glVertex2i( w,h );

glTexCoord2i( 1,0 );
glVertex2i( w,0 );
glEnd();

Share this post


Link to post
Share on other sites
I used to see all kinds of crazy stuff like that when the nvidia control panel settings had the image quality set to high performance. I wasted like a week messing with my code because all my GUI elements were looking shitty, and I thought I was at fault. The slider fixed it all.

Share this post


Link to post
Share on other sites
Quote:
Original post by Daaark
I used to see all kinds of crazy stuff like that when the nvidia control panel settings had the image quality set to high performance. I wasted like a week messing with my code because all my GUI elements were looking shitty, and I thought I was at fault. The slider fixed it all.

You might have something there. But, as far as I know, I'm using all default settings in the Nvidia control panel. I haven't made any changes
myself since I installed the driver.


Image settings is set to: "Let the 3D application decide"

Anisotropic filtering: Application-controlled
Anisotropic mip filtering optimization: Off
Anisotropic sample optimization: On
Antialiasing settings: Application-controlled
Conformant texture clamp: Use hardware
Extension limit: Off
Force mipmaps: None
Gamma correct antialiasing: Off
Hardware Acceleration: Multiple display performance mode
Negative LOD bias: Allow
Texture filtering: Quality
Transparency antialiasing: Off
Trilinear optimization: On
Triple buffering: Off
Vertical sync: Use the 3D application setting

Share this post


Link to post
Share on other sites
Would say it's a so called "precision issue" of the hardware. I've encountered exactly the same shitty glitches in a same scenario, unlike in a D3D10 context (using the Load intrinsic, no filter, no mipmap) and on a NV Quadro FX4600.

I did almost the same bypass as you, forcing my texel fetchs to be POTish when generating my screen aligned quad in my geometry shader (then discarding extra fragments with Discard intrinsic in my pixel shader).

That's all... I'm still waiting for doing some more tests on different IHVs boards or drivers...

Share this post


Link to post
Share on other sites
I added these lines, thinking they might help with NPOT texture widths:


glPixelStorei( GL_UNPACK_ALIGNMENT, 1 );
glPixelStorei( GL_PACK_ALIGNMENT, 1 );
glPixelStorei( GL_UNPACK_ROW_LENGTH, (INT)w );
glPixelStorei( GL_PACK_ROW_LENGTH, (INT)w );


But, nope, it didn't work. Still the same.

Share this post


Link to post
Share on other sites
Quote:
Original post by rosewell
I want to render a NPOT texture in its original dimensions, with no stretching, no filtering, no distortion, etc...


Did you try using the GL_ARB_texture_rectangle extension instead?

Share this post


Link to post
Share on other sites
u shouldnt be using int types eg
glTexCoord2i( 0,1 ); use 2f(0,1);
for one thing I believe u will fall off the fast path.

also theres perhaps rounding errors have a look at opnegl.org in the faq I believe theres info there on how to set up 1:1 mapping

Share this post


Link to post
Share on other sites
Quote:
Original post by zedz
u shouldnt be using int types eg
glTexCoord2i( 0,1 ); use 2f(0,1);
for one thing I believe u will fall off the fast path.

also theres perhaps rounding errors have a look at opnegl.org in the faq I believe theres info there on how to set up 1:1 mapping


I was going to suggest that to, but I give up on telling people just to use floats for all their GL code...

Share this post


Link to post
Share on other sites
Well, I don't believe it, but glTranslatef( 0.375f, 0.375f, 0.375f ); worked!
I was previously using glTranslatef( 0.5f, 0.5f, 0.5f ), so I did not think there was anything wrong with it.

And why a powers2 padded texture worked vs. using a non-padded NPOT texture, I have absolutely no idea.

Thanks!

Share this post


Link to post
Share on other sites

This topic is 3407 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this