Uniform per Instance?
Asked Answered
D

4

0

I have a very basic shader (new to shaders!), it takes in an int variable and uses logic to set the colour. Technically it works, but all the sprites are set to the colour of the last one set in code.

Is there a way to set each sprites colour independently using a single shader, or will I be reassigning materials?

Cheers

EDIT:

Something like set_SELF_shader_param?

Dorothy answered 7/4, 2020 at 0:28 Comment(0)
F
0

You may keep using the same Shader (don't duplicate it), but you'll have to assign a different ShaderMaterial per sprite.

Foresaid answered 7/4, 2020 at 1:34 Comment(0)
D
0

OK, so (say) 7 ShaderMaterials each with diff params but all use same actual Shader. That makes sense, thanks

Dorothy answered 7/4, 2020 at 1:44 Comment(0)
S
0

I know this is kinda an old topic, but Godot 4 has instance uniforms now, no more need to duplicate ShaderMaterial.

Stumpy answered 13/4, 2022 at 17:42 Comment(0)
B
0

Stumpy There is still needing to duplicate it because instance uniforms aren't implemented for 2D shaders 🙁

Boracite answered 15/11, 2023 at 7:52 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.