(pre-)crop texture


is there any way of cropping a texture (say use only 100x100 of an 128x128 texture) without modifiyng geometry’s tex coords?
what i want seems kinda the same as add some prescaling for tex coords inside a texture objects’ state, glcontext state or maybe TexEnv but not inside the geometry/vertex-shader attributes.

thanks & greets

If your texture coordinates are in the 0.0 to 1.0 range for the 128*128 texture, use a texture matrix with a scale factor

100/128   0    0 0
   0   100/128 0 0
   0      0    1 0
   0      0    0 1

Be warned, you won’t be able to get the border handling right on the non-zero text coords, unless you use nearest filtering.
Repeating the texture will also not work. You could do that in a fragment shader by calculating the wrapping yourself.

i first made it obsolete by using NPOT rectangle textures but then figured out on radeon they are limited to be multiples of 32 in both axes leading to very strange results otherwise (damaged texture, if height don’t match TRASHED geometry DAMN that was looking crazy!)
so i need to clamp to multiples of 32 and need the croping anyway…
thanks a lot

on radeon they are limited to be multiples of 32 in both axes
Really? Shocking. That sounds broken. :eek:

Well, that was a driver bug in early FBO implementations, but it was fixed quite a while ago. It ought to be in public driver by now I think. The hardware definitely has no such limitation.

ok, tracked it down to mod 32 for width and mod 8 for height :slight_smile:

some better now… but still not solved.

my current driver is 6.14.0010.6561, about two months old, just one month older then the actuall released. the card is a X300 one.
now i try for newer drivers.

btw. i uploaded some example pics:

width NOT mod 32 results in this:
(the scene is rendered again by a low-res fullscreen quad NOT mod 32 for use of fragment shader post effect)

and, incredible strange, texture height of this NOT mod 8:
-with mod 8:
-likewise scene not mod 8:

kinda fun, huh?

thanks a lot

Well, try the latest driver and I bet the bug is gone.

You’re right :slight_smile:
Yeah, its gone.

that proofs we’re a real high tech commumity here :slight_smile: if something is older than a month its considered “absolutely outdated” and no one can complain about strange results…

thanks very much,

You should try working for an IHV. For me things sometimes feel outdated before it has even reached the public. :wink: