greggman / twgl.js

A Tiny WebGL helper Library
http://twgljs.org
MIT License
2.67k stars 260 forks source link

perspective transform (quad warp) #109

Open julapy opened 5 years ago

julapy commented 5 years ago

hi, couldn't find any info in the docs so thought id post here.

looking for an implementation of the below in TWGL: https://github.com/jlouthan/perspective-transform taking 4 points of a rectangular quad and transforming them to match 4 points of another irregular quad. quad to quad as some libraries call it... also sometimes called quad warping.

wondering if there is some utility function that can do this? id like to save some time porting this if possible.

greggman commented 5 years ago

There's nothing in twgl to do that.

greggman commented 5 years ago

I don't know what you were trying to do but I found this article

http://www.reedbeta.com/blog/quadrilateral-interpolation-part-1/

and used to make this

https://jsfiddle.net/greggman/s68vfden/

greggman commented 5 years ago

Also there's this

https://jsfiddle.net/greggman/g4bwu68k/

julapy commented 5 years ago

@greggman thanks, thats exactly it!

greggman commented 5 years ago

which one were you looking for? The JS one (just map points) or the WebGL one (draw a texture)?