Directional light didn't show up in standalone build

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:

8581843--1149847--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.

I still don’t have this fixed. Could anyone suggest what could I try to do to solve this?

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

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.

HDAdditionalLightData lightData;
lightData = GameObject.Find ("directionalLight").GetComponent<HDAdditionalLightData>();
lightData.SetIntensity(100000, LightUnit.Lux);

By some reason it helped.