Skip to content
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

Calculate per-vertex smoothTangent and keep smooth normals #2068

Closed

Conversation

SinanAkkoyun
Copy link
Contributor

The calculateSmoothTangent previously built the tangent space transformation matrix based upon the geometry plane only. With smooth shaded meshes, each triangle has a per-vertex normal in contrast to a per-face normal. Each normal not necessarily matches with the geometric face normal, which allows shaders to lerp between normals to create an artificial smoothness of the rendered mesh with the same amount of polygons.

With this PR, the built T and B now lie within the per-vertex smooth normal and not within the geometric normal.
image
(The black arrow represents the geometry normal)
This is achieved by projecting the geometry points (P0, P1, P2) onto the plane of the smooth per-vertex normal plane (green) for the tangent space calculation.

The tangent space was previously also calculated per-face, not per-vertex. This hindered shaders to interpolate between tangent-spaces per-vertex (like it lerps per-vertex normals).

Also, this PR includes the retrieval of the per-vertex normals, needed for the calculateSmoothTangent method and smooth shading in general.

@IMS212 IMS212 closed this Aug 1, 2023
@SinanAkkoyun
Copy link
Contributor Author

9b04558

@SinanAkkoyun SinanAkkoyun deleted the 1.18.2-smoothtangentspace branch August 1, 2023 16:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants