Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.

Resolved Custom forward render pass shader has strange lighting issues

Discussion in 'High Definition Render Pipeline' started by b1gry4n, Sep 9, 2020.

  1. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    I have created a custom render pass to draw a quad and render using an amplify shader editor created shader. I describe my process in more detail in this thread: https://forum.unity.com/threads/cor...e-depth-offset-for-a-full-screen-quad.967018/

    Everything works as expected except for a strange issue with lighting. Every light in the scene appears to have some sort of billboard. I know it probably isnt a billboard but it behaves exactly like a billboard would. The shader does call light loop and it is a forward pass. I didnt write the forward pass, it generated by amplify shader editor. You can see in the video if I maneuver around the point where the light is the artifact rotates with me. Does anyone have any idea what this is or what causes this? Maybe point me in a direction that I can investigate to solve it? Thanks.

    Video:


     
  2. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    Here is another video with a blank texture that might help show the issue more clearly. The white texture is the shader, I toggle it on and off at some point in the video.

     
  3. b1gry4n

    b1gry4n

    Joined:
    Sep 11, 2013
    Posts:
    146
    I started to rewrite the shader by hand instead of using amplify shader editor to see if I could solve this. I was trying to get away with too much with the shader editor + custom render pass, I knew this but I wanted to see if I could. Turns out doing it by hand was better for this situation. I ended up solving this by decoding the gbuffer to retrieve the BSDFData data.
    Code (CSharp):
    1.  
    2. BSDFData bsdfData;
    3. BuiltinData builtinData;
    4. DECODE_FROM_GBUFFER(posInput.positionSS, UINT_MAX, bsdfData, builtinData);
    5. //color is the color from the triplanar map I set up earlier in the shader
    6. bsdfData.diffuseColor = color;
    After running this through the lightloop and drawing the diffuse I was still getting the billboard effect. I starting digging around in Lit.hlsl and more specifically LightLoopDef.hlsl and came across
    LIGHTLOOP_DISABLE_TILE_AND_CLUSTER
    . I decided to define it and it worked.


    I tried adding it to the amplify shader generated code and it didnt work, so it looks like I am going manual from here. At least the billboard effect is gone. At this point I dont have to apply a depth offset or any of the things I was trying to do with the amplify shader since this is just outputing color in a fullscreen image effect. Probably should have just done it this way from the start. Oh well.
     
    Last edited: Sep 10, 2020
    Olmi likes this.