PDA

View Full Version : textures

I_like_coca_cola
05-03-2003, 05:01 AM
Hi

Dumb question..
I want to scale a rectangular texture around it's center for screen rendering stuff, but im not able to do it (it must be really simple, but i don't get the solution..)

In square textures/d3d its simple, (texcoords-0.5)*scale+0.5

I've tried lots of ways with rectangular textures, but doenst work.

This should work, (texcoords-0.5*texcoords)*scale+0.5*texcoords, i think.

I doens't make any sense !

Need help http://www.opengl.org/discussion_boards/ubb/smile.gif

tks
I like coca cola !

I_like_coca_cola
05-03-2003, 05:10 AM
Btw, i meant to say non-power of 2 rectangular textures http://www.opengl.org/discussion_boards/ubb/smile.gif

tks
I really like coca cola!

Keenan Crane
05-03-2003, 06:33 AM
I'm not exactly sure what you mean, but try this - if your rectangle looks like this where the ordered pairs are the texture coordinates

(tx1, ty1) ------------------ (tx2, ty1)
| |
| |
| |
| |
| |
| |
(tx1, ty2) ------------------ (tx2, ty2)

then you would have

tx1 = (s - 1.0)/(2.0 * s);
ty1 = (s - 1.0)/(2.0 * s);
tx2 = (s + 1.0)/(2.0 * s);
ty2 = (s + 1.0)/(2.0 * s);

where s is your scaling factor (the bigger s is, the more zoomed-in on the texture you are).

Hope this helps,

Keenan Crane
kcrane@uiuc.edu

cass
05-03-2003, 06:57 AM
Originally posted by I_like_coca_cola:
In square textures/d3d its simple, (texcoords-0.5)*scale+0.5

I've tried lots of ways with rectangular textures, but doenst work.

This should work, (texcoords-0.5*texcoords)*scale+0.5*texcoords, i think.

Hi I_like_coca_cola,

Scaling about the center (whether using normalized or unnormalized coordinates) can always be done with:

new_coord = (coord - texsize/2) * scale + texsize/2

For normalized coordinates, texsize/2 is always 1/2 (or 0.5).

In your equation for unnormalized coordinates, you seem to be using "coord" in 2 places where you need "texsize/2".

Thanks -
Cass

I_like_coca_cola
05-03-2003, 01:56 PM
Dammm,

As i imagined, solution was super simple...
Shame on me !

tks Cass ! you're the man http://www.opengl.org/discussion_boards/ubb/wink.gif

cya
Coca Cola rulez