Custom HDRI skybox not rendered in final build

Yo, I have a problem with my custom HDRI skybox not rendering when I build the game. I followed instructions from this official website: Redirecting to latest version of com.unity.render-pipelines.high-definition 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.

5012246–490415–CustomHDRISky.cs (1 KB)
5012246–490418–CustomHDRISkyRenderer.cs (2.79 KB)
5012246–490424–CustomHDRISkyShader.shader (2.91 KB)

Okay problem was on line 21 in CustomHDRISkyRenderer:

m_SkyHDRIMaterial = CoreUtils.CreateEngineMaterial(Shader.Find("Custom/HDRISky"));

According to this link: Unity - Scripting API: Shader.Find
“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(…) istead of using Shader.Find.

1 Like

Always included shaders in graphics setting for purpose of include not referenced (directly) shaders in to build

You need to include the shader tn the graphics settings to the " Built-in Shaders " list