Search Unity

Question Random Between Two Gradients non linear interpolation?

Discussion in 'Visual Effect Graph' started by ShiraYaari, Oct 9, 2022.

  1. ShiraYaari

    ShiraYaari

    Joined:
    Nov 14, 2021
    Posts:
    1
    Not part of the VFX graph, but there isnt a dedicated subforum for all VFX, but regardless, this should still apply.
    Currently the "Random between two gradients" interpolates a color between each gradient to create a completely new third gradient.
    Is there any way to, either in code or in the Particle System Component, actually choose between two gradients rather than interpolating a new gradient?
    Is there a way to do this in the VFX graph?
     
  2. Qriva

    Qriva

    Joined:
    Jun 30, 2019
    Posts:
    1,314
    I don't know about particle system, but in vfx graph it would be something like that:
    upload_2022-10-9_14-37-45.png
    First one should give you 50% of particles use the first gradient and 50% the second one.
    (Actually it should be particle id instead of spawn index if you want to use it in update)
    The lower one is example where you provide some value to determine gradient index, but you can do any other logic you want.

    One note - if you plan to use more than several gradients then it might be better idea to create texture where each line represents one gradient and sample them instead of doing switch.