Search code examples
unity-game-engineshaderskyboxshaderlab

ShaderLab use default unity skybox


All of the reflection examles set the Cubemaps with the property like:

Properties {
  _Cube("Reflection Map", Cube) = "" {}
}

But i want to use the skybox from "Lighting" for all shaders. How to do that?


Solution

  • use unity_SpecCube0, here's a simple version of the sampling with unity's helper functions

    half3 GetCube(half3 _vector, half _smoothness) {
       half mip = _smoothness * 6.0;
       half4 rgbm = UNITY_SAMPLE_TEXCUBE_LOD(unity_SpecCube0, _vector, mip);
       return DecodeHDR(rgbm, unity_SpecCube0_HDR);
    }