Re: [Algorithms] Texel area
Brought to you by:
vexxed72
From: Sebastian S. <seb...@gm...> - 2011-02-04 11:47:58
|
On Fri, Feb 4, 2011 at 10:50 AM, Diogo de Andrade < dio...@sp...> wrote: > Hi all! > > > > I've been struggling with a problem and I hope somebody can point me in the > right direction... > > I'm making a lightmap/ambient occlusion map generator system, and for that > I built a rasterizer that calls a function that does the computations and > fills the target image. > > The rasterizer works in UV space, but all parameters of the triangle are > interpolated. > > > > Now, I wanted to add multisampling, so that I don't get just a single > sample for the ambient occlusion, and I want to "jitter" the source point > (not only the raycast direction), > > and for that I need to find out what's the area of the target lumel. By > area, I mean not only the actual area value, but the "rectangle" that bounds > the lumel, in world space... > > > > 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)... > > > > I've been thinking about this, but can't seem to find an approach that > works correctly... I'm expecting some error in this calculation (due to the > rasterizing process itself), but it's not a big deal since it's for sampling > purposes, but even so I can't seem to make it work... > > > > So, if anyone got any links, keywords, or just a simple algorithm he > doesn't mind sharing, I'd appreciate it! > The interpolator in the rasterizer should already know the gradient for the position w.r.t. the pixel (i.e.lumel, in this case) position right? So you once you know the center position for a given pixel (lumel) it should be easy to compute the world space positions of the corners of that pixel (just take the position gradient multiplied by +/- 0.5pixels and add it to the center position), which gives you the quadraliteral in world space. -- Sebastian Sylvan |