Search Unity

Question Can I use a mask (texture) to spawn particles on the white parts of it, inside of a shader?? (HLSL)

Discussion in 'Shaders' started by nadigupo, Dec 29, 2022.

  1. nadigupo

    nadigupo

    Joined:
    Mar 21, 2019
    Posts:
    3
    Hi there!
    Maybe this will be kind of a weird (stupid) question as I'm kind of new to HLSL.

    I have a texture that I'm using as a mask, so it's white and black.
    The thing is that this mask is sampled in a plane that acts as normal ground, and I want to spawn smoke particles only on the white parts of the mask (like really hot lines on the floor).

    I'm programming an Unlit Shader, and I would like to set up these particles (smoke) behavior (spawn in white parts of the mask) inside of it if possible. So maybe later I change the mask and the smoke effect will update automatically and it will adjust itself to the new white parts of a newer mask.
    Maybe I will need to mix my shader + a particle system (??). But I would like to know if I can attach a particle system to a shader.

    The idea seems realistic in my mind, but I don't know how to code it in case it's possible.
    Or if anyone knows another way to achieve this result by using a black and white mask.

    (I will also add that I'm not using shader graph. Only HLSL. Although any answer is valid to me!)
    Thank you so much!
     
  2. bertus1987

    bertus1987

    Joined:
    Jul 23, 2022
    Posts:
    5
    hi, could you fix the problem? i can't add a mask to the particle system... can you help me? thank you