Search Unity

Color over distance from camera

Discussion in 'Visual Effect Graph' started by bjedlowski97, Feb 4, 2020.

  1. bjedlowski97

    bjedlowski97

    Joined:
    Feb 13, 2018
    Posts:
    46
    Continuing this from the old forum, I do have a camera with the tag main camera in the scene. I am still unsure why this is no working
     

    Attached Files:

  2. JulienF_Unity

    JulienF_Unity

    Unity Technologies

    Joined:
    Dec 17, 2015
    Posts:
    326
    I see several issues in your graph:

    You're expanding and normalizing the distance to a vector2. So you're converting a float to a normalized vector2 which will therefore always be (0.5,0.5). Remove the Normalize operator and directly plug the distance operator to the remap operator. Also make sure the rempa operator is in float mode (and not vector2) by clicking the small setting icon if needed.

    Finally you will control the distance range being remapped to the gradient with Old Range Min and Old Range Max. So here between 0 and 1m. You may want to to increase the Old Range Max so that particles further than 1m dont all appear cyan.

    Finally Instead of using Add Color block switch to a Set Color (In the block inspector your can change the mode to "overwrite"). Default color is white so you may want to overwrite it rather than add.

    Hope this helps
     
  3. bjedlowski97

    bjedlowski97

    Joined:
    Feb 13, 2018
    Posts:
    46
    I got it working thank you so much for the help. I am only having one small issue maybe you could help me with, so it is only using one small part of the gradient I create but I would like if it used the full spectrum I create for easier control. Like if I set up let's say Red, Green, Yellow and Blue, I can only get it to show 2 maybe three colors at a time. Any way to get around this issue or should I just work with what I have
     
  4. VladVNeykov

    VladVNeykov

    Unity Technologies

    Joined:
    Sep 16, 2016
    Posts:
    550
    Hey @bjedlowski97 , this is where the remap will come into play.
    You can set the Old Range Max to be the maximum distance you expect your particles can get from the camera. Then if the new range is set to Min 0 (beginning of the gradient) and Max 1 (end of the gradient), you'll be able to get use all the colors based on how far particles are from the camera.

     

    Attached Files: