Jonny Flynn
jflynnxyz
About Me
Connect
LOCATION
Not Specified
WEBSITE
Houdini Skills
Availability
Not Specified
Recent Forum Posts
How to do face weighted normals in Houdini? Oct. 4, 2022, 7:06 a.m.
The calculations provided don't give the completely desired result: to have the vertex normals facing the direction of the largest face.
Taking the largest isn't always the desired case though, primarily for corner pieces they should take into account all the faces as they are the same size.
The best way is to take the weighted normals of all the faces and use the faces above a certain area threshold compared to the largest face(I use 0.666) so as you approach a more even shape the normals will revert back to being a face average
Here is my code for that:
Taking the largest isn't always the desired case though, primarily for corner pieces they should take into account all the faces as they are the same size.
The best way is to take the weighted normals of all the faces and use the faces above a certain area threshold compared to the largest face(I use 0.666) so as you approach a more even shape the normals will revert back to being a face average
Here is my code for that:
vector nml = { 0, 0, 0 }; vector offsets[]; float lengths[]; // iterate over each primitive that references the current point foreach(int pr; pointprims(@OpInput1, @ptnum)) { // use the primitive's area as its weight in the weighted sum float w = primintrinsic(0, “measuredarea”, pr); vector offset = w * prim_normal(@OpInput1, pr, 0.5, 0.5); // accumulate the primitve's normal at the primitive's center scaled by the weight append(offsets, offset); append(lengths, w); } float mx = max(lengths); for (int i=0; i<len(offsets); ++i) { float ratio = lengths[i] / mx; if (ch("snap") < 1 || ratio >=ch("tolerance")) { nml += offsets[i]; } } vector N = normalize(nml); v@N = N;