Search Unity

  1. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Build (player) doesn't render and stays black after implementing and using a custom sky

Discussion in 'High Definition Render Pipeline' started by sebastianzander, Aug 28, 2019.

  1. sebastianzander

    sebastianzander

    Joined:
    Mar 22, 2018
    Posts:
    37
    For the protocol: I am using
    Unity 2019.1.10f1
    High Definition RP Version 5.16.1 (preview)

    additionally:
    Visual Effects Graph Version 5.16.1 (preview)
    Input System Version 0.93 (preview)

    I recently implemented my very own custom sky (UnityEngine.Experimental.Rendering.HDPipeline.SkySettings) according to this tutorial. Its named CompoundSky. I did base my CompoundSky : SkySettings, CompoundSkyRenderer : SkyRenderer, CompoundSkyEditor : SkySettingsEditor and CompoundSky.shader on both the ProceduralSky and HDRISky scripts from my preview package (not the version that was references in the tutorial because some namespaces and class names have apparently changed). You can find the actual source files attached.

    Meaning and function of my custom sky is to use the procedural sky functionality (which I quite like) and blend in a starry night sky cubemap for my dynamic day/night cycle. It works great in the editor, no problems or warnings at all (screenshot attached). However, if I build the Player (PC, Mac & Linux Standalone with default settings) and I run it then after the splash screen is finished it remains visible until I change the screen resolution or toggle between window and full screen mode. After that the screen remains black. Solely the UI (canvas) is rendered and updated. The scene is normally loaded however and "playable", I can hear my sound effects and music playing and I can control my vehicle. It's just that no rendering takes place.

    I ascribe this to my custom sky (probably my custom shader, although using two cubemaps not that special computationally) because after I switched back to the standard ProceduralSky the Player worked normally. I am going to test of the normal HDRISky works though since I have never used it (with HDRP) until now (update: normal HDRISky works so no simple cubemap issue).

    I am hopeful that someone has a simple fix for me or can tell me what I did wrong.

    Additional notice: I use two global Scene Settings volumes. One for the daytime and one for the night time. Although many parameters are animated by a script and it may be achieved with only one I chose to use two volumes and blend between them using the Weight parameter. Both Scene Settings use my CompoundSky and it is also set in Visual Environment / Sky / Type.

    Thank you in advance for any advice.

    Sebastian
     

    Attached Files:

    Last edited: Aug 28, 2019
  2. sebastianzander

    sebastianzander

    Joined:
    Mar 22, 2018
    Posts:
    37
    I found the solution to my problem. In the Player.log file the following error gave it away:

    NullReferenceException: Object reference not set to an instance of an object
    at UnityEngine.Rendering.CoreUtils.SetKeyword (UnityEngine.Material m, System.String keyword, System.Boolean state) [0x00003] in <cf86b61f521b422b81e05f9f6a110997>:0
    at CompoundSkyRenderer.RenderSky (UnityEngine.Experimental.Rendering.HDPipeline.BuiltinSkyParameters builtinParams, System.Boolean renderForCubemap, System.Boolean renderSunDisk) [0x0001b] in <31bad814dfce409cb32557fc8c03b493>:0
    at...


    The error originates at CompoundSkyRenderer.cs:56
    Code (CSharp):
    1. CoreUtils.SetKeyword(m_CompoundSkyMaterial, "_ENABLE_SUN_DISK", m_CompoundSky.enableSunDisk.value);
    but its actual origin is at CompoundSkyRenderer.cs:37
    Code (CSharp):
    1. m_CompoundSkyMaterial = CoreUtils.CreateEngineMaterial(Shader.Find("Hidden/HDRP/Sky/CompoundSky"));
    As one can read here, Shader.Find does only work in game builds if you either:
    I went for 2), added my CompoundSky.shader to the "Always Included Shaders" list, built my game and now it works!


    BTW: why does the forum think that lines of text above are spam when I try to edit my original post? I could understand it if I would make post after post instead of editing, but so? I noticed it a couple of times now that the spam-filter seems to have a lot of false-positives.
     
    Last edited: Aug 29, 2019