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
tks
I like coca cola !
Btw, i meant to say non-power of 2 rectangular textures
tks
I really like coca cola!
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
May 3, 2003, 6:57am
4
Originally posted by I_like_coca_cola:
[b]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.
[/b]
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
Dammm,
As i imagined, solution was super simple…
Shame on me !
tks Cass ! you’re the man
cya
Coca Cola rulez