namespace UnityEngine.Rendering.HighDefinition { /// /// Base class for sky rendering. /// public abstract class SkyRenderer { int m_LastFrameUpdate = -1; /// Determines if the sky should be rendered when the sun light changes. public bool SupportDynamicSunLight = true; /// /// Called on startup. Create resources used by the renderer (shaders, materials, etc). /// public abstract void Build(); /// /// Called on cleanup. Release resources used by the renderer. /// public abstract void Cleanup(); /// /// HDRP calls this function once every frame. Implement it if your SkyRenderer needs to iterate independently of the user defined update frequency (see SkySettings UpdateMode). /// /// Engine parameters that you can use to update the sky. /// True if the update determines that sky lighting needs to be re-rendered. False otherwise. protected virtual bool Update(BuiltinSkyParameters builtinParams) { return false; } /// /// Preprocess for rendering the sky. Called before the DepthPrePass operations /// /// Engine parameters that you can use to render the sky. /// Pass in true if you want to render the sky into a cubemap for lighting. This is useful when the sky renderer needs a different implementation in this case. /// If the sky renderer supports the rendering of a sun disk, it must not render it if this is set to false. [System.Obsolete("Please override PreRenderSky(BuiltinSkyParameters) instead.")] public virtual void PreRenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap, bool renderSunDisk) { PreRenderSky(builtinParams); } /// /// Preprocess for rendering the sky. Called before the DepthPrePass operations /// /// Engine parameters that you can use to render the sky. public virtual void PreRenderSky(BuiltinSkyParameters builtinParams) {} /// /// Whether the PreRenderSky step is required. /// /// Engine parameters that you can use to render the sky. /// True if the PreRenderSky step is required. public virtual bool RequiresPreRenderSky(BuiltinSkyParameters builtinParams) { return false; } /// /// Implements actual rendering of the sky. HDRP calls this when rendering the sky into a cubemap (for lighting) and also during main frame rendering. /// /// Engine parameters that you can use to render the sky. /// Pass in true if you want to render the sky into a cubemap for lighting. This is useful when the sky renderer needs a different implementation in this case. /// If the sky renderer supports the rendering of a sun disk, it must not render it if this is set to false. public abstract void RenderSky(BuiltinSkyParameters builtinParams, bool renderForCubemap, bool renderSunDisk); /// /// Returns exposure setting for the provided SkySettings. /// /// SkySettings for which exposure is required. /// Current debug display settings /// Returns SkySetting exposure. protected static float GetSkyIntensity(SkySettings skySettings, DebugDisplaySettings debugSettings) { return skySettings.GetIntensityFromSettings(); } /// /// Setup global parameters for the sky renderer. /// /// Command buffer provided to setup shader constants. /// Sky system builtin parameters. public virtual void SetGlobalSkyData(CommandBuffer cmd, BuiltinSkyParameters builtinParams) { } internal bool DoUpdate(BuiltinSkyParameters parameters) { if (m_LastFrameUpdate < parameters.frameIndex) { m_LastFrameUpdate = parameters.frameIndex; return Update(parameters); } return false; } } }