I suddenly noticed that GPU instanced objects are ignored by my Projector.
I am rendering the object with DrawMeshInstanced.
I checked my layers, my ignore layers, which are fine.
The same objects, with the same shader, when placed in the scene manually, do get influenced.
I have similar problem before, but for my case it was cause by the light probe I place in the level, so I set the light probes to off from the mesh filter then the GPU Instancing work again
Thanks for your reply.
I have no gameobjects, but draw them with code. So i also have no MeshFilter…
I guess that’s the whole problem. Unity doesn’t seem to know these objects are there, as it would if they were regular gameobjects.
But maybe someone knows a workaround or shader trick?
Still haven’t found a solution.
I am using a projector for simple blob-shadows. Works fine on regular gameObjects, but when i draw the same object, with the same shader, with DrawMeshInstanced, it ignores the projector.
But shouldn’t this be handled in the shader?
Unity’s built in projector system does a lot of of the hard work on the CPU. It does an overlap test of the projector’s frustum and the bounds of renderer components in the scene and draws any object it touches again with the projector’s material and projector’s UV projection matrices.
Several of the “Graphics.Draw” functions get their extra efficiency by skipping several of Unity’s internal CPU side rendering steps. That projector overlap test is going to be one of them. It’s plausible they would be “enabled” as part of either the shadow casting or shadow receiving flags in the DrawMeshInstanced call. More likely you may need to handle this on your own and manually do the overlap tests and calculating the projection matrices you need then calling DrawMeshInstanced with only those meshes affected and using the projector’s material.
Alternatively you might look at doing something akin to deferred decals.
That clears things up a bit. Thanks!
I’ve tried drawing things with shadow flags enabled, but that didn’t help.
I’ll see what other solution i can cook up