godotengine / godot

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

[3.x] `AnimatedSprite` normal maps are displayed with differences from project until editor restart #43435

Closed squimmy closed 1 year ago

squimmy commented 3 years ago

Bugsquad note: This issue has been confirmed several times already. No need to confirm it further.


Godot version:

Godot_v3.2.3-stable_win64

OS/device including version:

Windows 10, OpenGL ES 3.0 Renderer: GeForce GTX 970/PCIe/SSE2

Issue description:

When adding a normal map to an AnimatedSprite, the normal map does not always take effect as expected. It seems to work in the editor, but not when the scene is run. Issue https://github.com/godotengine/godot/issues/38509 includes a comment saying this feature "doesn't work", but I don't know if the issue was subsequently resolved, since the documentation was updated to suggest that it should be working.

Steps to reproduce: Add an Animation to the SpriteFrames for an Animated sprite, and add another Animation with a normal map using the same name with _normal appended. The expected behaviour (the normal map affects lighting) can be seen in the editor, but is not seen when the scene is run. Opening an existing project with normal maps already added also exhibits the same problem.

Minimal reproduction project:

2D Lighting.zip

The normal map animation (spin_normal) doesn't take effect in the editor unless the spin animation is either removed and re-added or renamed to something else and the renamed back to spin. the normal map also doesn't take effect when the scene is run.

valpet commented 3 years ago

I have also encountered this issue.

Calinou commented 3 years ago

As a workaround, I suppose you can use the Sprite + AnimationPlayer workflow instead of an AnimatedSprite. It requires more work to setup, but it's technically a more powerful approach.

valpet commented 3 years ago

I began doing that but my sprite sheets have sizes that's a power of two (like 512x512, 1024x1024 etc) and there's blank space padded at the bottom or spacing between rows of sprites. The slicing algorithm does not seem to handle that afaik, which is topic for another issue. I was hoping to use the simpler and easier to use AnimatedSprite for static (but animated) objects like trees, torches etc as it seems perfect for that.

pietrodito commented 3 years ago

In my project it is working like a charm. Maybe the issue can be closed now?

aykut4 commented 3 years ago

@pietrodito can you please provide some insight how it is working like a charm for you?

pietrodito commented 3 years ago
squimmy commented 2 years ago

The "fixed" project includes a custom shader. This seems like a good workaround, but I don't think I'd consider the issue fixed unless the intended behaviour is for normal maps to do nothing by default.

r0ber70 commented 2 years ago

Yes, still a problem.

akien-mga commented 1 year ago

Is this still reproducible in the latest 4.x builds?

dalexeev commented 1 year ago

Add an Animation to the SpriteFrames for an Animated sprite, and add another Animation with a normal map using the same name with _normal appended.

In 4.0, support for normal and specular maps in AnimatedSprite2D (via _normal and _specular) has been removed in #43052 in favor of CanvasTexture.

But I don't know if this issue remained in one form or another in 4.0 and in 3.x.

CamBrown00 commented 1 year ago

so there's no way to use normal/specular maps with an animated sprite at all anymore then, aside from using an animation player with a sprite2D instead?

dalexeev commented 1 year ago

so there's no way to use normal/specular maps with an animated sprite at all anymore

In 4.x you can use CanvasTexture with AnimatedSprite2D.

CamBrown00 commented 1 year ago

Ah ok I see, so you just add the frames from a CanvasTexture resource in the SpriteFrames editor

dalexeev commented 1 year ago

I tested it. In 4.1 this seems to work correctly. In 3.5.2 there are differences between the newly created scene in the editor and the running project:

However, after restarting the editor, the differences disappear:

animsprite_normalmap_3.zip

akien-mga commented 1 year ago

Fixed by #80406.