Search Unity

Question Changing HDR outline color results in strange overlap

Discussion in 'Shader Graph' started by tescrin, Nov 1, 2020.

  1. tescrin

    tescrin

    Joined:
    Nov 26, 2019
    Posts:
    1
    Hello, I'm getting back into playing with unity after a year and am trying to make a simple outline shader to give me a neon-on-black effect.

    If I don't modify the outline color; I get a nice outline exactly as I'd want; as seein in unmodified.png.

    However if I modify it to the same color (afaik) by changing its property block, I get the modToRed; which shows a grey/greenish color on the intersection of outlines.
    Code (CSharp):
    1.         Color color = Color.red;
    2.         this._propBlock.SetColor("_OutlineColor", color);      
    3.         this._renderer.SetPropertyBlock(this._propBlock);
    If I modify it to blue and add some alpha (sending it to 2.0f), you'll see it go up to a yellow color in the editor; and blank in the game.
    Code (CSharp):
    1.         Color color = Color.blue;
    2.         color.a = 2;
    3.         this._propBlock.SetColor("_OutlineColor", color);      
    4.         this._renderer.SetPropertyBlock(this._propBlock);
    I've attached the (very routine) shader graph; which has a single extra modification over the tutorials (which is to blackout the entire texture; giving it a neon-retro look.)

    An aside, I also notice that if I GetColor on "_OutlineColor"; it's (0,0,0,0) upon return (at least initialially) which seems strange; since it should be initialized to the default. This makes me assume that since the initial color is HDR, that you have to talk to it in a slightly different way.

    Thank you for any help; especially regarding the getting/setting of HDR color properties in shaders and if there's an easy way to clear up the outline-intersection issue.
     

    Attached Files: