Jump to content


- - - - -

Interpolation on a 3D triangle using Normals?

Triangle Normal

9 replies to this topic

#1 Memnarch

    New Member

  • Members
  • Pip
  • 6 posts

Posted 03 December 2011 - 12:40 AM

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/...f6f0a2,9d2057d2


Greetings
Memnarch

#2 Reedbeta

    DevMaster Staff

  • Administrators
  • 5307 posts
  • LocationSanta Clara, CA

Posted 03 December 2011 - 01:35 AM

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?
reedbeta.com - developer blog, OpenGL demos, and other projects

#3 Memnarch

    New Member

  • Members
  • Pip
  • 6 posts

Posted 03 December 2011 - 03:03 PM

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)

#4 Memnarch

    New Member

  • Members
  • Pip
  • 6 posts

Posted 03 December 2011 - 07:19 PM

Nobody an Idea? :(

#5 Reedbeta

    DevMaster Staff

  • Administrators
  • 5307 posts
  • LocationSanta Clara, CA

Posted 03 December 2011 - 08:03 PM

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

Page 1
Page 2
Page 3
Page 4
Page 5
Page 6
Page 7
Page 8

This might be the post you're referring to (on page 3):

Nick said:

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.

reedbeta.com - developer blog, OpenGL demos, and other projects

#6 Memnarch

    New Member

  • Members
  • Pip
  • 6 posts

Posted 03 December 2011 - 09:22 PM

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...-rasterisation/

Thanks for your effort.

Its working :D

Posted Image

Still running slow, but i'll optimize later^^

#7 Enthusiastic for Sense

    New Member

  • Members
  • PipPip
  • 39 posts

Posted 03 January 2012 - 08:17 AM

Quote

Now, the equation of a 3D plane is generally:

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

Care to explain how or why?

#8 Reedbeta

    DevMaster Staff

  • Administrators
  • 5307 posts
  • LocationSanta Clara, CA

Posted 03 January 2012 - 08:37 PM

Enthusiastic, just google "plane equation" and you'll find plenty of articles about that.
reedbeta.com - developer blog, OpenGL demos, and other projects

#9 Enthusiastic for Sense

    New Member

  • Members
  • PipPip
  • 39 posts

Posted 04 January 2012 - 07:35 AM

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

http://uploadpic.org...?img=UdhtxKljaH

#10 geon

    Senior Member

  • Members
  • PipPipPipPip
  • 939 posts

Posted 04 January 2012 - 01:19 PM

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.





1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users