Search Unity

Any options to merge the ForwardAdd pass with the ForwardBass pass?

Discussion in 'Shaders' started by sschaem, Nov 18, 2016.

  1. sschaem

    sschaem

    Joined:
    Feb 14, 2014
    Posts:
    148
    Another way to ask, can the ForwardBass pass get access to additional local light information?

    I would like to merge the forward bass/add pass into a single pass that support 1 directional + 1 point light
     
  2. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,097
    Very short answer:
    Nope.

    Slightly longer short answer:
    As long as you're okay with only 4 lights that don't have shadows and don't 100% match the fall off of per pixel lights, any shader without a forward add pass will include the first 4 additional lights as vertex lights. This would be using either ShadeVertexLightsFull() which supports spot lights or Shade4PointLights() which does not.

    Much longer answer:
    If you want full single pass lighting support you have to completely replace Unity's lighting and shadowing systems. An example of this is Valve's Lab Renderer. Unity also has plans for this using its Scriptable Render Loop which is is being experimented with internally at Unity and while publicly accessible currently only runs on a non public branch of 5.6 or 5.7.
     
  3. sschaem

    sschaem

    Joined:
    Feb 14, 2014
    Posts:
    148
    Thanks again for taking the time.

    I'm not sure ShadeVertexLightsFull() can be used in the ForwardBase.
    The frame debugger show that the light position[]/attenuation[] not set.

    But Shade4PointLights() can be evaluated in the base pass, those are set.
    unity_4LightPosX0, unity_4LightPosY0, unity_4LightPosZ0, unity_4LightAtten0

    Unless I'm missing something, it seem the ForwardBase can indeed support 4 point lights but no spotlights.

    edit: Shade4PointLights() doesn't seem to work correctly when invoked in the pixel shader.
    The attenuation seem wrong.
     
    Last edited: Nov 19, 2016
  4. bgolus

    bgolus

    Joined:
    Dec 7, 2012
    Posts:
    8,097
    The attenuation for those functions are both approximate matches for the normal per pixel fall off brightness, but they use a fall off equation that doesn't actually have a max range so they do not match.
     
  5. rob_ice

    rob_ice

    Joined:
    Nov 11, 2016
    Posts:
    112
    Is it at all possible to use a point light shadow pass in a transparent shader? It's in the interests of blending shadows with AR surfaces not just including a directional light
     
unityunity