My use case: I'm using ANT Landscape and the Landscape Tools add-on to generate a landscape with vertex groups pre-assigned for erosion, deposit, water etc. (Landscape Tools does this for you).

I'm then happily using those vertex groups to control the length and density of grass with a particle system.

However it would be cool if I could use the same vertex groups to control the particles' texture, so that the grass turns more yellow where the water vertex group of the emitter has low values.

Any ideas how to achieve this?


[edit] There is a proper solution which I'll add as a separate answer, but since this technique is different enough to have its own uses (like if you want different grass models at the edges) I'll leave it here.

After digging around for a while, it looks like this is not possible. The closest I got was an OSL script using traceset to find the value, but it turns out that Blender OSL doesn't implement traceset.

I did come up with a workaround that more or less does what I want:

  1. Create an additional vertex group (I called it water.edge) on the emitter and assign all vertices to it.
  2. Add a Vertex Weight Mix modifier to the emitter, which copies the original water vertex group to water.edge.
  3. Below that add a Vertex Weight Edit modifier that edits water.edge and applies a custom falloff curve that starts at 0, rises to 1 then falls back to 0. This makes water.edge have its highest values where the water values are intermediate.
  4. Create a new particle system yellow grass, and use separate yellow grass variant particles.
  5. Use the water.edge vertex group to control the density and length of the yellow grass particle system.

Downside is the texture doesn't "blend" from one region to another, but at least I can get dry grass where I want it.

Here's a picture of that part of the modifier stack.

  • 1
    $\begingroup$ Can you use this trick to get vertex-group info into the emitter, and then 'from dupli' in the particles? $\endgroup$ – Robin Betts Jun 29 '20 at 13:13
  • 1
    $\begingroup$ That actually worked! Thank you so much. I'll write up the solution. $\endgroup$ – Bill Hails Jul 5 '20 at 8:15
  • $\begingroup$ Great! Don't forget to credit @Nathan's answer.. it's very handy, until other methods are properly written into Blender, and more people should know about it. $\endgroup$ – Robin Betts Jul 5 '20 at 8:30

Big thanks to Robin Betts for pointing the way.

A solution, using the UV Warp Modifier as suggested by @Nathan here.

  1. Unwrap the emitter to a new UV Map (in case you've already got one).
  2. In the UV editor for that map, select all the vertices, scale them to zero, and move them all to (0, 0).
  3. Create two empties, call them "Empty.from" and "Empty.to", place "Empty.from" at (1,1,0) and "Empty.to" at (0,0,0). Lock their loc/rot/scales as you don't want to accidentally move them.
  4. Add a UVWarp modifier to the emitter as shown:here
  5. Make sure the new UVMap is selected and active on the emitter.
    • If you've already unwrapped the emitter to texture it, you'll have to be explicit about using that older UV Map in the emitter's material.
  6. In the particle's material, add a UV Map node, and check "From Instancer".
  7. Connect the output of the UV Map node to the input of a Separate XYZ node.
  8. Connect either the X or Y output of the Separate XYZ node to the input of a colour ramp (to give you control).
  9. Use the output of the color ramp to control whatever mixing between colors or materials you need.

In creating a demo scene to test this in isolation, I had trouble getting it to work. It was useful to temporarily add the same uv map setup to the emitter itself (but uncheck "from instancer") and send the color ramp output straight to the output shader. That allows checking the modifier is working without the particles. I ended up having to swap the To and From empties in the UV Warp modifier, but oddly just swapping their locations didn't fix it. TL;DR persevere if it's not working.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.