- Home /
GPU Instancing with textures
Trying to do GPU instancing with different textures, kinda like SpriteRenderer does behind the scenes. The idea is to give each instance a different texture.
Now, I've read here that @bgolus said it's not possible, and that instancing only works with numerical properties. But I haven't heard any confirmation for this, and it doesn't make sense, since then what is MaterialPropertyBlock.SetTexture good for?
Answer by BastianUrbach · Sep 15, 2018 at 05:48 AM
You could make a texture array and then only set the array index as per instance data.
Yeah, that's what they suggest in the post I linked, but that requires more manual work and again, doesn't explain why they bothered adding the function $$anonymous$$aterialPropertyBlock.SetTexture
It's also much more limiting, since all textures must be the same size, compression, UV, etc.
$$anonymous$$aterialPropertyBlock can be used for non instanced draw calls as well and for those it's more consistent to have that function as well ins$$anonymous$$d of artificially restricting it.
Hmm... Can you explain how it differs from $$anonymous$$aterial.SetTexture
? Also, how can you access that value in the shader? A simple parameter?
Your answer
Follow this Question
Related Questions
Adding support for GPU instancing for legacy shaders? 1 Answer
Cant find Standard Surface Shader (Instanced) in Unity 2 Answers
Why do static arrays in shaders cause massive slowdown? 0 Answers
How do I enable GPU Instancing on the Sprites-Default shader? 1 Answer
Shader graph and GPU instancing 0 Answers