Using the example in preview 293 Example GPU Particle System with Mesh.vl, I’ve tried to add a compute shader into the PBR material so I can colour instances individually, I’ve hooked colour up to vel in the simulation shader for testing, but also tried setting it in a float4
And used Example Geometry Shader with PBR.vl as a base for the compute. But when I hook it up to the material, it hangs and quits, so I’m definitely doing it wrong :D
Going away for a couple of days, so thought I’d park this here and see if anyone can tell me where I’m messing up! Thanks :)
you have two options if you want to read the color from the particle buffer:
you can do the same as you do with the transformations, write them into a ComputeBuffer and connect that buffer to the material. look into the ColorPerInstance node to see how you read a buffer value per instance.
or, if you want to write a ShaderFX that reads the color from the particle buffer and provides it to a material you can do it like that:
Particles with Mesh and Color.zip (36.3 KB)
It doesn’t crash when I connect the compute now, but I still dont get per instance colour (it should be getting the vel as colour set in the simulation shader). Is there something else I need to do in the compute?
yes, it works correctly, but you are using the PBR material node with the specular workflow. for that you need to set the specular map, otherwise, you only see the specular contribution to the pixel color.
if you switch to the metallic workflow you see the diffuse color without modification.
Here is an updated particle system, I’ve got normal sprites working, and mesh, but can’t get the imposter particles working for some reason. Any ideas? (all in the draw patch)
I do have interframe particle emision though which has been on my list for ages, ie multiple particles per frame get spread between previous emiter postion and the latest rather than just clumping together (kind of like motion blur). Need to get colour over life working for the mesh particles too and the curl in a separate shader. But pretty functional for now.
Upcoming preview will contain a NullMesh that you should use for particle systems that use a geometry shader and a stride material. it fixes an issue found in the FUSE sphere imposters. there was a problem with topology and instances.
have a look into the GPU particle system with PBR example patch to see how to use it.