Material Ambient Light

A new update is now available, introducing seasons and more!
  • Hi, looks like material that are assigned to prefabs in bundle are not affected by scene ambient light.


    In editor:


    In game:


    That happens only with material that were assigned to assets by default in bundle, if material was created with code it will be fine:


    Is it possible to fix/avoid this?

  • I'm not sure, but this bug can be related to missing scripts in objects. Unity HDRP uses small scripts attached to objects as guidelines for shading engine, and in my experiments I noticed that all scripts attached to objects are not exported. Probably objects don't receive environment information due to missing HDRP scripts? If this is true then fix will be just adding these scripts to assets programmatically (from API side or from plugin side)

  • Sorry for my late response! It looks like that Unity is apparently stripping some shader variants when building the asset bundles (which are required to receive ambient light correctly)... I don't think we can fix that ingame (e.g. when loading the plugin), unless the default HDRP lit/unlit shader is used, so this needs to be done when building the bundles. I'll take a closer look at this issue and report back once I have a solution :)


    in my experiments I noticed that all scripts attached to objects are not exported. Probably objects don't receive environment information due to missing HDRP scripts?

    The reason is that the game uses IL2CPP, which doesn't support scripts loaded from asset bundles unfortunately (which is a pity)... but it's not causing this issue. HDRP only uses specific scripts for certain components (like cameras or lights), but they should still work in asset bundles.

  • In my example above I used default lit shader. That actually happens to both default and custom shaders - they just don't receive scene environment light

    Yes, it happens for any shader, but I just meant that we could fix it retroactively if the element uses the default HDRP lit/unlit shader ^^ The game has its own copy of that shader in cache (which includes all necessary shader variants), so we could basically just replace the shader manually when loading the prefab. But of course that doesn't work for custom shaders, so it would be only a partial solution :/

Participate now!

Don’t have an account yet? Create a new account now and be part of our community!