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

Strange error when changing Spotlight3D Projector texture during runtime, but not during _ready(): ; texture_remove_from_decal_atlas: Parameter "t" is null. #93516

Open
homhomhomhomhom opened this issue Jun 23, 2024 · 3 comments

Comments

@homhomhomhomhom
Copy link

Tested versions

My version:
v4.2.1.stable.official [b09f793]

System information

Godot v4.2.1.stable - Windows 10.0.22631 - Vulkan (Forward+) - dedicated NVIDIA GeForce RTX 3060 (NVIDIA; 31.0.15.5222) - Intel(R) Core(TM) i7-10700F CPU @ 2.90GHz (16 Threads)

Issue description

Very strange issue when changing Spotlight Projector texture to a different texture during runtime.
Setting the texture in _ready() works fine, but changing the texture after that throws an error, however, it does change the texture and does not crash.

error in question: E 0:00:02:0198 texture_remove_from_decal_atlas: Parameter "t" is null.
<C++ Source> servers/rendering/renderer_rd/storage_rd/texture_storage.cpp:2745 @ texture_remove_from_decal_atlas()

Expected:
No error when changing textures

Got:
Strange error when changing textures

Steps to reproduce

Add a spotlight to your scene

Have a script with a function that changes the spotlight's texture

Press specified button (in my test project it's ui_accept)

See error message when texture changes

Minimal reproduction project (MRP)

BugReproduction.zip

@AwesomeAxolotl
Copy link

After thinking the code through a bit, I found the the reason this happens (roughly):
On the change the old texture loses its last reference (RefCounted), and some internal of Light3D still using this will run into a missing reference because the reference already got cleaned up

So the fix would be keeping the current texture in memory by holding it in a var before changing light_projector to a new value or in this example it would also work to (pre)load the textures into the image1 and image2 vars (or an array) like

var image1 = preload("res://bobr.png") var image2 = preload("res://hegodh.png")

var new_image : CompressedTexture2D = image1

@AThousandShips
Copy link
Member

Please try with 4.2.2 to confirm this still occurs on a supported version

@homhomhomhomhom
Copy link
Author

Issue is also there on 4.2.2

AwesomeAxolotl's fix works tho, altho I'm still not sure it should give the error in the original example

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