mkrebser / GPUInstance

Instancing & Animation library for Unity3D
Other
228 stars 44 forks source link

Changing the Layer of Instances? #10

Closed projectBreakableAccAPI closed 1 year ago

projectBreakableAccAPI commented 1 year ago

Hey, it's me again! I was wondering whether or not it would be possible to change the layer of each instance, as I want my camera to cull a specific instance and ignore the rest. I was messing with it and found that the instances use the default layer, so could change this on an instance basis?

Thanks as always, -Max

mkrebser commented 1 year ago

Set the 'Invisible' property on the instance. Make sure you set the appropriate dirtyFlag as well, otherwise nothing will happen

https://github.com/mkrebser/GPUInstance/blob/master/Assets/Resources/GPUInstance/scripts/InstanceData.cs#L85 https://github.com/mkrebser/GPUInstance/blob/master/Assets/Resources/GPUInstance/scripts/instancemesh_types.cs#L319

Layers don't exist as a concept in shaders- it is a gameObject feature AFAIK and each instance is not a game object