Search Unity

Resolved Some shaders not rendering in build

Discussion in 'Graphics for ECS' started by Thygrrr, Mar 15, 2023.

  1. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    I fixed up my project to build to investigate some performance issues I have been seeing.
    Two shaders (but not all - the terrain outline an the ship icons (not in this screen) are also on an entity) do not render in the build.

    Where do I start looking?

    At Runtime, I can see this:
    upload_2023-3-15_8-54-53.png

    But I have added the respective shaders to "Always Include" and I have explicitly specified the fog modes uses.

    Interestingly, the "unshaded" fragments behave like a depth mask (though the skybox is showing through them and it's not uninitilaized HOM). They are made with ShaderGraph, the one on the spaceships is a super basic URP Lit shader with a material prop from ECS for the color, the other is just an opaque, custom lit shader.

    Actual:
    upload_2023-3-15_8-43-38.png

    Expected:
    upload_2023-3-15_8-40-16.png
     

    Attached Files:

    Last edited: Mar 15, 2023
  2. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    upload_2023-3-15_8-58-13.png

    some progress, but... HUH? Especially these variants should be expressly included
     
  3. Thygrrr

    Thygrrr

    Joined:
    Sep 23, 2013
    Posts:
    700
    Resolved (for current purposes): I turned off
    Strict Shader Variant Matching
    and now it renders as expected, but it's unclear why it removed them, I believed they were in the shader variants collection.

    upload_2023-3-15_9-9-0.png
     
    Last edited: Mar 15, 2023
  4. itelefon

    itelefon

    Joined:
    Apr 7, 2015
    Posts:
    2
    Did you submit this in a bug report? We also encountered this issue and couldn't find anything for a long time, only accidentally found a solution ourselves and only then found this forum. We spent a lot of time on this.
     
  5. mingwai

    mingwai

    Small Graphics Potato Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    52
    Hi, we have a known issue that the shader variant is being stripped if your scene has a different fog / lightmap mode with the subscene. Turning strict shader variant matching OFF could means that the object is using a fallback shader variant which rendering could be wrong.

    Try these to see if it fixes your issue:

    Method (1):
    1. Open ProjectSettings > Graphics > Shader Stripping
    2. On Fog Modes / Lightmap Modes, select Custom
    3. Click on Import from current scene, or select the correct modes to make sure subscene objects have the correct fog and lightmap modes to build shader variants, In your case, the error mentions FOG_EXP so you should tick the checkbox "Exponential" for Fog Modes.

    Method (2):
    1. Open the subscene and apply the same fog / lighting settings on the Lighting Panel as the original scene