sebastienlagarde
8 年前
当前提交
8cac0660
共有 5 个文件被更改,包括 118 次插入 和 118 次删除
-
177Assets/ScriptableRenderLoop/HDRenderLoop/Debug/Resources/DebugViewTiles.shader
-
6Assets/ScriptableRenderLoop/HDRenderLoop/Editor/HDRenderLoopInspector.cs
-
4Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/Lighting.hlsl
-
12Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePass.cs
-
37Assets/ScriptableRenderLoop/HDRenderLoop/Lighting/TilePass/TilePassLoop.hlsl
|
|||
Shader "Hidden/HDRenderLoop/DebugViewTiles" |
|||
{ |
|||
SubShader |
|||
SubShader |
|||
{ |
|||
ZWrite Off |
|||
Blend SrcAlpha OneMinusSrcAlpha |
|||
{ |
|||
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 |
|||
//------------------------------------------------------------------------------------- |
|||
HLSLPROGRAM |
|||
#pragma target 5.0 |
|||
#pragma only_renderers d3d11 // TEMP: unitl we go futher in dev |
|||
#include "Common.hlsl" |
|||
#pragma vertex VertViewTiles |
|||
#pragma fragment FragViewTiles |
|||
// 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 |
|||
#define LIGHTLOOP_TILE_PASS 1 |
|||
#define USE_FPTL_LIGHTLIST 1 //TODO: make it also work with clustered |
|||
#define LIGHTLOOP_TILE_ALL 1 |
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
uint _ViewTilesFlags; |
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
TEXTURE2D(_CameraDepthTexture); |
|||
SAMPLER2D(sampler_CameraDepthTexture); |
|||
#include "Common.hlsl" |
|||
float4 VertViewTiles(float3 positionOS : POSITION): SV_POSITION |
|||
{ |
|||
return TransformWorldToHClip(TransformObjectToWorld(positionOS)); |
|||
} |
|||
// 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 |
|||
float4 OverlayHeatMap(uint2 pixCoord, uint numLights) |
|||
{ |
|||
const float4 kRadarColors[12] = |
|||
{ |
|||
float4(0.0, 0.0, 0.0, 0.0), // black |
|||
float4(0.0, 0.0, 0.6, 0.5), // dark blue |
|||
float4(0.0, 0.0, 0.9, 0.5), // blue |
|||
float4(0.0, 0.6, 0.9, 0.5), // light blue |
|||
float4(0.0, 0.9, 0.9, 0.5), // cyan |
|||
float4(0.0, 0.9, 0.6, 0.5), // blueish green |
|||
float4(0.0, 0.9, 0.0, 0.5), // green |
|||
float4(0.6, 0.9, 0.0, 0.5), // yellowish green |
|||
float4(0.9, 0.9, 0.0, 0.5), // yellow |
|||
float4(0.9, 0.6, 0.0, 0.5), // orange |
|||
float4(0.9, 0.0, 0.0, 0.5), // red |
|||
float4(1.0, 0.0, 0.0, 0.9) // strong red |
|||
}; |
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
float maxNrLightsPerTile = 31; |
|||
uint _ViewTilesFlags; |
|||
int nColorIndex = numLights == 0 ? 0 : (1 + (int)floor(10 * (log2((float)numLights) / log2(maxNrLightsPerTile)))); |
|||
nColorIndex = nColorIndex<0 ? 0 : nColorIndex; |
|||
float4 col = nColorIndex>11 ? float4(1.0, 1.0, 1.0, 1.0) : kRadarColors[nColorIndex]; |
|||
TEXTURE2D(_CameraDepthTexture); |
|||
SAMPLER2D(sampler_CameraDepthTexture); |
|||
int2 coord = pixCoord - int2(1, 1); |
|||
float4 VertViewTiles(float3 positionOS : POSITION): SV_POSITION |
|||
{ |
|||
return TransformWorldToHClip(TransformObjectToWorld(positionOS)); |
|||
} |
|||
float4 color = float4(pow(col.xyz, 2.2), 0.3*col.w); |
|||
if (numLights > 0) |
|||
{ |
|||
if (SampleDebugFontNumber(coord, numLights)) // Shadow |
|||
color = float4(0, 0, 0, 1); |
|||
if (SampleDebugFontNumber(coord + 1, numLights)) // Text |
|||
color = float4(1, 1, 1, 1); |
|||
} |
|||
return color; |
|||
} |
|||
float4 FragViewTiles(float4 positionCS : SV_POSITION) : SV_Target |
|||
{ |
|||
Coordinate coord = GetCoordinate(positionCS.xy, _ScreenSize.zw); |
|||
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 USE_FPTL_LIGHTLIST |
|||
float linearDepth = 0.0; |
|||
#else |
|||
float depth = LOAD_TEXTURE2D(_CameraDepthTexture, coord.unPositionSS).x; |
|||
float linearDepth = GetLinearDepth(depth); |
|||
#endif |
|||
if(_ViewTilesFlags & DEBUGVIEWTILESFLAGS_REFLECTION) |
|||
{ |
|||
uint envLightStart; |
|||
uint envLightCount; |
|||
GetCountAndStart(coord, REFLECTION_LIGHT, linearDepth, envLightStart, envLightCount); |
|||
n += envLightCount; |
|||
} |
|||
int n = 0; |
|||
if (_ViewTilesFlags & DEBUGVIEWTILESFLAGS_DIRECT_LIGHTING) |
|||
{ |
|||
uint punctualLightStart; |
|||
uint punctualLightCount; |
|||
GetCountAndStart(coord, DIRECT_LIGHT, linearDepth, punctualLightStart, punctualLightCount); |
|||
n += punctualLightCount; |
|||
} |
|||
if(n > 0) |
|||
{ |
|||
return OverlayHeatMap(int2(coord.unPositionSS.xy) & 15, n); |
|||
} |
|||
else |
|||
{ |
|||
return 0.0f; |
|||
} |
|||
} |
|||
if (_ViewTilesFlags & DEBUGVIEWTILESFLAGS_REFLECTION) |
|||
{ |
|||
uint envLightStart; |
|||
uint envLightCount; |
|||
GetCountAndStart(coord, REFLECTION_LIGHT, linearDepth, envLightStart, envLightCount); |
|||
n += envLightCount; |
|||
} |
|||
ENDHLSL |
|||
} |
|||
if (n > 0) |
|||
{ |
|||
return OverlayHeatMap(int2(coord.unPositionSS.xy) & 15, n); |
|||
} |
|||
else |
|||
{ |
|||
return 0.0; |
|||
} |
|||
} |
|||
ENDHLSL |
|||
} |
|||
Fallback Off |
|||
} |
|||
Fallback Off |
|||
} |
撰写
预览
正在加载...
取消
保存
Reference in new issue