Mapping Square Texture to Trapezoid / Quadrilateral

It turns out to be not a straightforward one. If you ever want to render trapezoid but mapped to square texture coordinate, i.e. (0,0) - (1,1), it won't turn out right.

Turns out there's an easy way to fix this. Basically, instead of passing in float2 texture coordinates, you need to pass in the third coordinate to do projection on texture coordinates.

The solution can be found here

Edit: It turns out, there's a more generic solution, i.e. quadrilateral interpolation:
Other references that might be useful:


Popular posts from this blog

GDC 2015 Links

D3D11 Compute Shader - Part 1