"If a worker wants to do his job well, he must first sharpen his tools." - Confucius, "The Analects of Confucius. Lu Linggong"
Front page > Programming > How to Eliminate Facets in Bump Mapping: A Solution to the Per-Face Normal Calculation Problem?

How to Eliminate Facets in Bump Mapping: A Solution to the Per-Face Normal Calculation Problem?

Published on 2024-11-07
Browse:698

How to Eliminate Facets in Bump Mapping: A Solution to the Per-Face Normal Calculation Problem?

Fixing Faceted Models in Bump Mapping

In attempt to enhance models with bump mapping, many encounter faceted appearances like the one seen below:

[Insert image of faceted model]

This issue stems from calculating tangent, binormal, and normal values on a per-face basis, neglecting the existing model normals. The current process utilizes two triangle edges and texture space vectors to compute tangent and binormal, which are then cross-multiplied to obtain the normal.

Achieving Smooth Normals

To remedy this, consider calculating these values on a per-vertex basis, incorporating the model normals. Alternatively, explore smoothing techniques to eliminate the faceted appearance.

One effective method is:

  1. Initialize a per-vertex array for normal storage.
  2. Set each normal to zero and initialize a vertex counter to zero.
  3. Calculate the per-face normal and add it to all vertices involved in the face, incrementing the vertex counter accordingly.
  4. Normalize each vertex's normal by dividing it by the vertex counter.
  5. Compute per-vertex tangent and binormal vectors as usual, using the smoothed normals.

This approach yields smooth normals that can enhance the desired bump mapping effect. For further insight, consult the provided earth preview showcasing bump mapping and other effects.

Latest tutorial More>

Disclaimer: All resources provided are partly from the Internet. If there is any infringement of your copyright or other rights and interests, please explain the detailed reasons and provide proof of copyright or rights and interests and then send it to the email: [email protected] We will handle it for you as soon as possible.

Copyright© 2022 湘ICP备2022001581号-3