Search Unity

Bug Subscene entities rendering without fog

Discussion in 'DOTS Graphics' started by rodellison, Sep 2, 2021.

  1. rodellison

    rodellison

    Joined:
    Oct 3, 2014
    Posts:
    23
    Hi, just learning how to use DOTS/Subscenes, but stumbling on a rendering issue I can't figure out..
    Using 2020.3.13f, URP 10.6, HybridRenderV2 0.11.0-preview.44 with a project that has a main scene that includes a sub-scene. The entities materials are using a fairly simple shadergraph lit shader.

    The scene environment is using Fog. Testing the scene In the editor, everything - including the sub-scene entities are rendered correctly with fog producing the appropriate distanced effect.
    i.e. All columns except the center 4 are background entity columns loaded as part of the sub-scene that look correct:
    upload_2021-9-2_12-11-13.png

    However, when I go to compile the app to a standalone windows (using the build/windows classic build config) the entities loaded in the sub-scene appear unobscured by fog, ..it's like fog doesn't see them.
    upload_2021-9-2_12-0-58.png

    Any ideas I should be looking at?
     
  2. JussiKnuuttila

    JussiKnuuttila

    Unity Technologies

    Joined:
    Jun 7, 2019
    Posts:
    105
    One possible cause for an issue like this could be if the fog variant of the shader has been stripped from the standalone build for some reason, possibly because of a bug, and the entities are rendered with a variant that doesn't have fog support.

    It should be possible to take a RenderDoc capture with shader debug symbols enabled (shader needs to have
    #pragma enable_d3d11_debug_symbols
    , so you have to either edit the Shader Graph template or copy paste the generated code to a separate test shader) to find out whether the fog keyword is enabled for the draw call.
     
    rodellison likes this.
  3. rodellison

    rodellison

    Joined:
    Oct 3, 2014
    Posts:
    23
    Thanks, this definitely pointed me in the right direction re: stripped shaders. I was unaware of the 'Fog modes' setting in Graphics. Ultimately, I solved my particular problem by simply changing the Project Settings/Graphics/Shader stripping/Fog Modes value from 'Automatic' to Custom, no other changes.
    upload_2021-9-2_13-21-15.png
     
    Last edited: Sep 2, 2021
    JussiKnuuttila likes this.
  4. apkdev

    apkdev

    Joined:
    Dec 12, 2015
    Posts:
    144
    Also note that, if I understand correctly, including unused fog modes could have a very large impact on shader compilation times (which in my projects already usually constitute >90% of build time, despite excellent parallelisation on a 16-core cpu...).

    I am actually wondering if it wouldn't be more practical if unity offerred a single, project-wide fog mode setting. In URP/HDRP the amount of shader variants very easily explodes into (tens of) thousands.

    Stripping is a thing, but it's difficult to set up, and easily breaks during development, and when it does apparently there's no error message. Is there a reason for this? Why not even store some metadata at build time and log "shader variant XYZ can't be loaded because of build script MyShaderStripping/graphics setting UVW/render pipeline asset ABC"? Or at least the missing keywords and shader name?

    This is very useful information, but I don't think it's viable that I do this whenever QA notices that an object is missing/looks wrong in a build, which tends to be a somewhat common occurrence.

    Edit: it appears that the latest alpha will log useful info regarding missing shaders: https://forum.unity.com/threads/strict-shader-variant-matching.1167008/
     
    Last edited: Sep 7, 2021
    rodellison likes this.
  5. rodellison

    rodellison

    Joined:
    Oct 3, 2014
    Posts:
    23
    Agree, I went back and unchecked the linear and exponential that my small project wasn't using, and definitely an improvement in compile/build time. Now going to investigate de-selecting unused lightmap modes as well. Live and learn.
     
  6. mingwai

    mingwai

    Small Graphics Potato Unity Technologies

    Joined:
    Jan 16, 2017
    Posts:
    30
    Hi rodellison, do you mind making a bug report so that we can investigate? (make sure you attach you project that can reproduce the issue!)

    I tried on my side using the same Unity, Graphics and HybridRenderer versions as yours. The Fog is working fine in player and the build stripped the fog variants that the scene is not using, which is correct.
     
  7. rodellison

    rodellison

    Joined:
    Oct 3, 2014
    Posts:
    23
    Hi Mingwai, I'll take a look at doing that.. I can confirm if I select Project Settings/Graphics/Shader stripping/Fog Modes 'Custom' and manually select the Fog mode that I know the scene (and sub-scene) uses, that it does include the fog variant for my entities sub-scene shaders/materials and the buildconfig output looks correct and has everything it needs. The problem/bug that I believe might be present is that when using Fog mode 'Automatic', that mode may not be looking into the sub-scene such to include the scene's environmental fog mode for the materials on those entities. I'll put together a small demo scene and submit a bug report just in case..
     
    mingwai likes this.
  8. rodellison

    rodellison

    Joined:
    Oct 3, 2014
    Posts:
    23
    Submitted demo project and case: (Case 1363446) Sub-Scene shader fog variants missing when using buildconfig and subscene not in initial loaded scene

    Experimented a little further, and found the issue doesn't occur if using buildconfig and the scene (containing subscene) is the first/only/autoloaded scene. In my case, I use a manager scene as the initial scene, which is responsible for loading subsequent scenes. That's when the FogMode=Automatic issue occurs and the subscene entities don't render with fog.
     
    mingwai and apkdev like this.
unityunity