namespace UnityEngine.Rendering.HighDefinition { /// /// Parameters to override sun light cookie. /// public struct CookieParameters { /// The 2D cookie texture to use. public Texture texture; /// The size of the projected cookie texture in pixels. public Vector2 size; /// The world space position to use as projection origin. public Vector3 position; } /// /// Base class for cloud rendering. /// public abstract class CloudRenderer { int m_LastFrameUpdate = -1; /// Determines if the clouds 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(); /// /// Get the parameters for overriding the main directional light cookie for one frame. /// /// Current cloud settings. /// Overriden values for cookie parameters. /// True if the cookie should be overriden and RenderSunLightCookie should be called. public virtual bool GetSunLightCookieParameters(CloudSettings settings, ref CookieParameters cookieParams) { return false; } /// /// HDRP calls this function once every frame where GetSunLightCookieParameters returns true. /// Implement it if your CloudRenderer needs to render a texture to use for the light cookie (for example for cloud shadow rendering). /// /// Engine parameters that you can use to render the sun light cookie. public virtual void RenderSunLightCookie(BuiltinSunCookieParameters builtinParams) { } /// /// HDRP calls this function once every frame. Implement it if your CloudRenderer needs to iterate independently of the user defined update frequency (see CloudSettings UpdateMode). /// /// Engine parameters that you can use to update the clouds. /// True if the update determines that cloud lighting needs to be re-rendered. False otherwise. protected virtual bool Update(BuiltinSkyParameters builtinParams) { return false; } /// /// Preprocess for rendering the clouds. Called before the DepthPrePass operations /// /// Engine parameters that you can use to render the clouds. /// Pass in true if you want to render the clouds into a cubemap for lighting. This is useful when the cloud renderer needs a different implementation in this case. public virtual void PreRenderClouds(BuiltinSkyParameters builtinParams, bool renderForCubemap) { } /// /// Whether the PreRenderClouds step is required. /// /// Engine parameters that you can use to render the clouds. /// True if the PreRenderClouds step is required. public virtual bool RequiresPreRenderClouds(BuiltinSkyParameters builtinParams) { return false; } /// /// Implements actual rendering of the clouds. HDRP calls this when rendering the clouds into a cubemap (for lighting) and also during main frame rendering. /// /// Engine parameters that you can use to render the clouds. /// Pass in true if you want to render the clouds into a cubemap for lighting. This is useful when the cloud renderer needs a different implementation in this case. public abstract void RenderClouds(BuiltinSkyParameters builtinParams, bool renderForCubemap); internal bool DoUpdate(BuiltinSkyParameters parameters) { if (m_LastFrameUpdate < parameters.frameIndex) { m_LastFrameUpdate = parameters.frameIndex; return Update(parameters); } return false; } internal void Reset() { m_LastFrameUpdate = -1; } } }