godot
godot copied to clipboard
Mesh with negative size and cull disabled displays incorrect normals GLES3
This bug was found in both #26710 and #25696 But was mixed in with a few other bugs. This issue supercedes them both.
Godot version: Master
Issue description: When a mesh with culling disabled is given a negative size the normals appear backwards in GLES3.
https://user-images.githubusercontent.com/5222656/52463875-9e985800-2b46-11e9-9db0-136267400a36.png
Note: this issue doesn't appear when using cull_front or cull_back because Godot detects when the scale is negative and flips the culling operation.
https://github.com/godotengine/godot/blob/6895ad303b51aaf84a568c982e3622049a50ed37/servers/visual/visual_server_scene.cpp#L950
Steps to reproduce:
- Create a MeshInstance
- Set the cull property of the SpatialMaterial to "disabled"
- Set the scale of the MeshInstance to (-1, -1, -1)
Minimal reproduction project: https://github.com/godotengine/godot/files/2844079/tests_3.1.zip
Seems still valid in ba51af790
@KoBeWi I can reproduce this on v4.0.dev.custom_build [2a28df82d]

as you can see the left side (its a meshinstance inverted on scale)
thanks to @lyuma this can be workarounded via vertex shader:

PS: Lines 25-26