Search Unity

Help Wanted Why is the node "replace colour" not working on the given RGB?

Discussion in 'Shader Graph' started by dr4, Sep 4, 2019.

  1. dr4

    dr4

    Joined:
    Jan 14, 2015
    Posts:
    24
    Hi people!

    I just started working with this node to replace a very specific color but it doesn't seem to be working properly and I would like to ask if someone know if I'm missing something, so I created this test image, I know exactly the RGB of these colours:

    upload_2019-9-4_21-1-15.png

    but when I use the replace node pointing to a very specific RGB it affects other colours first, in this example I'm giving it the RGB of the brown color, I would like to change only the brown color and as I'm giving it the exact RGB I would expect to change it with range 0, but nothing happens until I put the range in 0.25, and what gets changed is the blue colour, the image above becomes:

    upload_2019-9-4_21-6-46.png

    why is this happening? Everything I read says that by giving it the specific RGB I should be able to affect a specific colour

    upload_2019-9-4_21-9-37.png
     
    Last edited: Sep 4, 2019
  2. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    2,804
    Do the color values differ if compared to if you pick it with the color picker from inside of unity?
    What is your Color space linear / gamma and is your texture imported as SRGB or not.

    In general this should work.

    upload_2019-9-6_19-27-42.png
     
  3. dr4

    dr4

    Joined:
    Jan 14, 2015
    Posts:
    24
    thank you so much for answering, I have been trying for days and at some point I assumed it was broken.

    Then Unity basically sees the colour different from what it is? (I did try some external tools to check the colour after export it to Unity and got exactly the same RGB of the original image) but I'm not aware of any colour picker within Unity, how can I know exactly how unity sees that colour RGB? your example seems to achieve exactly what I need.


    here for example this tool shows me the correct RGB of the brown colour (the one I gave it originally), but again adding that exact RGB in "from" makes the blue change first!:
    upload_2019-9-8_22-12-49.png
    upload_2019-9-8_22-11-52.png

    the sprite settings:


    upload_2019-9-8_22-8-11.png

    again thank you so much for your time @fffMalzbier , this have been driving me crazy.
     

    Attached Files:

    Last edited: Sep 8, 2019
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    2,804
    Every color field / selector in unity has a color picker.
    (Top left of the color popup)
    https://docs.unity3d.com/Manual/HDRColorPicker.html
    Unity does the color space conversion on import, but this does not change the asset you provided just the imported version saved in the library, so external tools will not see any change int the file.
     
  5. dr4

    dr4

    Joined:
    Jan 14, 2015
    Posts:
    24
    thank you again for answering @fffMalzbier , I thought you meant something where I could click on a sprite and get the exact RGB of that color as seen by Unity, so my main question remains, how can I know exactly the RGB as seen by Unity?I changed every single option on the sprite inspector and noticed that if I un-check the sRGB option the "replace colour" node works perfectly (with 0 range it removes the exact colour) bu it also makes the colours looks washed out, so it seems to be an option problem but I still don't get how to solve it after change everything multiple times:


    upload_2019-9-9_9-15-7.png

    after un-check:

    upload_2019-9-9_9-13-53.png

    checked:

    upload_2019-9-9_9-14-19.png
     
  6. dr4

    dr4

    Joined:
    Jan 14, 2015
    Posts:
    24
    ok I think that I got this, not enterily sure of what I changed but it seems to be working now if I convert the color to HDR

    upload_2019-9-9_9-23-8.png

    I will keep playing with this, thank you for guide me to check the settings @fffMalzbier
     
  7. dr4

    dr4

    Joined:
    Jan 14, 2015
    Posts:
    24
    I will surrender with this, the same sprite looks very different in the shadergraph preview and in-game, so I can adjust a very specific colour in shadergraph just to see it replacing way more on the sprite in-game, and different sprites are affected differently even when they have the same settings and same RGB, after many hours with this replace Node I'm sure that it is not working as intended at all. a shame really but this is very new so I guess that some problems should be expected