Search Unity

Question Shader Graph Material shown in pink

Discussion in 'Shaders' started by Banstro, Feb 26, 2021.

  1. Banstro

    Banstro

    Joined:
    Dec 9, 2020
    Posts:
    1
    Hi, I'm starting to study shaders a bit, and I'm following different tutorials and so on.
    I use version 2019.4.12f1 HDRP, and the problem comes to me that "light" and "Light" appear unrecognizable, and the shader is pink.
    Attached screenshot of the .hlsl text and errors.
    How could I solve it?
    Thanks in advance.

    CapturaPantalla.jpg


    Error.jpg
    VisualStudio.jpg

    Shader.jpg
     
  2. lady_magnetic

    lady_magnetic

    Joined:
    Apr 15, 2020
    Posts:
    3
    Your code is working fine with the Universal Render Pipeline for me. If you are just playing with shaders in order to learn new stuff and Render Pipeline is not important, you could switch to URP and go on with the tutorial.

    As far as I can tell "Light", "GetMainLight()" and "LightingSpecular()" are defined in a file called Lighting.hlsl which is part of the Universal Render Pipeline. So you cannot use them in HDRP.

    If you want / need to stick with HDRP have a look at these posts, maybe you find something useful / practicable there (I have not tried them myself):
    https://forum.unity.com/threads/shader-graph-light-direction.615316/#post-4795292
    https://forum.unity.com/threads/hdrp-getmainlight.745943/

    There could be other posts etc. out there, these are just the first two I found useful.