Home Coding, Scripting, Shaders

Star shader only displays with certain colours?

polycounter lvl 6
Offline / Send Message
Vranvs polycounter lvl 6
Hello all,

I don't know much about shaders so I am wondering if I am missing something completely obvious here. I am using the shader graph in Unity 2019. I am trying to create a starry look for my background, and everything was working fine. I could change the colour from the scripting API. Eventually I tried changing the colour to blue, and everything went black. I was super confused why this one colour wouldn't work. Eventually I went back into the shader and found that it only displays when certain colours are picked and I have NO idea why (see below).

I was hoping someone might know why this is happening.


Replies

  • Eric Chadwick
    I would try simplifying the shader, removing nodes, and testing input variations.

    For example, the output of the first Multiply after Time... why is this green? I would see if you can make the output grayscale instead. 
  • rollin
    Offline / Send Message
    rollin polycounter
    How does the Texture2D asset looks like? If it's not a whitish color this could mean the result might go towards zero when multiplied with a specific color.
  • Vranvs
    Offline / Send Message
    Vranvs polycounter lvl 6
    I would try simplifying the shader, removing nodes, and testing input variations.

    For example, the output of the first Multiply after Time... why is this green? I would see if you can make the output grayscale instead. 


    Hi Eric, thanks so much for getting back to me. I have tried messing around with things, and, you're right -- I have no idea why that node is green. I feel like that may have something to do with it, though,  later on in the ORIGINAL graph I posted, you can see that even with a colour that doesn't work, the texture still shows up before the final output, which shows (I think) that that colour is possible to have. Hopefully that makes sense. In other words, something is 'going wrong' between the final multiply node and the PBR master. At least, that is my interpretation of it :). Any idea how would I go about making that node grayscale? I tried with a 'Color Mask' node, but I dont know if this is right:



    rollin said:
    How does the Texture2D asset looks like? If it's not a whitish color this could mean the result might go towards zero when multiplied with a specific color.
    Hi Rollin, thanks for your reply. Here is the texture I am using:



  • rollin
    Offline / Send Message
    rollin polycounter
    I would try simplifying the shader, removing nodes, and testing input variations.

    For example, the output of the first Multiply after Time... why is this green? I would see if you can make the output grayscale instead. 
    I would say it's just a vector representation, isn't it?

    Edit: from what I can see everything looks the same until you multiply the final color. 
    But I'm not sure what's going on. Could you - for the sake of it - give the color an alpha of 1.
  • Vranvs
    Offline / Send Message
    Vranvs polycounter lvl 6
    rollin said:
    I would try simplifying the shader, removing nodes, and testing input variations.

    For example, the output of the first Multiply after Time... why is this green? I would see if you can make the output grayscale instead. 
    I would say it's just a vector representation, isn't it?

    Edit: from what I can see everything looks the same until you multiply the final color. 
    But I'm not sure what's going on. Could you - for the sake of it - give the color an alpha of 1.
    Sure, I have set the Alpha to 1 and screenshotted for you:

  • rollin
    Offline / Send Message
    rollin polycounter
    I meant 1.0f .. Anyway. I have rebuild the graph and it does work. Maybe you have something on top - maybe from the render pipeline - which could interfere? 

    Which version of Shader Graph are you using?
    What is this 'Hybrid Instanced (experimental)' Color property thing?
    Why is the color a gradient and how is this supposed to be applied?
  • Vranvs
    Offline / Send Message
    Vranvs polycounter lvl 6
    Hello,

    I'm using Shader Graph 7.3.1.


    Notably, I upgraded to the Universal Render Pipeline, because I am trying to get Post Processing effects to work. They don't seem to work either (I have reported each of these things to Unity as a bug, lol). 

    I am not sure what the Hybrid Instanced (experimental) thing is, but it is disabled. If you look really closely there is actually a checkbox to the right of those words. I tried toggling on and it still happens. I was able to find this documentation:
    https://docs.unity3d.com/Packages/com.unity.rendering.hybrid@0.4/manual/index.html?_ga=2.239563971.1372723096.1588613468-1889677728.1588613468

    The color is of type HDR, which makes it look like a gradient in the picker.  I'm applying the colour to the emission channel so the stars are light sources.
  • rollin
    Offline / Send Message
    rollin polycounter
    Got it.. the answer is: Unity takes the first channel from a multi channel input if the receiving slot takes only one value. And for the alpha slot this becomes the red channel  and it gets zero when you choose blue as color and bam! gone are the stars
  • Vranvs
    Offline / Send Message
    Vranvs polycounter lvl 6
    Oh interesting! Thank you so much!!! Fixed :)
Sign In or Register to comment.