Search Unity

How to change particle colour which is set with Set Color From Map using Hue

Discussion in 'Visual Effect Graph' started by laurienash, Oct 2, 2021.

  1. laurienash

    laurienash

    Joined:
    Mar 15, 2013
    Posts:
    61
    Hi,

    I'm using the Set Color from Map node in my Initialize Particle block.

    upload_2021-10-2_13-49-12.png

    I would like to be able to recolor it using a Hue node or something similar. (As using the blend, multiply or add color nodes flattens out the details).

    I've read I can create a vfx shadergraph, which has a Hue node. But I can't work out how to input the color set from in my Initialize particle block, as my shadergraph is overwriting that information.

    How can I input the colour from the Set Color From Map node into my shadergraph? Or should I go about this differently?

    Thanks,
    Laurien
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    Hello
    Each particle has its own attributes and almost all these blocks operate on them, but they have nothing to do with rendering itself - output does it. If you need to pass value to the shader, you must expose property and set it manually like this (we are talking about custom shader):
    upload_2021-10-2_16-53-36.png
    Also I might be wrong, but color is kind of special case in simple particles, because it is assigned to particle vertices and this mean you can get color of particle in shader graph from vertex color.

    When it comes to the hue you can do it in many ways, I don't know your goal, but I am going to assume it must be hue shift:
    First way, you could just shift hue of image used in Color From Map, but obviously this is very rigid solution and most likely not suitable for you.
    Second, you can change hue in shader graph - you need to feed shader with color (like image above) and then you can do whatever you want in shader.
    Third, downside of the second solution is that hue shift is calculated per pixel and this is probably not needed. The best solution would be to initialize particle with the color you want ultimately and I guess something like this should do the job:
    upload_2021-10-2_17-8-21.png

    You convert color to HSV and this way you can directly modify hue (x component), and then change it back to RGB to set it back to the graph. Maybe there is better way than this, but then you need someone smarter than me :D
     
    Last edited: Oct 2, 2021
    VladVNeykov likes this.
  3. laurienash

    laurienash

    Joined:
    Mar 15, 2013
    Posts:
    61
    Oh amazing, thanks so much!

    I hadn't thought of using the get attribute to feed the color data into shader graph, that works perfectly!