godotengine / godot

Godot Engine – Multi-platform 2D and 3D game engine
https://godotengine.org
MIT License
88.78k stars 20.13k forks source link

Incorrect shading on normal mapped models with skeleton when using compatibility renderer #94500

Open eatin-apples opened 1 month ago

eatin-apples commented 1 month ago

Tested versions

-Reproducible in 4.2.2, 4.3beta3. -Not reproducible in 4.1.1, 4.1.3

System information

Godot v4.2.2.stable - Windows 10.0.26100 - GLES3 (Compatibility) - NVIDIA GeForce RTX 3060 Ti (NVIDIA; 32.0.15.6070) - AMD Ryzen 5 5600X 6-Core Processor (12 Threads)

Issue description

When viewing a normal mapped model using the compatibility renderer, shading appears inverted in places. Issue is apparent both on windows and when exported for android. Issue does not occur when using Mobile or Forward+ renderer (nor in gles2 or gles3 for Godot 3). Issue does not occur in 4.1.3, 4.1.1, or 3.5.3.

My uneducated guess is that there's a missing or superfluous negative in the normal map code.

Miscelaneous information; Model is ~6k polys, rigged and animated .glb. Only has diffuse and normal map. Textures tested at various resolutions. Created in blender.

This is my first post, please let me know if the formatting or information is wrong.

whyiscompatibilitylikethis2a

Steps to reproduce

open a normal mapped model with skeleton while using the compatibility renderer in Godot 4.2.2 / 4.3beta3

Minimal reproduction project (MRP)

test-normalbug.zip

akien-mga commented 1 month ago

A MRP would be really useful to confirm the issue and solve it.

Calinou commented 1 month ago

If the issue only occurs in 4.2 and later in Compatibility, this could be due to shadow rendering which wasn't implemented in 4.1 but is available in 4.2. It's enabled in the preview environment, so try adding a DirectionalLight3D node and disable shadows to get a fair comparison with 4.1.

eatin-apples commented 1 month ago

Disabling shadows does not seem to affect the issue, nor does disabling the directional light altogether. I've also tried to recreate the issue using static normal mapped models, they do not appear to be affected.

clayjohn commented 1 month ago

Sounds like the issue is with the skinning code, which is located here: https://github.com/godotengine/godot/blob/master/drivers/gles3/shaders/skeleton.glsl)