From: Olivier Galibert <galibert@po...>  20110204 19:51:26

On Fri, Feb 04, 2011 at 10:50:08AM 0000, Diogo de Andrade wrote: > So, what I want to do is, given > >  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 that's your real problem, the solution is reasonably simple and has nothing to do with the rasterization. You have three points when space/texture coordinates: (x0, y0, z0, u0, v0) (x1, y1, z1, u1, v1) (x2, y2, z2, u2, v2) Given u, v the position in texture space, you first want to find the barycentric coordinates (t1, t2):  u0 + t1*(u1u0) + t2*(u2u0) = u  v0 + t1*(v1v0) + t2*(v2v0) = v That's a rather usual linear system. Noting the inverse determinant di: di = 1/((v2v0)*(u1u0)  (u2u0)*(v1v0)) then:  t1 = di*((v2v0)*(uu0)  (u2u0)*(vv0))  t2 = di*((v1v0)*(uu0)  (u1u0)*(vv0)) >From these, you can easily find the world coordinates:  x = x0 + t1*(x1x0) + t2*(x2x0)  y = y0 + t1*(y1y0) + t2*(y2y0)  z = z0 + t1*(z1z0) + t2*(z2z0) You'll notice that all these are linear systems, which means a texel rectangle size is independant of its position. So you can get your vector once by computing the position differences between (0, 0), (0.5, 0) and (0, 0.5) for instance. You'll notice the equations simplify nicely when computing deltas if you do the math. I suspect it's not your real problem though, so feel free to correct it :) OG. 