Particle Systems emitting from Skinned Mesh / Mesh - assign mesh UV to particle?

For a particle emitting mesh, I know that you can assign vertex colors to emitted particles, but is there any way to assign the UV coordinates from which the particle was emitted?

The best way I can come up with for the moment is to iterate through a particle system’s particles every frame to search for newly emitted particles and raycast back at the emitting mesh to find the UV and then stuff it into a custom vertex stream (5.5 feature) but that seems like it could be expensive at scale.

I do need the vertex color data for color, but I tried putting the uv info into the vertex colors of the emitter mesh so that they’d get assigned to the particle color when it is emitted by the Shape module, but even though I have no other modules set up to modify the color in this test, somehow it is changed by the time I’m dealing with it in a fragment shader.

1 Like

What do you need the UV data on the particles for? We currently have no way of extracting it. And yes, your raycasting solution sounds very slow :slight_smile:

It’s a bit convoluted, but this might work:

  • when loading your mesh, create a 256 color palette of the most “important” colors on your mesh
  • replace the vertex color in the mesh with X=paletteIndex, YZ=UV
  • now, when you are rendering your mesh particle, the color stream will have enough information to look up a color, and also provide the source UV
    However, the color stream is 8 bit, you are going to lose quite a lot of UV precision by packing them into this format, and I assume they are in the 0-1 range to begin with. Without knowing your use-case, I can’t say whether this amount of precision will be enough for you.

Regarding this, it should be preserved, as long as the particle start color is set to White, and the Shape module has Use Mesh Colors selected, to use the vertex color from the mesh.

1 Like

I wanted to have the particles sample from a floating point render texture that is dynamically drawn to on the emitting mesh for an effect that is localized to certain parts of the mesh.

If the Shape module is already picking up vertex colors, couldn’t it also read from the UVs of the emitting mesh? I guess stuffing it into a custom vertex stream would be a little less straightforward in the ParticleSystem inspector UI…

Anyway, I’ve moved on to a different implementation that won’t be quite as cool :cry: