Search Unity

Surface shader with a replaced/secondary light source?

Discussion in 'Shaders' started by Nichotine, Sep 23, 2019.

  1. Nichotine

    Nichotine

    Joined:
    Jul 30, 2017
    Posts:
    18
    Hi there,

    I'm trying to make a surface shader that performs the lighting calculation based on a provided light direction. Basically, I want the main directional light to cast shadows, but object surface to be lit by a different direction.

    I'm trying to do this with a custom lighting function, I am inputting the second light's direction vector to the shader, but I believe that everything in the lighting function is done in tangent space? I'm using a typical lambert function but I just want to replace the lightDir value with the secondary light's direction. I'm just unsure as to how I could convert to tangent space.

    All help is appreciated :)
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    12,342
    AFAIK once you get to the custom lighting function, all the operations are in world space, not tangent space. This is especially true if you're not using normal maps as the shader doesn't even use tangent space anywhere.