Skip to content

Commit c7367bc

Browse files
HDRenderLoop: SinglePAss work but Tile is broken...
1 parent 07b27a3 commit c7367bc

File tree

4 files changed

+30
-17
lines changed

4 files changed

+30
-17
lines changed

Assets/ScriptableRenderLoop/HDRenderLoop/Debug/Resources/DebugViewTiles.shader

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,16 @@ Shader "Hidden/HDRenderLoop/DebugViewTiles"
101101
#endif
102102

103103
int n = 0;
104-
for(int category = 0; category < LIGHTCATEGORY_COUNT; category++)
104+
for (int category = 0; category < LIGHTCATEGORY_COUNT; category++)
105105
{
106106
uint mask = 1u << category;
107-
uint start;
108-
uint count;
109-
GetCountAndStart(coord, category, linearDepth, start, count);
110-
n += count;
107+
if (mask & _ViewTilesFlags)
108+
{
109+
uint start;
110+
uint count;
111+
GetCountAndStart(coord, category, linearDepth, start, count);
112+
n += count;
113+
}
111114
}
112115

113116
if (n > 0)

Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ private class Styles
2020

2121
public readonly GUIContent useForwardRenderingOnly = new GUIContent("Use Forward Rendering Only");
2222
public readonly GUIContent useDepthPrepass = new GUIContent("Use Depth Prepass");
23-
public readonly GUIContent useSinglePassLightLoop = new GUIContent("Use single Pass light loop");
2423

2524
public bool isDebugViewMaterialInit = false;
2625
public GUIContent[] debugViewMaterialStrings = null;
@@ -45,8 +44,8 @@ private class Styles
4544
public readonly GUIContent shadowsCascades = new GUIContent("Cascade values");
4645

4746
public readonly GUIContent tileLightLoopSettings = new GUIContent("Tile Light Loop settings");
48-
public readonly string[] tileLightLoopDebugTileFlagStrings = new string[] { "Direct Light", "Reflection Light", "Area Light"};
49-
public readonly GUIContent splitLightEvaluation = new GUIContent("Enable direct and indirect lighting in single pass", "Toggle");
47+
public readonly string[] tileLightLoopDebugTileFlagStrings = new string[] { "Punctual Light", "Area Light", "Env Light"};
48+
public readonly GUIContent splitLightEvaluation = new GUIContent("Split light and reflection evaluation", "Toggle");
5049
public readonly GUIContent bigTilePrepass = new GUIContent("Enable big tile prepass", "Toggle");
5150
public readonly GUIContent clustered = new GUIContent("Enable clustered", "Toggle");
5251
public readonly GUIContent disableTileAndCluster = new GUIContent("Disable Tile/clustered", "Toggle");
@@ -194,7 +193,6 @@ public override void OnInspectorGUI()
194193
debugParameters.displayTransparentObjects = EditorGUILayout.Toggle(styles.displayTransparentObjects, debugParameters.displayTransparentObjects);
195194
debugParameters.useForwardRenderingOnly = EditorGUILayout.Toggle(styles.useForwardRenderingOnly, debugParameters.useForwardRenderingOnly);
196195
debugParameters.useDepthPrepass = EditorGUILayout.Toggle(styles.useDepthPrepass, debugParameters.useDepthPrepass);
197-
debugParameters.useSinglePassLightLoop = EditorGUILayout.Toggle(styles.useSinglePassLightLoop, debugParameters.useSinglePassLightLoop);
198196

199197
if (EditorGUI.EndChangeCheck())
200198
{

Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ public class DebugParameters
5858

5959
public bool enableTonemap = true;
6060
public float exposure = 0;
61-
62-
public bool useSinglePassLightLoop = true;
6361
}
6462

6563
DebugParameters m_DebugParameters = new DebugParameters();

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

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -164,13 +164,27 @@ void LightLoop( float3 V, float3 positionWS, Coordinate coord, PreLightData prel
164164
#endif
165165

166166
#ifdef PROCESS_ENV_LIGHT
167-
uint envLightStart;
168-
uint envLightCount;
169-
GetCountAndStart(coord, LIGHTCATEGORY_ENV, linearDepth, envLightStart, envLightCount);
170167

171168
float3 iblDiffuseLighting = float3(0.0, 0.0, 0.0);
172169
float3 iblSpecularLighting = float3(0.0, 0.0, 0.0);
173170

171+
// Only apply sky IBL if the sky texture is available.
172+
if (_EnvLightSkyEnabled)
173+
{
174+
float3 localDiffuseLighting, localSpecularLighting;
175+
float2 weight;
176+
// The sky is a single cubemap texture separate from the reflection probe texture array (different resolution and compression)
177+
context.sampleReflection = SINGLE_PASS_CONTEXT_SAMPLE_SKY;
178+
EnvLightData envLightSky = InitSkyEnvLightData(0); // The sky data are generated on the fly so the compiler can optimize the code
179+
EvaluateBSDF_Env(context, V, positionWS, prelightData, envLightSky, bsdfData, localDiffuseLighting, localSpecularLighting, weight);
180+
iblDiffuseLighting = lerp(iblDiffuseLighting, localDiffuseLighting, weight.x); // Should be remove by the compiler if it is smart as all is constant 0
181+
iblSpecularLighting = lerp(iblSpecularLighting, localSpecularLighting, weight.y);
182+
}
183+
184+
uint envLightStart;
185+
uint envLightCount;
186+
GetCountAndStart(coord, LIGHTCATEGORY_ENV, linearDepth, envLightStart, envLightCount);
187+
174188
for (i = 0; i < envLightCount; ++i)
175189
{
176190
float3 localDiffuseLighting, localSpecularLighting;
@@ -185,9 +199,9 @@ void LightLoop( float3 V, float3 positionWS, Coordinate coord, PreLightData prel
185199
specularLighting += iblSpecularLighting;
186200
#endif
187201

188-
// Currently do lightmap with indirect specula
189-
// TODO: test what is the most appropriate here...
190-
#ifdef PROCESS_ENV_LIGHT
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
191205
// Add indirect diffuse + emissive (if any)
192206
diffuseLighting += bakeDiffuseLighting;
193207
#endif

0 commit comments

Comments
 (0)