Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Join us on March 30, 2023, between 5 am & 1 pm EST, in the Performance Profiling Dev Blitz Day 2023 - Q&A forum and Discord where you can connect with our teams behind the Memory and CPU Profilers.
    Dismiss Notice

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


    Mar 21, 2019
    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


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