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

Shader instance uniforms are updated with one frame delay #79602

Closed
bitsawer opened this issue Jul 18, 2023 · 0 comments · Fixed by #79603
Closed

Shader instance uniforms are updated with one frame delay #79602

bitsawer opened this issue Jul 18, 2023 · 0 comments · Fixed by #79603

Comments

@bitsawer
Copy link
Member

Godot version

Godot v4.2.dev (57919be)

System information

Godot v4.2.dev (57919be) - Windows 10.0.19045 - Vulkan (Forward+) - dedicated NVIDIA GeForce GTX 970 (NVIDIA; 31.0.15.3179) - Intel(R) Core(TM) i7-4790K CPU @ 4.00GHz (8 Threads)

Issue description

I already have a possible PR incoming to fix this issue, but I'm creating this report in case the fix needed is more complex.

Unlike normal shader uniforms set using ShaderMaterial.set_shader_parameter(), instance uniforms set using GeometryInstance3D.set_instance_shader_parameter() are is some situations updated one or more frames later. This causes all kinds of headaches as you have to add a sentinel value check (or some other similar workaround) to your shaders to see if the instance uniform has been updated yet.

Steps to reproduce

Download the MRP project and run it (it's a modified MRP from #79167 where I noticed this issue). Press and hold left mouse button and you can "paint" and create new cubes on the ground where the raycast hits. Note that all newly created cubes have a black color during their first frame of lifetime. After the first frame their instance uniform is updated and the cube gets it's real color. Hopefully, this should be pretty easy to see when dragging the mouse.

Minimal reproduction project

InstanceUniformUpdateBug.zip

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

Successfully merging a pull request may close this issue.

2 participants