Search Unity

Question Directional light didn't show up in standalone build

Discussion in 'High Definition Render Pipeline' started by Zolden, Nov 13, 2022.

  1. Zolden

    Zolden

    Joined:
    May 9, 2014
    Posts:
    141
    I'm using Unity 2022.2.0b13 and HDRP 14.0.3

    This is how the scene looks when I run the game in editor:




    And this is how it looks in the build:

    upload_2022-11-13_2-13-15.png


    No directional/environment light. But point light, material emission and particles are visible.

    Any ideas what could be the reason and what can I do to fix this? I'd like at least to understand if it's a bug or I did something wrong.
     
    Last edited: Nov 13, 2022
  2. Zolden

    Zolden

    Joined:
    May 9, 2014
    Posts:
    141
    I still don't have this fixed. Could anyone suggest what could I try to do to solve this?
     
  3. SebLagarde

    SebLagarde

    Unity Technologies

    Joined:
    Dec 30, 2015
    Posts:
    934
    Hi,

    not simple to know what is happening, so I will do a random suggestion here.
    Maybe the shader variant you are using have been stripped out by the hdrp stripper, causing the direcitonal light code to not appear. (At least when we see difference between editor and build, it is usually because of this).

    But now the question is why the variant have been stripped out. And you can have multiple cause.
    - is you shader used a builtin shader from hdrp or a custom one you have done or get from somewhere?
    - could you try the same scene with a builtin shader (like replacign all materials by a lit.shader grey) and see if lighting is correct?
    - are you using forward or deferred for the lit shader mode?

    if it works by replacing by a basic shader, then indeed it may come from incorrect stripping.

    need this first step to diagnostic
     
  4. Zolden

    Zolden

    Joined:
    May 9, 2014
    Posts:
    141
    Hey! Thanks for trying to help.

    I have some legacy shaders in the projects, mostly on particles. Also, there are a couple of custom shaders that I got from an asset, and they don't even compile because of some error.

    deferred

    Oh, and I fixed the issue by manually grabbing the light and setting its intensity from code.

    Code (CSharp):
    1. HDAdditionalLightData lightData;
    2. lightData = GameObject.Find ("directionalLight").GetComponent<HDAdditionalLightData>();
    3. lightData.SetIntensity(100000, LightUnit.Lux);
    By some reason it helped.