Bug in default shader with normal map
See original GitHub issueDescription of the problem
There are rending issues due to the default shader (checked with MeshStandardMaterial and MeshPhongMaterial) when using the normal map if all the texture coordinates for the face are exactly the same.
I had exactly the same issue with other shaders and this was related to the dFdx(uv)
and dFdy(uv)
shader functions returning 0 and leading to a division by 0.
Live example:
- jsfiddle (dev branch)
Three.js version
- Dev
- r108
- r104
Browser
- All of them
- Chrome
- Firefox
- Internet Explorer
OS
- All of them
- Windows
- macOS
- Linux
- Android
- iOS
Hardware Requirements (graphics card, VR Device, …)
OpenGL vendor: NVIDIA Corporation (0x10de)
OpenGL renderer: GeForce RTX 2060/PCIe/SSE2 (0x1f08)
OpenGL version: 4.6.0 NVIDIA 430.40
Issue Analytics
- State:
- Created 4 years ago
- Comments:32 (8 by maintainers)
Top Results From Across the Web
[Bug] Specular and Normal maps not working with shaders
Have a shader enabled (I used Sildurs enhanced default V1.10); Ensure normal maps and specular maps are on in the shaders menu ...
Read more >Trying to set a normal map on a simple shader - Unity Forum
Hi. I am unable to create a shader with a normal map in the Shader Graph (with HDRP). I had been trying it...
Read more >Normal map inverted UVWs shader bug
Your normal map is messed up. Try this normal map, it works fine. ... There are three things that last forever: Abort, Retry,...
Read more >Normal map (Bump mapping) - Unity - Manual
Normal maps are a type of Bump Map. They are a special kind of texture that allow you to add surface detail such...
Read more >Strange behaviours in Node Material normals - Bugs
Normal default color (127, 127, 255) does not align with empty normal. This seems to be a general normal map problem that also...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This is what I believe is happening…
Even if the uv’s at each vertex are identical, interpolation of uv’s across the face of the primitive can result in different values due to numerical roundoff.
Consequently,
may not be the zero vector we would hope it would be.
The next line
will return - 1, 0, or 1.
And the following line is normalizing something that is very close to zero
which just amplifies the numerical errors since it returns a unit-length vector.
@Mugen87 The OP is only trying to help locate the issue at this point.