浏览代码

Moved debug rendering of tile lists to separate shader pass

/main
runes 8 年前
当前提交
1ff2ff4b
共有 17 个文件被更改,包括 153 次插入38 次删除
  1. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Debug.meta
  2. 8
      Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs
  3. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting.meta
  4. 1
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/Resources/Deferred.shader
  5. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/SinglePass.meta
  6. 36
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs
  7. 6
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs.hlsl
  8. 18
      Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePassLoop.hlsl
  9. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Material/Builtin.meta
  10. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Material/LayeredLit.meta
  11. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Material/Unlit.meta
  12. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/PostProcess.meta
  13. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass.meta
  14. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shadow.meta
  15. 2
      Assets/ScriptableRenderLoop/HDRenderLoop/Shadow/FixedSizePCF.meta
  16. 93
      Assets/ScriptableRenderLoop/HDRenderLoop/Debug/Resources/DebugViewTiles.shader
  17. 9
      Assets/ScriptableRenderLoop/HDRenderLoop/Debug/Resources/DebugViewTiles.shader.meta

2
Assets/ScriptableRenderLoop/HDRenderLoop/Debug.meta


fileFormatVersion: 2
guid: ee4b12281385a0a4791e3128dd34eae4
guid: 10d6f30f9ddaa5f47b910603925654fb
folderAsset: yes
timeCreated: 1475748186
licenseType: Pro

8
Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs


index++;
localIndex++;
}
}
}
public override void OnInspectorGUI()
{

EditorGUILayout.Space();
EditorGUILayout.LabelField(styles.tileLightLoopSettings);
EditorGUI.indentLevel++;
EditorGUI.BeginChangeCheck();
renderLoop.tilePassLightLoop.enableDrawTileDebug = EditorGUILayout.Toggle(styles.tileLightLoopDebugMode, renderLoop.tilePassLightLoop.enableDrawTileDebug);
EditorGUI.BeginChangeCheck();
renderLoop.tilePassLightLoop.debugViewTilesFlags = (TilePass.DebugViewTilesFlags)EditorGUILayout.EnumMaskField("DebugView Tiles", renderLoop.tilePassLightLoop.debugViewTilesFlags);
renderLoop.tilePassLightLoop.enableDirectIndirectSinglePass = EditorGUILayout.Toggle(styles.directIndirectSinglePass, renderLoop.tilePassLightLoop.enableDirectIndirectSinglePass);
renderLoop.tilePassLightLoop.enableBigTilePrepass = EditorGUILayout.Toggle(styles.bigTilePrepass, renderLoop.tilePassLightLoop.enableBigTilePrepass);
renderLoop.tilePassLightLoop.enableClustered = EditorGUILayout.Toggle(styles.clustered, renderLoop.tilePassLightLoop.enableClustered);

2
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting.meta


fileFormatVersion: 2
guid: b8bec6e2ba5850349bc2827fbe25b071
guid: 7dc18395c5211d44bbe417b8b8b2e81a
folderAsset: yes
timeCreated: 1474297943
licenseType: Pro

1
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/Resources/Deferred.shader


// TODO: Workflow problem here, I would like to only generate variant for the LIGHTLOOP_TILE_PASS case, not the LIGHTLOOP_SINGLE_PASS case. This must be on lightloop side and include here.... (Can we codition
#pragma multi_compile LIGHTLOOP_TILE_DIRECT LIGHTLOOP_TILE_INDIRECT LIGHTLOOP_TILE_ALL
#pragma multi_compile USE_FPTL_LIGHTLIST USE_CLUSTERED_LIGHTLIST
#pragma multi_compile _ ENABLE_DEBUG
//-------------------------------------------------------------------------------------
// Include

2
Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/SinglePass.meta


fileFormatVersion: 2
guid: 16efe1cc514ae594993f6705dacbf97d
guid: dfb6e7f2aee22e147834de3e01b7c03c
folderAsset: yes
timeCreated: 1477266406
licenseType: Pro

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


public static int NR_LIGHT_MODELS = 2;
public static int DIRECT_LIGHT = 0;
public static int REFLECTION_LIGHT = 1;
}
}
[GenerateHLSL]
public enum DebugViewTilesFlags
{
DirectLighting = 1,
Reflection = 2
};
[GenerateHLSL]
public struct SFiniteLightBound

public Vector3 center; // a center in camera space inside the bounding volume of the light source.
public Vector2 scaleXY;
public float radius;
};
};
[GenerateHLSL]
public struct SFiniteLightData

private static int s_GenListPerBigTileKernel;
// clustered light list specific buffers and data begin
public DebugViewTilesFlags debugViewTilesFlags = 0;
public bool enableDrawTileDebug = false;
public bool enableDirectIndirectSinglePass = false;
public bool enableComputeLightEvaluation = false;
const bool k_UseDepthBuffer = true; // only has an impact when EnableClustered is true (requires a depth-prepass)

Material m_DeferredDirectMaterial;
Material m_DeferredIndirectMaterial;
Material m_DeferredAllMaterial;
Material m_DebugViewTilesMaterial;
const int k_TileSize = 16;

m_DeferredAllMaterial.DisableKeyword("LIGHTLOOP_TILE_DIRECT");
m_DeferredAllMaterial.DisableKeyword("LIGHTLOOP_TILE_INDIRECT");
m_DeferredAllMaterial.EnableKeyword("LIGHTLOOP_TILE_ALL");
m_DebugViewTilesMaterial = Utilities.CreateEngineMaterial("Hidden/HDRenderLoop/DebugViewTiles");
}
public void OnDisable()

Utilities.Destroy(m_DeferredDirectMaterial);
Utilities.Destroy(m_DeferredIndirectMaterial);
Utilities.Destroy(m_DeferredAllMaterial);
Utilities.Destroy(m_DebugViewTilesMaterial);
}
public bool NeedResize()

m_DeferredDirectMaterial.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.Zero);
m_DeferredDirectMaterial.EnableKeyword(bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
m_DeferredDirectMaterial.DisableKeyword(!bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST");
Utilities.SetKeyword(m_DeferredDirectMaterial, "ENABLE_DEBUG", enableDrawTileDebug);
m_DeferredIndirectMaterial.SetMatrix("_InvViewProjMatrix", invViewProj);
m_DeferredIndirectMaterial.SetVector("_ScreenSize", screenSize);
m_DeferredIndirectMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);

Utilities.SetKeyword(m_DeferredIndirectMaterial, "ENABLE_DEBUG", enableDrawTileDebug);
m_DeferredAllMaterial.SetMatrix("_InvViewProjMatrix", invViewProj);
m_DeferredAllMaterial.SetVector("_ScreenSize", screenSize);
m_DeferredAllMaterial.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.One);

Utilities.SetKeyword(m_DeferredAllMaterial, "ENABLE_DEBUG", enableDrawTileDebug);
m_DebugViewTilesMaterial.SetVector("_ScreenSize", screenSize);
m_DebugViewTilesMaterial.SetInt("_ViewTilesFlags", (int)debugViewTilesFlags);
var cmd = new CommandBuffer();
cmd.SetGlobalBuffer("g_vLightListGlobal", bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList); // opaques list (unless MSAA possibly)

cmd.Blit(null, cameraColorBufferRT, m_DeferredIndirectMaterial, 0);
}
//}
if(debugViewTilesFlags != 0)
{
cmd.Blit(null, cameraColorBufferRT, m_DebugViewTilesMaterial, 0);
}
renderLoop.ExecuteCommandBuffer(cmd);
cmd.Dispose();

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


#define DIRECT_LIGHT (0)
#define REFLECTION_LIGHT (1)
//
// UnityEngine.Experimental.ScriptableRenderLoop.TilePass.DebugViewTilesFlags: static fields
//
#define DEBUGVIEWTILESFLAGS_DIRECT_LIGHTING (1)
#define DEBUGVIEWTILESFLAGS_REFLECTION (2)
// Generated from UnityEngine.Experimental.ScriptableRenderLoop.TilePass.SFiniteLightBound
// PackingRules = Exact
struct SFiniteLightBound

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


// LightLoop
// ----------------------------------------------------------------------------
float3 OverlayHeatMap(uint2 pixCoord, uint numLights, float3 c)
float4 OverlayHeatMap(uint2 pixCoord, uint numLights)
{
const float4 kRadarColors[12] =
{

int2 coord = pixCoord - int2(1, 1);
float3 color = lerp(c, pow(col.xyz, 2.2), 0.3*col.w);
float4 color = float4(pow(col.xyz, 2.2), 0.3*col.w);
color = 0.0f;
color = float4(0,0,0,1);
color = 1.0f;
color = float4(1,1,1,1);
}
return color;
}

diffuseLighting += iblDiffuseLighting;
specularLighting += iblSpecularLighting;
#endif
#if ENABLE_DEBUG
#if defined(PROCESS_PUNCTUAL_LIGHT) && defined(PROCESS_ENV_LIGHT)
diffuseLighting = OverlayHeatMap(coord.unPositionSS.xy & (TILE_SIZE - 1), punctualLightCount + envLightCount, diffuseLighting);
#elif defined(PROCESS_PUNCTUAL_LIGHT)
diffuseLighting = OverlayHeatMap(coord.unPositionSS.xy & (TILE_SIZE - 1), punctualLightCount, diffuseLighting);
#elif defined(PROCESS_ENV_LIGHT)
diffuseLighting = OverlayHeatMap(coord.unPositionSS.xy & (TILE_SIZE - 1), envLightCount, diffuseLighting);
#endif
#endif
// Currently do lightmap with indirect specula

2
Assets/ScriptableRenderLoop/HDRenderLoop/Material/Builtin.meta


fileFormatVersion: 2
guid: af4ee1f6f88b039449ba02003b0f332d
guid: d67cc60b4fdba994cb837067ccdc352a
folderAsset: yes
timeCreated: 1476653183
licenseType: Pro

2
Assets/ScriptableRenderLoop/HDRenderLoop/Material/LayeredLit.meta


fileFormatVersion: 2
guid: cebd0ba54432759488065d1592e05692
guid: d43c06a2afd9f2f4ab88a7a94c43e1a6
folderAsset: yes
timeCreated: 1476653183
licenseType: Pro

2
Assets/ScriptableRenderLoop/HDRenderLoop/Material/Unlit.meta


fileFormatVersion: 2
guid: 355ba1f7a06cc7a4abe51689715bb1e7
guid: 5ebb7166783e16a42807309c93c63fad
folderAsset: yes
timeCreated: 1476653182
licenseType: Pro

2
Assets/ScriptableRenderLoop/HDRenderLoop/PostProcess.meta


fileFormatVersion: 2
guid: 8a352e0cb2a42fd4ba968b628ec4bc10
guid: 838933a8561a8704e9d537270132e500
folderAsset: yes
timeCreated: 1474641822
licenseType: Pro

2
Assets/ScriptableRenderLoop/HDRenderLoop/ShaderPass.meta


fileFormatVersion: 2
guid: 86e1905991f44ab49baa68fc4d0570e4
guid: e3b3ad4462341ec4b86566ec1fd82c7c
folderAsset: yes
timeCreated: 1476885561
licenseType: Pro

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shadow.meta


fileFormatVersion: 2
guid: 90ecdcec65552154d89b8e03c90039d4
guid: 74dbe7f252951f340bb1038a738db89e
folderAsset: yes
timeCreated: 1477395055
licenseType: Pro

2
Assets/ScriptableRenderLoop/HDRenderLoop/Shadow/FixedSizePCF.meta


fileFormatVersion: 2
guid: bf62af062defe384f9e1e45ef3cb4169
guid: b7ba3daf73a727d4a851bd2c904c04dd
folderAsset: yes
timeCreated: 1477395055
licenseType: Pro

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


Shader "Hidden/HDRenderLoop/DebugViewTiles"
{
SubShader
{
Pass
{
ZWrite Off
Blend SrcAlpha OneMinusSrcAlpha
HLSLPROGRAM
#pragma target 5.0
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev
#pragma vertex VertViewTiles
#pragma fragment FragViewTiles
#define LIGHTLOOP_TILE_PASS 1
#define USE_FPTL_LIGHTLIST 1 //TODO: make it also work with clustered
#define LIGHTLOOP_TILE_ALL 1
//-------------------------------------------------------------------------------------
// Include
//-------------------------------------------------------------------------------------
#include "Common.hlsl"
// Note: We have fix as guidelines that we have only one deferred material (with control of GBuffer enabled). Mean a users that add a new
// deferred material must replace the old one here. If in the future we want to support multiple layout (cause a lot of consistency problem),
// the deferred shader will require to use multicompile.
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderConfig.cs.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/ShaderVariables.hlsl"
#include "Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/Lighting.hlsl" // This include Material.hlsl
//-------------------------------------------------------------------------------------
// variable declaration
//-------------------------------------------------------------------------------------
uint _ViewTilesFlags;
TEXTURE2D(_CameraDepthTexture);
SAMPLER2D(sampler_CameraDepthTexture);
float4 VertViewTiles(float3 positionOS : POSITION): SV_POSITION
{
return TransformWorldToHClip(TransformObjectToWorld(positionOS));
}
float4 FragViewTiles(float4 positionCS : SV_POSITION) : SV_Target
{
Coordinate coord = GetCoordinate(positionCS.xy, _ScreenSize.zw);
#if USE_FPTL_LIGHTLIST
float linearDepth = 0.0f;
#else
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, coord.unPositionSS).x;
float linearDepth = GetLinearDepth(depth);
#endif
int n = 0;
if(_ViewTilesFlags & DEBUGVIEWTILESFLAGS_DIRECT_LIGHTING)
{
uint punctualLightStart;
uint punctualLightCount;
GetCountAndStart(coord, DIRECT_LIGHT, linearDepth, punctualLightStart, punctualLightCount);
n += punctualLightCount;
}
if(_ViewTilesFlags & DEBUGVIEWTILESFLAGS_REFLECTION)
{
uint envLightStart;
uint envLightCount;
GetCountAndStart(coord, REFLECTION_LIGHT, linearDepth, envLightStart, envLightCount);
n += envLightCount;
}
if(n > 0)
{
return OverlayHeatMap(int2(coord.unPositionSS.xy) & 15, n);
}
else
{
return 0.0f;
}
}
ENDHLSL
}
}
Fallback Off
}

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


fileFormatVersion: 2
guid: c7c2bd17b06ceb4468e14081aaf1b96f
timeCreated: 1480329456
licenseType: Pro
ShaderImporter:
defaultTextures: []
userData:
assetBundleName:
assetBundleVariant:
正在加载...
取消
保存