Calculating Point Normals in Vex

   3917   1   1
User Avatar
Member
101 posts
Joined: Dec. 2012
Offline
Just for learning purposes I would like to replicate the ‘facet’ nodes ‘post compute normals’. In theory it would be the cross-product of the points shared by a plane. Does anyone have a snippet that showcases that?
Edited by schiho - March 14, 2018 14:41:38
User Avatar
Member
8592 posts
Joined: July 2007
Offline
obviously you can just type
v@N;
in a fresh point wrangle and you'll get automatic normals, but that's probably not much to learn from

also, best way to learn is to try solving it yourself
but if you want an easy way, you can do this for example to do averaged nonweighted normals
int prims[] = pointprims(0, @ptnum);
vector sumN = 0;
foreach (int prim; prims) sumN += prim_normal(0, prim, .5, .5);
v@N = normalize(sumN / len(prims) );
Tomas Slancik
FX Supervisor
Method Studios, NY
  • Quick Links