Search Unity

Distribute Particles based on a texture?

Discussion in 'Visual Effect Graph' started by Cell-i-Zenit, Feb 7, 2020.

  1. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    103
    Hi,

    i have a simple black white texture and i would like to use this as a kind of height map and place particles based on this.

    Is there an "easy" way to do that?
     
  2. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    113
    Hi. You want to use your black and white texture as a height map or a density map?
    Whatever it is, just sample it in the init context to drive the height of the particle (for height map) or the probability of spawning using alive attribute (for a density map)
     
  3. Cell-i-Zenit

    Cell-i-Zenit

    Joined:
    Mar 11, 2016
    Posts:
    103
    I didnt explain it good enough what i would like to do:

    I would like to place grass based on a height map, but just putting a sample texture 2d node to a position node is just spawning the particles at the same position.

    Iam missing a node which acts like a Generator function. For each pixel on the texture spawn a particle. If the Color is under a treshhold, discard the particle.

    What iam doing now is just generating two random numbers and using these numbers as UV, but this is reaaaally bad as i cannot get an evenly distributed field.
     
  4. Voronoi

    Voronoi

    Joined:
    Jul 2, 2012
    Posts:
    296
    Are you using the Attributes>Map>SetPositionFromMap block in the initialize node? I think that does what you are describing. You can also Kill or change the lifetime using a Map.
     
unityunity