Search Unity

Custom HDRI skybox not rendered in final build

Discussion in 'High Definition Render Pipeline' started by Just_Lukas, Sep 29, 2019.

  1. Just_Lukas

    Just_Lukas

    Joined:
    Feb 9, 2019
    Posts:
    34
    Yo, I have a problem with my custom HDRI skybox not rendering when I build the game. I followed instructions from this official website: https://docs.unity3d.com/Packages/c...inition@6.7/manual/Creating-a-Custom-Sky.html but since it uses outdated HDRP scripts (HDRISky , HDRISkyRenderer) I've copied their newest 6.9.1 versions from my project.

    Reason why I have to use custom HDRI sky override is because I need skybox rotation on different axis than the defaul one provides.

    The problem is that editor renders my custom skybox normally without any warnings or errors:



    but once I build my game, this is what it shows:



    Just a blank blue skybox, scripts I use are here as well. Any help will be much appreciated.
     

    Attached Files:

  2. Just_Lukas

    Just_Lukas

    Joined:
    Feb 9, 2019
    Posts:
    34
    Okay problem was on line 21 in CustomHDRISkyRenderer:

    Code (CSharp):
    1. m_SkyHDRIMaterial = CoreUtils.CreateEngineMaterial(Shader.Find("Custom/HDRISky"));
    According to this link: https://docs.unity3d.com/ScriptReference/Shader.Find.html
    "Note that a shader might be not included into the player build if nothing references it! In that case, Shader.Find will work only in the editor, and will result in pink "missing shader" materials in the player build." So this is why my shader was working in the editor but not in the build.

    SOLUTION: Move the .shader file into Resources folder and load it with Resources.Load<Shader>(...) istead of using Shader.Find.
     
    sarahnorthway likes this.
  3. eizenhorn

    eizenhorn

    Joined:
    Oct 17, 2016
    Posts:
    2,684
    Always included shaders in graphics setting for purpose of include not referenced (directly) shaders in to build
     
  4. karl_kent

    karl_kent

    Joined:
    Feb 1, 2018
    Posts:
    10
    You need to include the shader tn the graphics settings to the " Built-in Shaders " list