Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

TileMap NormalMap behaves incorrectly for transposed tiles #39851

Open
SquiggelSquirrel opened this issue Jun 26, 2020 · 1 comment
Open

TileMap NormalMap behaves incorrectly for transposed tiles #39851

SquiggelSquirrel opened this issue Jun 26, 2020 · 1 comment

Comments

@SquiggelSquirrel
Copy link

Godot version:
v3.2.2.stable.official

OS/device including version:
Ubuntu 18.04.4.LTS

Issue description:
When using a TileMap with a normal map and a Light2D, transposed cells do not take the light correctly.
Using the following cell texture, normal map, and Light2D:

tile
tile normal map
light

The following behaviour is observed:

image

Steps to reproduce:

  • Create a TileSet with a normal map
  • Draw transposed cells in a TileMap (e.g. rotate 90 degrees, in either direction, with or without a single flip)
  • Add a Light2D
  • Enable the Light2D, place near the tiles, adjust height and energy until effects are seen.

Minimal reproduction project:
Bug demo.zip

@lawnjelly
Copy link
Member

lawnjelly commented Jun 26, 2020

Note this demo is GLES3. Out of interest I tried it in GLES2. It turns out the legacy renderer does the same as GLES3 (incorrect according to this issue), but the batching renderer does it correctly (i.e. flips the normal map).

We'll have to decide on what the correct behaviour should be, I'll have look at the shader and see if I can work out why the legacy renderer is not flipping (perhaps this is intentional).

Edit : I now suspect the best behaviour would be flipping and using the same text coords as the texture as GLES2 batching does (as it has to match up - consider an irregular texture), but also flipping the actual normals read from the normal map in the fragment shader so the lighting still makes sense in relation to the light and is not backwards. This current combination is not currently supported in any configuration, so it is a bit broken in this respect.

However for cases where you are using normal maps, for the time being at least you could duplicate the variations of the texture manually in the texture atlas.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants