public override void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap, bool renderSunDisk)
        {
            ProceduralSky skySettings = builtinParams.skySettings as ProceduralSky;

            CoreUtils.SetKeyword(m_ProceduralSkyMaterial, "_ENABLE_SUN_DISK", skySettings.enableSunDisk.value);

            // Default values when no sun is provided
            Color   sunColor     = Color.white;
            Vector3 sunDirection = Vector3.zero;
            float   sunSize      = 0.0f;

            if (builtinParams.sunLight != null)
            {
                sunColor     = builtinParams.sunLight.color * builtinParams.sunLight.intensity;
                sunDirection = -builtinParams.sunLight.transform.forward;
                sunSize      = skySettings.sunSize.value;
            }

            if (!renderSunDisk)
            {
                sunSize = 0.0f;
            }

            m_PropertyBlock.SetVector(_SkyParam, new Vector4(GetExposure(skySettings, builtinParams.debugSettings), skySettings.multiplier.value, 0.0f, 0.0f));
            m_PropertyBlock.SetFloat(_SunSizeParam, sunSize);
            m_PropertyBlock.SetFloat(_SunSizeConvergenceParam, skySettings.sunSizeConvergence.value);
            m_PropertyBlock.SetFloat(_AtmoshpereThicknessParam, skySettings.atmosphereThickness.value);
            m_PropertyBlock.SetColor(_SkyTintParam, skySettings.skyTint.value);
            m_PropertyBlock.SetColor(_GroundColorParam, skySettings.groundColor.value);
            m_PropertyBlock.SetColor(_SunColorParam, sunColor);
            m_PropertyBlock.SetVector(_SunDirectionParam, sunDirection);
            m_PropertyBlock.SetMatrix(_PixelCoordToViewDirWS, builtinParams.pixelCoordToViewDirMatrix);

            CoreUtils.DrawFullScreen(builtinParams.commandBuffer, m_ProceduralSkyMaterial, m_PropertyBlock, renderForCubemap ? 0 : 1);
        }
Beispiel #2
0
 public ProceduralSkyRenderer(ProceduralSky proceduralSkyParams)
 {
     m_ProceduralSkyParams = proceduralSkyParams;
     m_PropertyBlock       = new MaterialPropertyBlock();
 }