A game about forced loneliness, made by TACStudios
1using System.Collections.Generic;
2
3namespace UnityEngine.Rendering.LookDev
4{
5 /// <summary>
6 /// Interface that Scriptable Render Pipelines should implement to be able to use LookDev window
7 /// </summary>
8 public interface IDataProvider
9 {
10 /// <summary>Additional configuration required by this SRP on LookDev's scene creation</summary>
11 /// <param name="stage">Access element of the LookDev's scene</param>
12 void FirstInitScene(StageRuntimeInterface stage);
13
14 /// <summary>Notify the SRP that sky have changed in LookDev</summary>
15 /// <param name="camera">The camera of the LookDev's scene</param>
16 /// <param name="sky">The new Sky informations</param>
17 /// <param name="stage">Access element of the LookDev's scene</param>
18 void UpdateSky(Camera camera, Sky sky, StageRuntimeInterface stage);
19
20 /// <summary>Notify the LookDev about what debug view mode are available in this SRP</summary>
21 /// <value>The list of the mode, None is not required.</value>
22 IEnumerable<string> supportedDebugModes { get; }
23
24 /// <summary>Notify the SRP about a change in the DebugMode used</summary>
25 /// <param name="debugIndex">
26 /// -1: None
27 /// Others: map the result of <see cref="supportedDebugModes()"/>
28 /// </param>
29 void UpdateDebugMode(int debugIndex);
30
31 /// <summary>
32 /// Compute the shadow mask in SRP for LookDev sun simulation
33 /// </summary>
34 /// <param name="output">The computed ShadowMask</param>
35 /// <param name="stage">Access element of the LookDev's scene</param>
36 void GetShadowMask(ref RenderTexture output, StageRuntimeInterface stage);
37
38 /// <summary>
39 /// Callback called at the beginning of LookDev rendering.
40 /// </summary>
41 /// <param name="stage">Access element of the LookDev's scene</param>
42 void OnBeginRendering(StageRuntimeInterface stage);
43
44 /// <summary>
45 /// Callback called at the beginning of LookDev rendering.
46 /// </summary>
47 /// <param name="stage">Access element of the LookDev's scene</param>
48 void OnEndRendering(StageRuntimeInterface stage);
49
50 /// <summary>
51 /// Callback called to do any necessary cleanup.
52 /// </summary>
53 /// <param name="SRI">Access element of the LookDev's scene</param>
54 void Cleanup(StageRuntimeInterface SRI);
55 }
56
57 /// <summary>
58 /// Runtime container representing Sky data given to the scriptable render pipeline for rendering
59 /// </summary>
60 public struct Sky
61 {
62 /// <summary>The cubemap representing this sky</summary>
63 public Cubemap cubemap;
64 /// <summary>The longitude offset to rotate this cubemap</summary>
65 public float longitudeOffset;
66 /// <summary>The sky exposure</summary>
67 public float exposure;
68 }
69
70 /// <summary>Runtime link to reflect some Stage functionality for SRP editing</summary>
71 public class StageRuntimeInterface
72 {
73 System.Func<bool, GameObject> m_AddGameObject;
74 System.Func<Camera> m_GetCamera;
75 System.Func<Light> m_GetSunLight;
76
77 /// <summary>Construct a StageRuntimeInterface</summary>
78 /// <param name="AddGameObject">Callback to call when adding a GameObject</param>
79 /// <param name="GetCamera">Callback to call for getting the Camera</param>
80 /// <param name="GetSunLight">Callback to call for getting the sun Light</param>
81 public StageRuntimeInterface(
82 System.Func<bool, GameObject> AddGameObject,
83 System.Func<Camera> GetCamera,
84 System.Func<Light> GetSunLight)
85 {
86 m_AddGameObject = AddGameObject;
87 m_GetCamera = GetCamera;
88 m_GetSunLight = GetSunLight;
89 }
90
91 /// <summary>Create a gameObject in the stage</summary>
92 /// <param name="persistent">
93 /// [OPTIONAL] If true, the object is not recreated with the scene update.
94 /// Default value: false.
95 /// </param>
96 /// <returns>The newly created GameObject, or null if the creation process failed.</returns>
97 public GameObject AddGameObject(bool persistent = false)
98 => m_AddGameObject?.Invoke(persistent);
99
100 /// <summary>Get the camera used in the stage</summary>
101 public Camera camera => m_GetCamera?.Invoke();
102
103 /// <summary>Get the sun used in the stage</summary>
104 public Light sunLight => m_GetSunLight?.Invoke();
105
106 /// <summary>Custom data pointer for convenience</summary>
107 public object SRPData;
108 }
109}