Home > Backend Development > C++ > body text

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

DDD
Release: 2024-10-28 20:12:31
Original
912 people have browsed it

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.

The above is the detailed content of How to Eliminate Facets in Bump Mapping: A Solution to the Per-Face Normal Calculation Problem?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!