playcanvas / playcanvas/engine

Detail map normals and material normals are combined wrong when using different UV channels

Open
#5,985 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: graphics
Dominant language
JavaScript
Stars
16.8k
Forks
2k
Avg merge
4h 32m
Merged PRs (30d)
222

Description

If we have a material using a normal texture in UV 0, then apply a baked normal map as detail in UV 1, then we get wrong normals as a result. If however the material normal and detail normal use the same UV channel, we get correct results. When toggling the material normal UV channel it looks like this:
Toggle

In this example, the normal texture in the material is a solid color, flat normal (127, 127, 255), so it shouldn't affect the end result.

If we swap the textures so that the baked normal map is in the material, and the flat normal map is applied as a detail, we get the correct normals no matter what UV channel configuration. Here's a comparison of the different combinations (the top left is wrong, the rest is correct):
Comparison

The example project can be found here:
https://playcanvas.com/project/1184651
Try toggling the material TestObj's normal UV channel. When set to UV 0, we get wrong normals. When set to UV 1, we get correct normals. The expected result is that there shouldn't be a visual change when using different UV channels.

While the example project may not look that wrong, it's very visible when working on real models:
FlightHelmet_Toggle

Tested on both Firefox and Edge, and using the latest engine version as well as older ones.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked PlayCanvas project and reproduce the issue on TestObj by toggling the material normal UV channel between UV 0 and UV 1. Trace the normal-combination path for different material and detail UV channels; done means the rendered normals remain visually unchanged when the channel is toggled, including the reported texture combinations.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
computer-graphics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.