Monday, 9 December 2024

Added a Smooth Normals Slide Bar

Angle between normal of adjacent faces using the dot product:
dot(n1,n2)=∣n1∣⋅∣n2∣⋅cos⁡(θ)
dot(n1​,n2​)=∣n1​∣⋅∣n2​∣⋅cos(θ)
Dot Product and Angle - https://mathinsight.org/search/?q=dot+product
Vector Normalization - https://en.wikipedia.org/wiki/Unit_vector
OpenGL: Normals - https://learnopengl.com/Lighting/Basic-Lighting
Wikipedia: Normal - https://en.wikipedia.org/wiki/Normal_(geometry)
OpenGL : Smooth Shading - https://www.opengl.org/archives/resources/faq/technical/
Blender Manual: Auto Smooth - https://docs.blender.org/manual/en/latest/modeling/modifiers/normals/smooth_by_angle.html

glm::vec3 n1(1.0f, 0.0f, 0.0f); // Normal vector 1
glm::vec3 n2(0.0f, 1.0f, 0.0f); // Normal vector 2
float dotProduct = glm::dot(n1, n2); // Dot product
float magnitudeN1 = glm::length(n1); // Magnitudes
float magnitudeN2 = glm::length(n2);
float cosTheta = dotProduct / (magnitudeN1 * magnitudeN2);// Cosine of the angle
float angle = glm::degrees(std::acos(cosTheta));// Angle in degrees

No comments:

Post a Comment