Search Unity

Question Shader graph always uses _ADDITIONAL_LIGHTS_VERTEX keyword by default

Discussion in 'Shader Graph' started by raingame_, Aug 2, 2021.

  1. raingame_

    raingame_

    Joined:
    Jan 15, 2019
    Posts:
    28
    Hi guys, I noticed that all shaders created with ShaderGraph have _ADDITIONAL_LIGHTS_VERTEX by default, and it only changes to _ADDITIONAL_LIGHTS keyword if there is some additional lights in the scene (Point LIght, Secondary dir light or spot light). What is the logic behind that? Why all shader graph shaders have this keyword? Can I see the code somewhere? Tried to find it in URP package code but I didn't succeeded. Thanks!

    upload_2021-8-2_17-46-42.png
     
  2. insignifantastica

    insignifantastica

    Joined:
    Apr 22, 2020
    Posts:
    10
    Late response, but anyone found this post and If you used URP,
    URP asset Lighting section's additional lights part define _ADDITIONAL_LIGHTS_VERTEX and
    _ADDITIONAL_LIGHTS.
    _VERTEX indicates to calculate additional light in vertex or fragment shader, corresponding to "Per Vertex" and "Per Pixel" options.
    In short, if you are using more than one light in the scene and enabled additional lights in URP assets, these keywords will be defined and shader will calculate light differently by the keywords.

    related post: https://forum.unity.com/threads/lwrp-questions.769868/
     
  3. raingame_

    raingame_

    Joined:
    Jan 15, 2019
    Posts:
    28
    hey, thanks for reply. I understand what you said. My question is why shader graph shaders have _ADDITIONAL_LIGHTS_VERTEX enabled by default even when there is no single additional light in scene. Like if you see simple unity cube keywords when there is no additional light in the scene, you see it doesn't have any keywords enabled, but gameobject which has material of shader graph shader has _ADDITIONAL_LIGHTS_VERTEX enabled. And if there is an additional light in the scene both of them have _ADDITIONAL_LIGHTS or _ADDITIONAL_LIGHTS_VERTEX keywords enabled depending on the urp asset settings.