Hello.
I have this problem where I want to calculate the gradient of the texture coordinates of a 2D triangle. I have:
- three 2D positions XY for each vertex of the triangle, in screen pixels.
- three 2D texture coordinates ST for each vertex of the triangle, in the range [0-1].
I want to calculate the gradient along X and Y for the texture coordinates, but I can’t remember how to do that from my linear algebra classes, and my Google-fu is failing me. In other words, what’s the change in the texture coordinates when I go one pixel to the right (dFdx) or one pixel up (dFdy)?
The ultimate goal is to derive a function F(XY) = ST, so that I can calculate the texture coordinates of any pixel on the screen quickly (even points outside the triangle). It will have the form F(XY) = XdFdx + YdFdy + offset, with the 2D offset being possible to calculate once I have dFdx and dFdy.