Hi Sebastian,

Well, no my rasterizer (which might be a piece of trash...) is a scanline rasterizer…

So, for the following triangle:

A

x

xx

xxx

xxxx

xxxxx

xxxxxx

xxxxxxx

B C

I know the left gradient, and the right gradient… Problem is that the position gradient of AC (for example) is something like scalar*(sqrt(2)/2,sqrt(2)/2) and not the “down” scalar*(0,1) gradient I’d like… The horizontal gradient works allright, since I’m interpolating between the spans…

As far as I understand the problem, the issue is that for every pixel, I know how to reach the next horizontal lumel (which is one of the things I need), and on the edges, I know how to go to the next lumel on the edge (which most of the time doesn’t match the actual “down” position I need).

For communication purposes, I’m calling the “down” position to the world-relative vector that takes me from the position of the current lumel, to the one that’s right below it in UV space… The “next horizontal lumel” is the one that’s right to the right of the current one in UV space.

Don’t know if this was clear enough, I’m starting to have a hard time getting my head around the problem (maybe too close to it by now)…

Best regards,

Diogo

**From:** Sebastian Sylvan [mailto:sebastian.sylvan@gmail.com] **Sent:** sexta-feira, 4 de Fevereiro de 2011 11:48**To:** Game Development Algorithms**Subject:** Re: [Algorithms] Texel area

On Fri, Feb 4, 2011 at 10:50 AM, Diogo de Andrade <diogo.andrade@spellcasterstudios.com> 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