Skip to content

Commit dcfd9c9

Browse files
Merge pull request #35 from Unity-Technologies/Fix-Tiled-lighting
HDRenderLoop: Fix issue with tiled lighting, now working as before the refactor
2 parents 2bbabfc + c654e74 commit dcfd9c9

File tree

5 files changed

+18
-16
lines changed

5 files changed

+18
-16
lines changed

Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -685,7 +685,8 @@ public override void Render(Camera[] cameras, RenderLoop renderLoop)
685685
}
686686
RenderDeferredLighting(camera, renderLoop);
687687

688-
RenderForward(cullResults, camera, renderLoop, true);
688+
// TODO: enable this for tile forward opaque
689+
// RenderForward(cullResults, camera, renderLoop, true);
689690

690691
RenderSky(camera, renderLoop);
691692

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ public void Allocate()
149149
static int s_GenListPerTileKernel;
150150
static int s_GenListPerVoxelKernel;
151151
static int s_ClearVoxelAtomicKernel;
152-
static ComputeBuffer s_LigthVolumeDataBuffer = null;
152+
static ComputeBuffer s_LightVolumeDataBuffer = null;
153153
static ComputeBuffer s_ConvexBoundsBuffer = null;
154154
static ComputeBuffer s_AABBBoundsBuffer = null;
155155
static ComputeBuffer s_LightList = null;
@@ -235,11 +235,11 @@ public override void Rebuild(TextureSettings textureSettings)
235235
s_GenListPerTileKernel = buildPerTileLightListShader.FindKernel(enableBigTilePrepass ? "TileLightListGen_SrcBigTile" : "TileLightListGen");
236236
s_AABBBoundsBuffer = new ComputeBuffer(2 * k_MaxLightsOnSCreen, 3 * sizeof(float));
237237
s_ConvexBoundsBuffer = new ComputeBuffer(k_MaxLightsOnSCreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(SFiniteLightBound)));
238-
s_LigthVolumeDataBuffer = new ComputeBuffer(k_MaxLightsOnSCreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightVolumeData)));
238+
s_LightVolumeDataBuffer = new ComputeBuffer(k_MaxLightsOnSCreen, System.Runtime.InteropServices.Marshal.SizeOf(typeof(LightVolumeData)));
239239

240240
buildScreenAABBShader.SetBuffer(s_GenAABBKernel, "g_data", s_ConvexBoundsBuffer);
241241
buildPerTileLightListShader.SetBuffer(s_GenListPerTileKernel, "g_vBoundsBuffer", s_AABBBoundsBuffer);
242-
buildPerTileLightListShader.SetBuffer(s_GenListPerTileKernel, "_LigthVolumeData", s_LigthVolumeDataBuffer);
242+
buildPerTileLightListShader.SetBuffer(s_GenListPerTileKernel, "_LightVolumeData", s_LightVolumeDataBuffer);
243243
buildPerTileLightListShader.SetBuffer(s_GenListPerTileKernel, "g_data", s_ConvexBoundsBuffer);
244244

245245
if (enableClustered)
@@ -248,7 +248,7 @@ public override void Rebuild(TextureSettings textureSettings)
248248
s_GenListPerVoxelKernel = buildPerVoxelLightListShader.FindKernel(kernelName);
249249
s_ClearVoxelAtomicKernel = buildPerVoxelLightListShader.FindKernel("ClearAtomic");
250250
buildPerVoxelLightListShader.SetBuffer(s_GenListPerVoxelKernel, "g_vBoundsBuffer", s_AABBBoundsBuffer);
251-
buildPerVoxelLightListShader.SetBuffer(s_GenListPerVoxelKernel, "_LigthVolumeData", s_LigthVolumeDataBuffer);
251+
buildPerVoxelLightListShader.SetBuffer(s_GenListPerVoxelKernel, "_LightVolumeData", s_LightVolumeDataBuffer);
252252
buildPerVoxelLightListShader.SetBuffer(s_GenListPerVoxelKernel, "g_data", s_ConvexBoundsBuffer);
253253

254254
s_GlobalLightListAtomic = new ComputeBuffer(1, sizeof(uint));
@@ -258,7 +258,7 @@ public override void Rebuild(TextureSettings textureSettings)
258258
{
259259
s_GenListPerBigTileKernel = buildPerBigTileLightListShader.FindKernel("BigTileLightListGen");
260260
buildPerBigTileLightListShader.SetBuffer(s_GenListPerBigTileKernel, "g_vBoundsBuffer", s_AABBBoundsBuffer);
261-
buildPerBigTileLightListShader.SetBuffer(s_GenListPerBigTileKernel, "_LigthVolumeData", s_LigthVolumeDataBuffer);
261+
buildPerBigTileLightListShader.SetBuffer(s_GenListPerBigTileKernel, "_LightVolumeData", s_LightVolumeDataBuffer);
262262
buildPerBigTileLightListShader.SetBuffer(s_GenListPerBigTileKernel, "g_data", s_ConvexBoundsBuffer);
263263
}
264264

@@ -315,7 +315,7 @@ public override void Cleanup()
315315

316316
Utilities.SafeRelease(s_AABBBoundsBuffer);
317317
Utilities.SafeRelease(s_ConvexBoundsBuffer);
318-
Utilities.SafeRelease(s_LigthVolumeDataBuffer);
318+
Utilities.SafeRelease(s_LightVolumeDataBuffer);
319319

320320
// enableClustered
321321
Utilities.SafeRelease(s_GlobalLightListAtomic);
@@ -1140,7 +1140,7 @@ public override void PushGlobalParams(Camera camera, RenderLoop loop)
11401140

11411141
// These two buffers have been set in Rebuild()
11421142
s_ConvexBoundsBuffer.SetData(m_lightList.bounds.ToArray());
1143-
s_LigthVolumeDataBuffer.SetData(m_lightList.lightVolumes.ToArray());
1143+
s_LightVolumeDataBuffer.SetData(m_lightList.lightVolumes.ToArray());
11441144

11451145
Shader.SetGlobalBuffer("_DirectionalLightDatas", s_DirectionalLightDatas);
11461146
Shader.SetGlobalInt("_DirectionalLightCount", m_lightList.directionalLights.Count);
@@ -1259,7 +1259,7 @@ public override void RenderDeferredLighting(Camera camera, RenderLoop renderLoop
12591259
cmd.SetComputeTextureParam(deferredComputeShader, kernel, "_LightTextureB0", m_LightAttentuationTexture);
12601260
12611261
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_vLightListGlobal", bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList);
1262-
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "_LigthVolumeData", s_LigthVolumeDataBuffer);
1262+
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "_LightVolumeData", s_LightVolumeDataBuffer);
12631263
cmd.SetComputeBufferParam(deferredComputeShader, kernel, "g_dirLightData", s_DirLightList);
12641264
12651265
var defdecode = ReflectionProbe.GetDefaultTextureHDRDecodeValues();
@@ -1382,4 +1382,4 @@ public override void RenderForward(Camera camera, RenderLoop renderLoop, bool re
13821382
}
13831383
}
13841384
}
1385-
}
1385+
}

Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePassLoop.hlsl

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -199,9 +199,8 @@ void LightLoop( float3 V, float3 positionWS, Coordinate coord, PreLightData prel
199199
specularLighting += iblSpecularLighting;
200200
#endif
201201

202-
// TODO: HACK: to avoid the message Fragment program 'Frag': sampler 'sampler_PreIntegratedFGD' has no matching texture and will be undefined.
203-
// we sample the GI during direct lighting, so FGD texture is used...
204-
#ifdef LIGHTLOOP_TILE_DIRECT
202+
// TODO: currently apply GI at the same time as reflection
203+
#ifdef PROCESS_ENV_LIGHT
205204
// Add indirect diffuse + emissive (if any)
206205
diffuseLighting += bakeDiffuseLighting;
207206
#endif
@@ -299,4 +298,4 @@ void LightLoop( float3 V, float3 positionWS, Coordinate coord, PreLightData prel
299298
diffuseLighting += bakeDiffuseLighting;
300299
}
301300

302-
#endif
301+
#endif

Assets/ScriptableRenderLoop/HDRenderLoop/Material/LayeredLit/LayeredLit.shader

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -467,7 +467,7 @@ Shader "HDRenderLoop/LayeredLit"
467467
#define SHADERPASS SHADERPASS_FORWARD
468468
// TEMP until pragma work in include
469469
// #include "../../Lighting/Forward.hlsl"
470-
#pragma multi_compile LIGHTLOOP_SINGLE_PASS
470+
#pragma multi_compile LIGHTLOOP_SINGLE_PASS LIGHTLOOP_TILE_PASS
471471
#define LAYERED_LIT_SHADER
472472
//#pragma multi_compile SHADOWFILTERING_FIXED_SIZE_PCF
473473

Assets/ScriptableRenderLoop/HDRenderLoop/Material/Lit/Lit.hlsl

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,9 @@
4040

4141
// TODO: I haven't configure this sampler in the code, we should be able to do it (but Unity don't allow it for now...)
4242
// By default Unity provide MIG_MAG_LINEAR_POINT sampler, so it fit with our need.
43-
#ifdef LIT_DISPLAY_REFERENCE_IBL
43+
// TODO: to avoid the message Fragment program 'Frag' : sampler 'sampler_PreIntegratedFGD' has no matching texture and will be undefined.
44+
// We need to test this define LIGHTLOOP_TILE_DIRECT, this is a bad workaround but no alternative until we can setup sampler correctly...
45+
#if defined(LIT_DISPLAY_REFERENCE_IBL) || defined(LIGHTLOOP_TILE_DIRECT)
4446
// When reference mode is enabled, then we need to chose another sampler not related to cubemap code...
4547
SAMPLER2D(sampler_LtcGGXMatrix);
4648
#define SRL_BilinearSampler sampler_LtcGGXMatrix // Used for all textures

0 commit comments

Comments
 (0)