Handmade Hero»Forums»Code
44 posts
Neither affine nor perspective texturing of a trapezoid!
Edited by rizoma on

Hi guys I'm trying to get this result as a texture stretching on a 2d quad trapezoid.

effect.png

Seems that normally people use affine transforms only or just texture projection! How can I implement this on OpenGL?

Simon Anciaux
1337 posts
Neither affine nor perspective texturing of a trapezoid!

It's probably not what you want, but if you subdivide the quad enough the "seam issue" get less noticeable. Left is no subdivision, center is 10 subdivisions, right is 4 subdivisions.

trapezoid_checker.png

If you find how to do it "properly" I'm interested.

511 posts
Neither affine nor perspective texturing of a trapezoid!

do you want to only stretch the trapezoid or do you want actual perspective?

44 posts
Neither affine nor perspective texturing of a trapezoid!

Yeah I know that if you subdivide the geometry the problem "kind" of goes away, and I suppose that in the idea of doing distortion effects etc one ends up subdividing the "sprite" anyway. So it's indeed more of a <I'm looking for the "proper" way to do it>, even if I suspect that the real and useful way would be just to subdivide, since in the worst and probably more common situation you'd need more geometry as control points anyway to do something useful. Yet, one should quantify if this alleged "proper way" is more expensive than just adding the extra geometry needed.

I'll keep you updated if I find the time and the solution!

44 posts
Neither affine nor perspective texturing of a trapezoid!
Edited by rizoma on
Replying to ratchetfreak (#26266)

As the title suggests, I just want stretching!:)

At first I tried using textureProj and it just looked like a rotated quad.