-
-
Notifications
You must be signed in to change notification settings - Fork 35.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Raycaster: Add Interpolated Normals #25566
Conversation
Seems like this breaks (or changes the screenshot) |
Ahhh, perhaps the library they import from unpkg calls it. I've restored |
Co-authored-by: Levi Pesin <[email protected]>
Maybe not always all cubes there are able to appear in time... So maybe we should increase |
@gkjohnson This change is relevant for https://rawcdn.githack.com/mrdoob/three.js/dev/examples/webgl_geometry_csg.html |
@Mugen87 Should we add a temp bar to only log it once? |
Niiiice! Technically this should be a slerp, but that would be crazy expensive. I wonder if it should at least do a normalize after the interpolate. I think they call that a "nlerp". |
I considered it, but then I realized that models can technically have all kinds of crazy non-unit normals in some cases... I guess the debate is between the number of people who will stub their toes on non-unit normals vs. the number of people who will have to edit the engine to get them if they need them... (Also, I don't believe Slerp works on more than 2 components... but I suppose I could use the torque average from one of my favorite papers... https://matthias-research.github.io/pages/publications/stablePolarDecomp.pdf ) |
What kinds of models have non-unit normals? |
I believe some anime/toon shaded models warp/distort normals to achieve specific shading contours... Not sure who else ¯\_(ツ)_/¯ ; it's been a while since I've interacted with any technical artists... It might be worth the headache for them to normalize; feel free to open a PR with it xD |
I think it'll be better to not normalize until we get enough people bumping into that. |
It should probably be explicitly called out in the docs, then, that the "normal" vector will likely not be normalized even if all the vertex normals are since barycentrically interpolating three normalized vectors does not guarantee a normalized result. |
Yes, that makes sense. I'll file a PR. |
Since a normalization is cheap, I would add it to the code so we have a mathematical correct result. |
This PR exposes barycentrically interpolated/smoothed normal vectors in raycast intersection objects.
These normals are useful to have on hand when calculating accurate reflections in optical systems; helping to mitigate "the disco ball effect" that can come from flat facets.
You can see in this example scene I set up (attempting to mimic Paul Bourke's Mirror Dome):
https://raw.githack.com/zalo/three.js/feat-curved-reprojection-mirrordome/examples/webgl_materials_reprojection.html
Enable and Disable the
Use Interpolated Normals
checkbox to see the difference between normals from flat faces and normals from interpolating the normals attribute.