![]() |
| [[ Home | Forums | 3D Engines Database | Wiki | Articles/Tutorials | Game Dev Jobs | IRC Chat Network | Contact Us ]] |
|
|
#1 |
|
DevMaster Staff
Join Date: Sep 2003
Location: Hell
Posts: 1,109
|
Just thought I'd post something small.
Given a list of vertices and a list of indices.. Code:
|
|
|
|
|
|
#2 |
|
Valued Member
Join Date: Aug 2004
Location: Norway
Posts: 200
|
I'm new here but I remember
http://www.devmaster.net/forums/index.php?showtopic=414 It's a very nice way to calculate vertex normals fast thought. However, that vertex normals should be the average of the connecting triangle normals is purely speculative though. There is a paper that compares different methods for computing vertex normals somewhere (www.google.com and citeseer are our friends), but IIRC they didn't find any "best" solution, but I think averaged normals was good in general (might been weighted average (?)). Anyways, to get weighted average based on triangle areals, simply don't normalize triangle normals before adding them (and then continue as bladder does)... just my 0.02kr. -Si |
|
|
|
|
|
#3 |
|
New Member
Join Date: Oct 2004
Posts: 5
|
There seems to be a bug in this example, as well as an optional optimization.
1) The code averages the normals, but doesn't renormalize ( this is the bug ). 2) There is no need to average normals, just sum them up, and then instead of dividing by the # of normals, simply renormalize. This way you avoid doing two divides, one by the # of normals, and the other by the normal length squared. |
|
|
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
|