Skip to content

Commit 4842000

Browse files
HDRenderLoop: Enable linearLighting and CCT + rename rebuild to build
1 parent 7860f21 commit 4842000

File tree

5 files changed

+30
-20
lines changed

5 files changed

+30
-20
lines changed

Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs

Lines changed: 23 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,14 @@ public TextureSettings textureSettings
152152
RenderTargetIdentifier m_DistortionBufferRT;
153153

154154
// Detect when windows size is changing
155-
int m_WidthOnRecord;
156-
int m_HeightOnRecord;
155+
int m_currentWidth;
156+
int m_currentHeight;
157157

158-
// This must be allocate outside of Rebuild() else the option in the class can't be set in the inspector (as it will in this case recreate the class with default value)
158+
// Keep these settings safe to recover when leaving the render pipeline
159+
bool previousLightsUseLinearIntensity;
160+
bool previousLightsUseCCT;
161+
162+
// This must be allocate outside of Build() else the option in the class can't be set in the inspector (as it will in this case recreate the class with default value)
159163
BaseLightLoop m_lightLoop = new TilePass.LightLoop();
160164

161165
public BaseLightLoop lightLoop
@@ -164,7 +168,7 @@ public BaseLightLoop lightLoop
164168
}
165169

166170
// TODO: Find a way to automatically create/iterate through deferred material
167-
// TODO TO CHECK: SebL I move allocation from Rebuild() to here, but there was a comment "// Our object can be garbage collected, so need to be allocate here", it is still true ?
171+
// TODO TO CHECK: SebL I move allocation from Build() to here, but there was a comment "// Our object can be garbage collected, so need to be allocate here", it is still true ?
168172
Lit.RenderLoop m_LitRenderLoop = new Lit.RenderLoop();
169173

170174
public override void Build()
@@ -175,6 +179,10 @@ public override void Build()
175179
reflectionProbe = UnityEditor.SupportedRenderingFeatures.ReflectionProbe.Rotation
176180
};
177181
#endif
182+
previousLightsUseLinearIntensity = UnityEngine.Rendering.GraphicsSettings.lightsUseLinearIntensity;
183+
previousLightsUseCCT = UnityEngine.Rendering.GraphicsSettings.lightsUseCCT;
184+
UnityEngine.Rendering.GraphicsSettings.lightsUseLinearIntensity = true;
185+
UnityEngine.Rendering.GraphicsSettings.lightsUseCCT = true;
178186

179187
m_CameraColorBuffer = Shader.PropertyToID("_CameraColorTexture");
180188
m_CameraDepthBuffer = Shader.PropertyToID("_CameraDepthTexture");
@@ -183,7 +191,7 @@ public override void Build()
183191
m_CameraDepthBufferRT = new RenderTargetIdentifier(m_CameraDepthBuffer);
184192

185193
m_SkyRenderer = new SkyRenderer();
186-
m_SkyRenderer.Rebuild();
194+
m_SkyRenderer.Build();
187195

188196
m_FinalPassMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/FinalPass");
189197
m_DebugViewMaterialGBuffer = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/DebugViewMaterialGBuffer");
@@ -215,15 +223,15 @@ public override void Build()
215223
m_DistortionBuffer = Shader.PropertyToID("_DistortionTexture");
216224
m_DistortionBufferRT = new RenderTargetIdentifier(m_DistortionBuffer);
217225

218-
m_LitRenderLoop.Rebuild();
219-
m_lightLoop.Rebuild(m_TextureSettings);
226+
m_LitRenderLoop.Build();
227+
m_lightLoop.Build(m_TextureSettings);
220228
}
221229

222230
public override void Cleanup()
223231
{
224-
m_LitRenderLoop.Cleanup();
225232
m_lightLoop.Cleanup();
226-
233+
m_LitRenderLoop.Cleanup();
234+
227235
Utilities.Destroy(m_FinalPassMaterial);
228236
Utilities.Destroy(m_DebugViewMaterialGBuffer);
229237

@@ -235,6 +243,8 @@ public override void Cleanup()
235243
#if UNITY_EDITOR
236244
UnityEditor.SupportedRenderingFeatures.active = UnityEditor.SupportedRenderingFeatures.Default;
237245
#endif
246+
UnityEngine.Rendering.GraphicsSettings.lightsUseLinearIntensity = previousLightsUseLinearIntensity;
247+
UnityEngine.Rendering.GraphicsSettings.lightsUseCCT = previousLightsUseCCT;
238248
}
239249

240250
void InitAndClearBuffer(Camera camera, RenderLoop renderLoop)
@@ -562,18 +572,18 @@ void Resize(Camera camera)
562572
// For now consider we have only one camera that go to this code, the main one.
563573
m_SkyRenderer.Resize(m_SkyParameters); // TODO: Also a bad naming, here we just want to realloc texture if skyparameters change (usefull for lookdev)
564574

565-
if (camera.pixelWidth != m_WidthOnRecord || camera.pixelHeight != m_HeightOnRecord || m_lightLoop.NeedResize())
575+
if (camera.pixelWidth != m_currentWidth || camera.pixelHeight != m_currentHeight || m_lightLoop.NeedResize())
566576
{
567-
if (m_WidthOnRecord > 0 && m_HeightOnRecord > 0)
577+
if (m_currentWidth > 0 && m_currentHeight > 0)
568578
{
569579
m_lightLoop.ReleaseResolutionDependentBuffers();
570580
}
571581

572582
m_lightLoop.AllocResolutionDependentBuffers(camera.pixelWidth, camera.pixelHeight);
573583

574584
// update recorded window resolution
575-
m_WidthOnRecord = camera.pixelWidth;
576-
m_HeightOnRecord = camera.pixelHeight;
585+
m_currentWidth = camera.pixelWidth;
586+
m_currentHeight = camera.pixelHeight;
577587
}
578588
}
579589

Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/LightLoop.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace UnityEngine.Experimental.ScriptableRenderLoop
88
public class BaseLightLoop
99
{
1010
// TODO: We should rather put the texture settings in LightLoop, but how do we serialize it ?
11-
public virtual void Rebuild(TextureSettings textureSettings) {}
11+
public virtual void Build(TextureSettings textureSettings) {}
1212

1313
public virtual void Cleanup() {}
1414

@@ -22,7 +22,7 @@ public virtual void NewFrame() {}
2222

2323
public virtual void PrepareLightsForGPU(CullResults cullResults, Camera camera, ref ShadowOutput shadowOutput) { }
2424

25-
// TODO: this should not be aprt of the interface but for now make something working
25+
// TODO: this should not be part of the interface but for now make something working
2626
public virtual void BuildGPULightLists(Camera camera, RenderLoop loop, RenderTargetIdentifier cameraDepthBufferRT) { }
2727

2828
public virtual void PushGlobalParams(Camera camera, RenderLoop loop) {}

Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public void Allocate()
166166
public int debugViewTilesFlags = 0;
167167
public bool enableClustered = false;
168168
public bool disableFptlWhenClustered = true; // still useful on opaques. Should be false by default to force tile on opaque.
169-
public bool enableBigTilePrepass = true;
169+
public bool enableBigTilePrepass = false;
170170
const bool k_UseDepthBuffer = true; // only has an impact when EnableClustered is true (requires a depth-prepass)
171171
const bool k_UseAsyncCompute = true; // should not use on mobile
172172

@@ -209,7 +209,7 @@ int GetNumTileY(Camera camera)
209209
return (camera.pixelHeight + (k_TileSize - 1)) / k_TileSize;
210210
}
211211

212-
public override void Rebuild(TextureSettings textureSettings)
212+
public override void Build(TextureSettings textureSettings)
213213
{
214214
m_lightList = new LightList();
215215
m_lightList.Allocate();

Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Lit.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -242,7 +242,7 @@ Texture2D LoadLUT(TextureFormat format, float[] LtcGGXMagnitudeData,
242242
return CreateLUT(k_LtcLUTResolution, k_LtcLUTResolution, format, pixels);
243243
}
244244

245-
public void Rebuild()
245+
public void Build()
246246
{
247247
m_InitPreFGD = CreateEngineMaterial("Hidden/HDRenderLoop/PreIntegratedFGD");
248248
m_PreIntegratedFGD = new RenderTexture(128, 128, 0, RenderTextureFormat.ARGBHalf);
@@ -260,7 +260,7 @@ public void Cleanup()
260260
{
261261
Utilities.Destroy(m_InitPreFGD);
262262

263-
// TODO: how to delete RenderTexture ?
263+
// TODO: how to delete RenderTexture ? or do we need to do it ?
264264
isInit = false;
265265
}
266266

Assets/ScriptableRenderLoop/HDRenderLoop/Sky/SkyRenderer.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public void Resize(SkyParameters skyParameters)
140140
RebuildTextures(skyParameters);
141141
}
142142

143-
public void Rebuild()
143+
public void Build()
144144
{
145145
// TODO: We need to have an API to send our sky information to Enlighten. For now use a workaround through skybox/cubemap material...
146146
m_StandardSkyboxMaterial = Utilities.CreateEngineMaterial("Skybox/Cubemap");

0 commit comments

Comments
 (0)