To access DOTS Instanced properties, your shaderA program that runs on the GPU. More info
See in Glossary can use one of the access macros that Unity provides. The access macros assume that instance data in unity_DOTSInstanceData
uses the following layout:
unity_DOTSInstanceData
buffer.0
, every instance uses the value from instance index zero. This means each instance loads directly from the byte address in the metadata value. In this case, the buffer only needs to store a single value, instead of one value per instance.1
, the address should contain an array where you can find the value for instance index instanceID
using AddressOfInstance0 + sizeof(PropertyType) * instanceID
. In this case, you should ensure that every rendered instance index has valid data in buffer. Otherwise, out-of-bounds access and undefined behavior can occur.You can also set the the metadata value directly which is useful if you want to use a custom data source that doesn’t use the above layout, such as a texture.
For an example of how to use these macros, see Access macro example.