0
101 Dec 03, 2011 at 00:40 triangle

Hi,
Currently rewriting my old Rasterizer based on Nicolas Capens Half-Space Rasterizer.
In one of his comment(which is not accessible atm) he showed and example on how to interpolate any given value on the 3D Triangle face using normalvector. Because i lost some of my source, this part is gone, too.

Googled the whole day, but it seemed i missed it. Maybe someone here knows/rememberes how it worked? Its been a long time…since i have worked on my rasterizer.

Link to Cached Post of Nicolas:

http://cc.bingj.com/cache.aspx?d=4568179128665439&w=92f6f0a2,9d2057d2

Greetings
Memnarch

#### 9 Replies

0
165 Dec 03, 2011 at 01:35

Are you sure it was using the normals? That doesn’t make much sense to me. Interpolation of values on triangles is usually done with barycentric coordinates. The depth, normals, UVs, and any other attribute can be interpolated this way. Maybe you’re misremembering?

0
101 Dec 03, 2011 at 15:03

If i remember correctly, he used the normals to calculate a step value. By adding this step after each cycle, you got the Barycentric coordinate.

Sofar, if iam misremembering, any tip on how to interpolate the Barycentric coordinates without calculating the 3 subtriangles everytime?(avoiding to much calculation per pixel)

0
101 Dec 03, 2011 at 19:19

Nobody an Idea? :(

0
165 Dec 03, 2011 at 20:03

OK, with a little googling I was able to track down all the pages of that thread in the google cache.

This might be the post you’re referring to (on page 3):
@Nick

The easiest and most robust way is to use the plane equation.

Let’s say we want to interpolate some component z linearly across the polygon (note that z stands for any interpolant). We can visualize this as a plane going through the x, y and z positions of the triangle, in 3D space. Now, the equation of a 3D plane is generally:

A * x + B * y + C * z + D = 0

From this we can derive that:

z = -A / C * x - B / C * y - D

Note that for every step in the x-direction, z increments by -A / C, and likewise it increments by -B / C for every step in the y-direction. So these are the gradients we’re looking for to perform linear interpolation. In the plane equation (A, B, C) is the normal vector of the plane. It can easily be computed with a cross product.

Now that we have the gradients, let’s call them dz/dx (which is -A / C) and dz/dy (which is -B / C), we can easily compute z everywhere on the triangle. We know the z value in all three vertex positions. Let’s call the one of the first vertex z0, and it’s position coordinates (x0, y0). Then a generic z value of a point (x, y) can be computed as:

z = z0 + dz/dx * (x - x0) + dz/dy * (y - y0)

Once you’ve computed the z value for the center of the starting pixel this way, you can easily add dz/dx to get the z value for the next pixel, or dz/dy for the pixel below (with the y-axis going down).

I hope this helps! Don’t hesitate to ask for further clarification.

0
101 Dec 03, 2011 at 21:22

Wow, thanks :).
Yes thats the post, and as you noted before: normals are wrong :P.

Meanwhile i found this(Which focuses on the same):

http://www.acunliffe.com/index.php/2011/10/triangle-rasterisation/

Thanks for your effort.

Its working :D

Still running slow, but i’ll optimize later\^\^

0
101 Jan 03, 2012 at 08:17

Now, the equation of a 3D plane is generally: A * x + B * y + C * z + D = 0

Care to explain how or why?

0
165 Jan 03, 2012 at 20:37

Enthusiastic, just google “plane equation” and you’ll find plenty of articles about that.

0
101 Jan 04, 2012 at 07:35

Okay, I did.

And under what law should I care to follow the mathematical operations given to provide an “ideal” measurement of something in a space from an already generated “perspective” of how it works?

I can tell you that a Nivotyev Lokiq is 3 * 44 \^ *33 + X.

What is X? Nobody knows but me because I made it up to represent something in MY head.

How do you understand it? By listening to what I tell you.

Nivotyev Lokigs are something I made up as well and you MUST understand that 3 * 44 \^ *33 + X = a polygonal, six-faced 3-point lighted scale of a Nivotyev Lokig.

Accept or you’ll never learn.

Also, it is stored in Pomerazquep memory. Memory in circles. Don’t ask, just accept it.

Not accepting? Never will learn what I tell you then and you’ll never work for me or succeed in Nivotyev programming logic.

|
|
v

0
101 Jan 04, 2012 at 13:19

Enthusiastic, what’s your point? If you find some article, that’s incomprehensible, just search until you find one that you can understand. There is plenty of great material on the interwebz.

If you still can’t understand, you might need to brush up on the mathematics behind it.