how to make shadow caster and light probe work if im using commandbuffer.draw?

hi ,i am trying to use compute shader to make a all gpu workflow particle system,and all particle-mesh movment was calculating by compute buffer and move by vertex shader.
so the best way to do this is to use commandbuffer.drawprocedural instead of graphics.drawmesh(cause it will have to transfer your buffer back to CPU and then get back to GPU);
but if you using ommandbuffer.drawprocedural then you won’t get any shadow or light probe work,that will lose many best part of unity.
so my question is how to aovid that?
if i rewriting unity bulid-in standard shader’s vertex shader with my custom vertex shader?would it do the job?
i just dunno how to do this.

bump

Shadows and light probes require the mesh be processed by the CPU to determine the data needed so that it can be supplied. Since draw procedural skips all of that CPU side work it means no shadow casting, shadow receiving, or light probes… Unless you do it all yourself.

For shadow casting you have to use command buffers on the lights to inject your draw calls into the shadow maps. This is relatively straightforward.

For shadow receiving you either need to render your own shadow maps and supply those or copy the shadows maps using a command buffer. I don’t know of anyone for sure doing this yet, certainly no one has released a code example showing this working, but all of the necessary functionality is there for this now, though it requires some reconstructing of shadow matrices. You might look at the volumetric light thread as I think some of the methods for doing these require similar work.

To get light probes you’ll need to get an interpolated probe and convert it into there form the shader needs on you’re open. There’s a handy built in function for getting an interpolated probe, but not one for getting the data in there right layout. Luckily others have reverse engineered that already, though unfortunately I can’t find the thread. Alternatively you could conceivably use a light probe volume, but you world have to figure out how to get that from another object or generate your own manually.

5 Likes