Sorry for the silly question, but really stuck with my custom vertex stream – first time writing a shader specifically for a particle system. It works fine passing in the UV and a random value from the P.S., but when trying to pass the center (whether as a float3 or float4 texcoord) it just doesn’t work. Image attached of my CVS setup and my appdata structure – any advice? Many thanks!
That looks correct. How are you trying to use the value?
I wanted to use the center to apply a “falloff” to the particle based on distance between the camera and the particle system’s origin. That part’s not too difficult to do, but I haven’t even got there – I didn’t use the value at all yet and it throws a vertex stream error. Should I just try to ignore it?
Oh yeah. That error always shows. It’s been broken since they added custom streams, even when using the built in particle shaders.
If you remove the vertex instance id line it might go away. It’s only need if you’re doing VR or instanced mesh particles (which would require a different setup anyway).
I’m planning on using these particles in a VR scenario, which is why I added that line [not instanced mesh]. Could you expand on how that would differ in terms of setup anyways? Thanks for the heads up on the error showing though!
Unity’s own documentation has some example shaders showing how to write instanced mesh particles. Including using custom vertex streams.
The short answer is the extra data is packed into an instanced data array that you need to access with the instance ID. Color and the transform matrix is handled differently than other instanced shaders, hence needing shaders that are specifically written to support instanced mesh particles.