Skip to content

Commit 775617b

Browse files
2 parents 5ac1697 + da3a6ee commit 775617b

24 files changed

+946
-355
lines changed

.gitignore

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11

22
Library/*
33
Temp/*
4+
obj/*
45
*.csproj
56
*.sln
67
*.suo
@@ -14,7 +15,3 @@ DataSource/*
1415
*.aspx
1516
*.sdf
1617
*.userprefs
17-
18-
Assets/UnityHDRI.meta
19-
Assets/UnityHDRI/Gareoult/GareoultWhiteBalanced.exr
20-
obj/Debug/Assembly-CSharp.csproj.FileListAbsolute.txt

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,8 @@ Shader "Hidden/HDRenderLoop/DebugViewMaterialGBuffer"
1111
#pragma target 5.0
1212
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
1313

14-
#pragma vertex VertDeferred
15-
#pragma fragment FragDeferred
14+
#pragma vertex Vert
15+
#pragma fragment Frag
1616

1717
#include "Common.hlsl"
1818
#include "Color.hlsl"
@@ -41,7 +41,7 @@ Shader "Hidden/HDRenderLoop/DebugViewMaterialGBuffer"
4141
float4 positionCS : SV_POSITION;
4242
};
4343

44-
Varyings VertDeferred(Attributes input)
44+
Varyings Vert(Attributes input)
4545
{
4646
// TODO: implement SV_vertexID full screen quad
4747
Varyings output;
@@ -51,12 +51,12 @@ Shader "Hidden/HDRenderLoop/DebugViewMaterialGBuffer"
5151
return output;
5252
}
5353

54-
float4 FragDeferred(Varyings input) : SV_Target
54+
float4 Frag(Varyings input) : SV_Target
5555
{
5656
float4 unPositionSS = input.positionCS; // as input we have the vpos
5757
Coordinate coord = GetCoordinate(unPositionSS.xy, _ScreenSize.zw);
5858

59-
float depth = _CameraDepthTexture.Load(uint3(coord.unPositionSS, 0)).x;
59+
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, coord.unPositionSS).x;
6060

6161
FETCH_GBUFFER(gbuffer, _GBufferTexture, coord.unPositionSS);
6262
BSDFData bsdfData;

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

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@ Shader "Hidden/HDRenderLoop/DebugViewTiles"
1212
#pragma target 5.0
1313
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
1414

15-
#pragma vertex VertViewTiles
16-
#pragma fragment FragViewTiles
15+
#pragma vertex Vert
16+
#pragma fragment Frag
1717

1818
#define LIGHTLOOP_TILE_PASS 1
1919
#define LIGHTLOOP_TILE_ALL 1
@@ -40,10 +40,12 @@ Shader "Hidden/HDRenderLoop/DebugViewTiles"
4040

4141
uint _ViewTilesFlags;
4242

43-
TEXTURE2D(_CameraDepthTexture);
44-
SAMPLER2D(sampler_CameraDepthTexture);
43+
TEXTURE2D(_CameraDepthTexture);
44+
SAMPLER2D(sampler_CameraDepthTexture);
4545

46-
float4 VertViewTiles(float3 positionOS : POSITION): SV_POSITION
46+
float4x4 _InvViewProjMatrix;
47+
48+
float4 Vert(float3 positionOS : POSITION): SV_POSITION
4749
{
4850
return TransformWorldToHClip(TransformObjectToWorld(positionOS));
4951
}
@@ -66,11 +68,11 @@ Shader "Hidden/HDRenderLoop/DebugViewTiles"
6668
float4(1.0, 0.0, 0.0, 0.9) // strong red
6769
};
6870

69-
float maxNrLightsPerTile = 31;
71+
float maxNrLightsPerTile = 31; // TODO: setup a constant for that
7072

71-
int nColorIndex = numLights == 0 ? 0 : (1 + (int)floor(10 * (log2((float)numLights) / log2(maxNrLightsPerTile))));
72-
nColorIndex = nColorIndex<0 ? 0 : nColorIndex;
73-
float4 col = nColorIndex>11 ? float4(1.0, 1.0, 1.0, 1.0) : kRadarColors[nColorIndex];
73+
int colorIndex = numLights == 0 ? 0 : (1 + (int)floor(10 * (log2((float)numLights) / log2(maxNrLightsPerTile))));
74+
colorIndex = colorIndex < 0 ? 0 : colorIndex;
75+
float4 col = colorIndex > 11 ? float4(1.0, 1.0, 1.0, 1.0) : kRadarColors[colorIndex];
7476

7577
int2 coord = pixCoord - int2(1, 1);
7678

@@ -85,13 +87,15 @@ Shader "Hidden/HDRenderLoop/DebugViewTiles"
8587
return color;
8688
}
8789

88-
float4 FragViewTiles(float4 positionCS : SV_POSITION) : SV_Target
90+
float4 Frag(float4 positionCS : SV_POSITION) : SV_Target
8991
{
9092
Coordinate coord = GetCoordinate(positionCS.xy, _ScreenSize.zw);
9193

9294
#ifdef USE_CLUSTERED_LIGHTLIST
95+
// Perform same calculation than in deferred.shader
9396
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, coord.unPositionSS).x;
94-
float linearDepth = GetLinearDepth(depth); // View space linear depth
97+
float3 positionWS = UnprojectToWorld(depth, coord.positionSS, _InvViewProjMatrix);
98+
float linearDepth = TransformWorldToView(positionWS).z; // View space linear depth
9599
#else
96100
float linearDepth = 0.0; // unused
97101
#endif

Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs

Lines changed: 42 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,14 @@ private class Styles
4848
public readonly GUIContent tileLightLoopDebugMode = new GUIContent("Enable Debug mode", "Toggle overheat map mode");
4949
public readonly GUIContent directIndirectSinglePass = new GUIContent("Enable direct and indirect lighting in single pass", "Toggle");
5050
public readonly GUIContent bigTilePrepass = new GUIContent("Enable big tile prepass", "Toggle");
51-
public readonly GUIContent clustered = new GUIContent("Enable clusted", "Toggle");
51+
public readonly GUIContent clustered = new GUIContent("Enable clustered", "Toggle");
52+
53+
54+
public readonly GUIContent textureSettings = new GUIContent("texture Settings");
55+
56+
public readonly GUIContent spotCookieSize = new GUIContent("spotCookie Size");
57+
public readonly GUIContent pointCookieSize = new GUIContent("pointCookie Size");
58+
public readonly GUIContent reflectionCubemapSize = new GUIContent("reflectionCubemap Size");
5259
}
5360

5461
private static Styles s_Styles = null;
@@ -164,7 +171,7 @@ public override void OnInspectorGUI()
164171
FillWithProperties(typeof(Builtin.BuiltinData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, GetSubNameSpaceName(typeof(Lit.SurfaceData)), ref index);
165172
FillWithProperties(typeof(Lit.SurfaceData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, GetSubNameSpaceName(typeof(Lit.SurfaceData)), ref index);
166173
FillWithProperties(typeof(Builtin.BuiltinData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, GetSubNameSpaceName(typeof(Unlit.SurfaceData)), ref index);
167-
FillWithProperties(typeof(Unlit.SurfaceData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, GetSubNameSpaceName(typeof(Unlit.SurfaceData)), ref index);
174+
FillWithProperties(typeof(Unlit.SurfaceData), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, false, GetSubNameSpaceName(typeof(Unlit.SurfaceData)), ref index);
168175

169176
// Engine
170177
FillWithPropertiesEnum(typeof(Attributes.DebugViewGbuffer), styles.debugViewMaterialStrings, styles.debugViewMaterialValues, "", true, ref index);
@@ -183,9 +190,9 @@ public override void OnInspectorGUI()
183190
EditorGUILayout.Space();
184191
debugParameters.displayOpaqueObjects = EditorGUILayout.Toggle(styles.displayOpaqueObjects, debugParameters.displayOpaqueObjects);
185192
debugParameters.displayTransparentObjects = EditorGUILayout.Toggle(styles.displayTransparentObjects, debugParameters.displayTransparentObjects);
186-
debugParameters.useForwardRenderingOnly = EditorGUILayout.Toggle(styles.useForwardRenderingOnly, debugParameters.useForwardRenderingOnly);
193+
debugParameters.useForwardRenderingOnly = EditorGUILayout.Toggle(styles.useForwardRenderingOnly, debugParameters.useForwardRenderingOnly);
187194
debugParameters.useDepthPrepass = EditorGUILayout.Toggle(styles.useDepthPrepass, debugParameters.useDepthPrepass);
188-
debugParameters.useSinglePassLightLoop = EditorGUILayout.Toggle(styles.useSinglePassLightLoop, debugParameters.useSinglePassLightLoop);
195+
debugParameters.useSinglePassLightLoop = EditorGUILayout.Toggle(styles.useSinglePassLightLoop, debugParameters.useSinglePassLightLoop);
189196

190197
if (EditorGUI.EndChangeCheck())
191198
{
@@ -220,41 +227,64 @@ public override void OnInspectorGUI()
220227
EditorGUI.indentLevel++;
221228
EditorGUI.BeginChangeCheck();
222229

223-
224230
shadowParameters.enabled = EditorGUILayout.Toggle(styles.shadowsEnabled, shadowParameters.enabled);
225231
shadowParameters.shadowAtlasWidth = Mathf.Max(0, EditorGUILayout.IntField(styles.shadowsAtlasWidth, shadowParameters.shadowAtlasWidth));
226232
shadowParameters.shadowAtlasHeight = Mathf.Max(0, EditorGUILayout.IntField(styles.shadowsAtlasHeight, shadowParameters.shadowAtlasHeight));
227233
shadowParameters.maxShadowDistance = Mathf.Max(0, EditorGUILayout.FloatField(styles.shadowsMaxShadowDistance, shadowParameters.maxShadowDistance));
228234
shadowParameters.directionalLightCascadeCount = EditorGUILayout.IntPopup(styles.shadowsDirectionalLightCascadeCount, shadowParameters.directionalLightCascadeCount, styles.shadowsCascadeCounts, styles.shadowsCascadeCountValues);
229235

230236
EditorGUI.indentLevel++;
231-
for (int i = 0; i < shadowParameters.directionalLightCascadeCount-1; i++)
237+
for (int i = 0; i < shadowParameters.directionalLightCascadeCount - 1; i++)
232238
{
233239
shadowParameters.directionalLightCascades[i] = Mathf.Max(0, EditorGUILayout.FloatField(shadowParameters.directionalLightCascades[i]));
234240
}
235241
EditorGUI.indentLevel--;
236-
237242
if (EditorGUI.EndChangeCheck())
238243
{
239244
EditorUtility.SetDirty(renderLoop); // Repaint
240245
}
241246
EditorGUI.indentLevel--;
242247

243248
EditorGUILayout.Space();
244-
EditorGUILayout.LabelField(styles.tileLightLoopSettings);
249+
var textureParameters = renderLoop.textureSettings;
250+
251+
EditorGUILayout.LabelField(styles.textureSettings);
245252
EditorGUI.indentLevel++;
246253
EditorGUI.BeginChangeCheck();
247254

248-
renderLoop.tilePassLightLoop.debugViewTilesFlags = (TilePass.DebugViewTilesFlags)EditorGUILayout.EnumMaskField("DebugView Tiles", renderLoop.tilePassLightLoop.debugViewTilesFlags);
249-
renderLoop.tilePassLightLoop.enableDirectIndirectSinglePass = EditorGUILayout.Toggle(styles.directIndirectSinglePass, renderLoop.tilePassLightLoop.enableDirectIndirectSinglePass);
250-
renderLoop.tilePassLightLoop.enableBigTilePrepass = EditorGUILayout.Toggle(styles.bigTilePrepass, renderLoop.tilePassLightLoop.enableBigTilePrepass);
251-
renderLoop.tilePassLightLoop.enableClustered = EditorGUILayout.Toggle(styles.clustered, renderLoop.tilePassLightLoop.enableClustered);
255+
textureParameters.spotCookieSize = Mathf.NextPowerOfTwo(Mathf.Clamp(EditorGUILayout.IntField(styles.spotCookieSize, textureParameters.spotCookieSize), 16, 1024));
256+
textureParameters.pointCookieSize = Mathf.NextPowerOfTwo(Mathf.Clamp(EditorGUILayout.IntField(styles.pointCookieSize, textureParameters.pointCookieSize), 16, 1024));
257+
textureParameters.reflectionCubemapSize = Mathf.NextPowerOfTwo(Mathf.Clamp(EditorGUILayout.IntField(styles.reflectionCubemapSize, textureParameters.reflectionCubemapSize), 64, 1024));
252258

253259
if (EditorGUI.EndChangeCheck())
254260
{
255261
EditorUtility.SetDirty(renderLoop); // Repaint
256262
}
257263
EditorGUI.indentLevel--;
264+
265+
266+
EditorGUILayout.Space();
267+
268+
if (renderLoop.tilePassLightLoop != null)
269+
{
270+
EditorGUILayout.LabelField(styles.tileLightLoopSettings);
271+
EditorGUI.indentLevel++;
272+
EditorGUI.BeginChangeCheck();
273+
274+
renderLoop.tilePassLightLoop.debugViewTilesFlags = (TilePass.DebugViewTilesFlags)EditorGUILayout.EnumMaskField("DebugView Tiles", renderLoop.tilePassLightLoop.debugViewTilesFlags);
275+
renderLoop.tilePassLightLoop.enableDirectIndirectSinglePass = EditorGUILayout.Toggle(styles.directIndirectSinglePass, renderLoop.tilePassLightLoop.enableDirectIndirectSinglePass);
276+
renderLoop.tilePassLightLoop.enableBigTilePrepass = EditorGUILayout.Toggle(styles.bigTilePrepass, renderLoop.tilePassLightLoop.enableBigTilePrepass);
277+
renderLoop.tilePassLightLoop.enableClustered = EditorGUILayout.Toggle(styles.clustered, renderLoop.tilePassLightLoop.enableClustered);
278+
279+
if (EditorGUI.EndChangeCheck())
280+
{
281+
EditorUtility.SetDirty(renderLoop); // Repaint
282+
283+
// If something is chanage on tilePassLightLoop we need to force a OnValidate() OnHDRenderLoop, else change Rebuild() will not be call
284+
renderLoop.OnValidate();
285+
}
286+
EditorGUI.indentLevel--;
287+
}
258288
}
259289
}
260290
}

Assets/ScriptableRenderLoop/HDRenderLoop/HDRenderLoop.asset

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ MonoBehaviour:
1616
rotation: 0
1717
exposure: 0
1818
multiplier: 1
19+
skyResolution: 256
1920
m_ShadowSettings:
2021
enabled: 1
2122
shadowAtlasWidth: 4096

0 commit comments

Comments
 (0)