Search Unity

Multiply shadows from previous/specific light source?

Discussion in 'Shaders' started by domjon, Oct 9, 2020.

  1. domjon

    domjon

    Joined:
    Oct 14, 2012
    Posts:
    12
    In a scene say have two or more point lights:
    1 - A regular shadow-casting point light
    2 - A "primary" shadow-casting point light (prioritized with 0 alpha color)

    Is it possible to create a lit shader, but have the brightness always be multiplied by this "Primary" point light's shadow info?

    Basically, trimming all other light color with the Primary light's shadow...

    It would look something like this:

    I've been playing around with a surf shader and Lighting.cginc (pipelines don't matter here), and can differentiate between the two kinds of lights, but I'm not sure how to order the lights (if possible), or how to access other light shadow info (if possible).

    Familiar enough with shaders, but not nearly as smart as you lovely people on here are. Insights greatly appreciated! :)
     
  2. domjon

    domjon

    Joined:
    Oct 14, 2012
    Posts:
    12
    Figured it out!

    At first was thinking I had to transfer shadows, or use fancy stencil things, but really was just a simple matter of making a shader with 2 passes and making use of the Blend features.

    First pass for the primary light which uses
    Blend One One

    Second pass for the remaining lights which uses
    Blend DstColor One

    Each going to a custom lighting function that could multiply itself by its own _LightColor0.a to differentiate which lights to omit from which pass.

     
  3. pinochetlab_unity

    pinochetlab_unity

    Joined:
    Dec 10, 2022
    Posts:
    1
    Di u find soution? I have the same problem(