Textures messed up! (Scaled)

Started by
25 comments, last by Riddle 18 years, 9 months ago
Hello! I currently have a problem I can't solve. All my textures are somehow suddenly scaled down: Image Hosted by ImageShack.us The textures look fine if I scale my objects for around 1.89! What do you guys think could be the problem? Should I post my texture loading code? I checked the modelview matrix before I was rendering the object above: 1, 0, 0, 0 0, 1, 0, 0 0, 0, 1, 0 0, 0, 0, 1 -> identity! Please help me, thank you!
Advertisement
Could it be that you are using low-res render target? Window size doesn't matter, after all.

Or it could be, that it's using some low-level mipmap. In orthogonal mode it is possible. Render settings may be of use.

Just a thought...
/def

// Posting more code? Why not.
Hi!

I added:
Gl.glTexParameteri( Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR );
Gl.glTexParameteri( Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR );

to my loading code. If my objects are in identity mode then they look fine.
But If I rotate:

Image Hosted by ImageShack.us

Quite ugly.. Is this normal?

Thank you!


Some setup settings(scaled down to GL commands):

glViewport( 0, 0, window.Width, window.Height );

Gl.glMatrixMode( Gl.GL_PROJECTION );
Gl.glLoadIdentity();
Gl.glOrtho( 0.0f, window.Width, window.Height, 0.0f, -1.0f, 1.0 );

Gl.glEnable( gl.GL_BLEND );
Gl.glBlendFunc(Gl.GL_SRC_ALPHA, Gl.GL_ONE_MINUS_SRC_ALPHA);

Texture loading(scaled down to the used textures):Gl.glTexParameteri( Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAX_LEVEL, 0 );// New:Gl.glTexParameteri( Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MIN_FILTER, Gl.GL_LINEAR );Gl.glTexParameteri( Gl.GL_TEXTURE_2D, Gl.GL_TEXTURE_MAG_FILTER, Gl.GL_LINEAR );Gl.glTexImage2D( Gl.GL_TEXTURE_2D,		 0,		 hasAlpha ? Gl.GL_RGBA8 : Gl.GL_RGB8,		 width, height, 0,		 this.GLPixelFormat, Gl.GL_UNSIGNED_BYTE,		 data );
Quote:Original post by Riddle
to my loading code. If my objects are in identity mode then they look fine.
But If I rotate:
[...]
Quite ugly.. Is this normal?


Seeems fine to me - not ugly at all. If you're using same render-target resolution as the size of the texture, it WILL BE somewhat screwed.

Quote:
Gl.glOrtho( 0.0f, window.Width, window.Height, 0.0f, -1.0f, 1.0 );


Ortho from -1.0 to 1.0? If you're placing the textured object at depth 0.0, it's relatively far from the viewer, and I wouldn't be surprised if a mipmap was used. Why don't just use (0.0, 1.0)?

Cheers.
/def
Quote:
Seeems fine to me - not ugly at all. If you're using same render-target resolution as the size of the texture, it WILL BE somewhat screwed.


When I rotate the object there are some moving lines in the texture... This is not so pretty. But normal? Okay! There is also no difference with different resolutions.

Quote:
Ortho from -1.0 to 1.0? If you're placing the textured object at depth 0.0, it's relatively far from the viewer, and I wouldn't be surprised if a mipmap was used. Why don't just use (0.0, 1.0)?

Cheers.
/def


No difference between (0.0, 1.0) and (-1.0 to 1.0). But this is because
my objects don't have a depth value atm. Just one question: Do my object scale
with the above ortho projection when they have different depth(z) values?


Thank you! r++
Quote:Original post by deffer
Quote:
Gl.glOrtho( 0.0f, window.Width, window.Height, 0.0f, -1.0f, 1.0 );


Ortho from -1.0 to 1.0? If you're placing the textured object at depth 0.0, it's relatively far from the viewer, and I wouldn't be surprised if a mipmap was used. Why don't just use (0.0, 1.0)?

Cheers.
/def


A mipmap is only used if the screensize if different. It shouldn't be used if it's just far away.

In ortho mode objects will not be scaled if they are far away.
Quote:Original post by Riddle
There is also no difference with different resolutions.


Now this is NOT normal(at least not desirable). It's got to be a little screwed, but with high-res, it should be a smooth and "antialiased-like". Try experimenting a little with LINEAR_MIPMAP_LINEAR. Or post a high-res screen-shot.

Quote:
Just one question: Do my object scale with the above ortho projection when they have different depth(z) values?


No, as when Z column is (0,0,1,0), final z-value is equal to original z-value.

EDIT: @rick_appleton is right, being far away is not a reason for the card to use mipmap, it's being minimized, which doesn't happen in this case.
Quote:
Now this is NOT normal(at least not desirable). It's got to be a little screwed, but with high-res, it should be a smooth and "antialiased-like". Try experimenting a little with LINEAR_MIPMAP_LINEAR. Or post a high-res screen-shot.


Ah! YOu are right.. I thought you mean the size of my render window.

Quote:
No, as when Z column is (0,0,1,0), final z-value is equal to original z-value.


Good! So I can use the Z value for depth sorting? And the Z value must be in range
znear, zfar of the ortho mode to be drawn?


My objects are still ugly when I rotate them. The strange moving lines..


Thanks again,
Riddle.
Quote:Original post by Riddle
My objects are still ugly when I rotate them. The strange moving lines..

(Gosh, this really seems to me like a problem with jumping texels, but since you're using GL_LINEAR... ugh, my head...)

Give some more info:
- texture size
- render target size
- window size

Quote:
And the Z value must be in range znear, zfar of the ortho mode to be drawn?

It's "near and far clipping plane", so, yeah, unless you do not have depth-test enabled.

Quote:
So I can use the Z value for depth sorting?

GPU does that for you, so why would you do that by hand? Only if you're doing some tricky blending, like in particle systemZ.
/def
Quote:
Give some more info:
- texture size
- render target size
- window size


128/128
128/128
800/640 ( Same problem with all resolutions )

You see the lines in this picture:
Image Hosted by ImageShack.us

They rotate and move as I rotate my object. Looks really irritating!



Quote:
It's "near and far clipping plane", so, yeah, unless you do not have depth-test enabled.
GPU does that for you, so why would you do that by hand? Only if you're doing some tricky blending, like in particle systemZ.


Yes, I understand.

Thanks!

[Edited by - Riddle on June 24, 2005 5:02:20 PM]

This topic is closed to new replies.

Advertisement