Search Unity

Resolved Get Unshaded Light Color in a Shader?

Discussion in 'Shaders' started by DimitriX89, Jan 6, 2023.

  1. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    551
    Returning to the topic of cartoon shaders, is there a way to get an original color of a light affecting the mesh? For example, to make a shader where areas below 0.5 RGB intensity are assigned some arbitrary "shaded color", and areas above are assigned color of the light source?
     
  2. Invertex

    Invertex

    Joined:
    Nov 7, 2013
    Posts:
    1,550
    Assuming you've already got a basic cell shader where light intensity has been computed (there's plenty of examples).
    Then really all you've have to do is:

    float3 col = lightIntensity <= 0.5 ? cellColor : _LightColor0;
     
    DimitriX89 likes this.
  3. DimitriX89

    DimitriX89

    Joined:
    Jun 3, 2015
    Posts:
    551
    _LightColor0 works as a charm; I needed to study built in variables more. Thanks!