Re: [Algorithms] Texel area
Brought to you by:
vexxed72
From: Manuel M. <m.m...@wa...> - 2011-02-04 20:03:18
|
Hi Diogo, > - triangle T=(V1,V2,V3), in which V1, V2, V3 are vertexes that have some > properties (world space position, normal, diffuse color, texture > coordinates 0 (in uniform space), texture coordinates 1 (in texture space, > [0..texture size[), etc), > > - texture size > > - position inside the triangle (absolute value in texture space) > > > > is to find out the rectangle that bounds the texel in world space (origin+2 > vectors)... if I understand your setup correctly, you're dealing with a linear transform (from a plane in UV-space to a plane in world space), so the partial derivatives with respect to u and v are constants across the triangle. If this is not too much setup overhead, you could proceed by finding the world space directions U and V corresponding to the u/v axes for the triangle by solving for a 3x2 matrix with the world-space-directions U and V as columns: matrix(U V) * (A-B) = A.worldpos - B.worldpos matrix(U V) * (B-C) = B.worldpos - C.worldpos where A, B are 2D u/v coordinates (in pixel units). cheers, Manuel |