using System.Collections.Generic;
namespace UnityEngine.Rendering.LookDev
{
///
/// Interface that Scriptable Render Pipelines should implement to be able to use LookDev window
///
public interface IDataProvider
{
/// Additional configuration required by this SRP on LookDev's scene creation
/// Access element of the LookDev's scene
void FirstInitScene(StageRuntimeInterface stage);
/// Notify the SRP that sky have changed in LookDev
/// The camera of the LookDev's scene
/// The new Sky informations
/// Access element of the LookDev's scene
void UpdateSky(Camera camera, Sky sky, StageRuntimeInterface stage);
/// Notify the LookDev about what debug view mode are available in this SRP
/// The list of the mode, None is not required.
IEnumerable supportedDebugModes { get; }
/// Notify the SRP about a change in the DebugMode used
///
/// -1: None
/// Others: map the result of
///
void UpdateDebugMode(int debugIndex);
///
/// Compute the shadow mask in SRP for LookDev sun simulation
///
/// The computed ShadowMask
/// Access element of the LookDev's scene
void GetShadowMask(ref RenderTexture output, StageRuntimeInterface stage);
///
/// Callback called at the beginning of LookDev rendering.
///
/// Access element of the LookDev's scene
void OnBeginRendering(StageRuntimeInterface stage);
///
/// Callback called at the beginning of LookDev rendering.
///
/// Access element of the LookDev's scene
void OnEndRendering(StageRuntimeInterface stage);
///
/// Callback called to do any necessary cleanup.
///
/// Access element of the LookDev's scene
void Cleanup(StageRuntimeInterface SRI);
}
///
/// Runtime container representing Sky data given to the scriptable render pipeline for rendering
///
public struct Sky
{
/// The cubemap representing this sky
public Cubemap cubemap;
/// The longitude offset to rotate this cubemap
public float longitudeOffset;
/// The sky exposure
public float exposure;
}
/// Runtime link to reflect some Stage functionality for SRP editing
public class StageRuntimeInterface
{
System.Func m_AddGameObject;
System.Func m_GetCamera;
System.Func m_GetSunLight;
/// Construct a StageRuntimeInterface
/// Callback to call when adding a GameObject
/// Callback to call for getting the Camera
/// Callback to call for getting the sun Light
public StageRuntimeInterface(
System.Func AddGameObject,
System.Func GetCamera,
System.Func GetSunLight)
{
m_AddGameObject = AddGameObject;
m_GetCamera = GetCamera;
m_GetSunLight = GetSunLight;
}
/// Create a gameObject in the stage
///
/// [OPTIONAL] If true, the object is not recreated with the scene update.
/// Default value: false.
///
/// The newly created GameObject, or null if the creation process failed.
public GameObject AddGameObject(bool persistent = false)
=> m_AddGameObject?.Invoke(persistent);
/// Get the camera used in the stage
public Camera camera => m_GetCamera?.Invoke();
/// Get the sun used in the stage
public Light sunLight => m_GetSunLight?.Invoke();
/// Custom data pointer for convenience
public object SRPData;
}
}