Evgenii Golubev
7 年前
当前提交
a04a82ab
共有 61 个文件被更改,包括 1472 次插入 和 1088 次删除
-
2Assets/GraphicsTests/Framework/Editor/TestFramework.cs
-
4Assets/GraphicsTests/RenderPipeline/HDRenderPipeline/HDRPAsset/HDRenderPipelineResourcesTest.asset
-
2Assets/ScriptableRenderPipeline/Core/Shadow/Shadow.cs
-
71Assets/ScriptableRenderPipeline/Core/TextureCache.cs
-
11Assets/ScriptableRenderPipeline/Fptl/FptlLighting.cs
-
10Assets/ScriptableRenderPipeline/Fptl/LightingConvexHullUtils.hlsl
-
16Assets/ScriptableRenderPipeline/Fptl/LightingTemplate.hlsl
-
24Assets/ScriptableRenderPipeline/Fptl/LightingUtils.hlsl
-
4Assets/ScriptableRenderPipeline/Fptl/ShadowDispatch.hlsl
-
26Assets/ScriptableRenderPipeline/Fptl/lightlistbuild-bigtile.compute
-
26Assets/ScriptableRenderPipeline/Fptl/lightlistbuild-clustered.compute
-
17Assets/ScriptableRenderPipeline/Fptl/lightlistbuild.compute
-
11Assets/ScriptableRenderPipeline/Fptl/scrbound.compute
-
47Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs
-
11Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.cs.hlsl
-
39Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugDisplay.hlsl
-
124Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugFullScreen.shader
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugViewMaterialGBuffer.shader
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/DebugViewTiles.shader
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Debug/LightingDebugPanel.cs
-
33Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
-
35Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipeline.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/ScreenSpaceAmbientOcclusion.cs
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/ScreenSpaceAmbientOcclusion.shader
-
6Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/AmbientOcclusion/ScreenSpaceAmbientOcclusionSettings.cs
-
18Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Deferred.shader
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/Forward.hlsl
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/ShadowDispatch.hlsl
-
232Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs.hlsl
-
20Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.hlsl
-
224Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePassLoop.hlsl
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLit.shader
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/LayeredLit/LayeredLitTessellation.shader
-
303Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.hlsl
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Lit.shader
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitTessellation.shader
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/CopyStencilBuffer.shader
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.compute
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/Resources/SubsurfaceScattering.shader
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Unlit/Unlit.shader
-
14Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/CameraMotionVectors.shader
-
3Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/RenderPipelineResources.cs
-
1Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderPass/ShaderPassForward.hlsl
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/ShaderVariables.hlsl
-
12Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/Shadow.hlsl
-
78Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/ShadowAlgorithms.hlsl
-
10Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/ShadowAlgorithmsCustom.hlsl
-
2Assets/ScriptableRenderPipeline/ShaderLibrary/Shadow/ShadowMoments.hlsl
-
195Assets/TestScenes/HDTest/BasicProfiling.unity
-
287Assets/TestScenes/HDTest/CascadedShadowsTest.unity
-
2ProjectSettings/ProjectVersion.txt
-
172Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Deferred.compute
-
248Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitReference.hlsl
-
10Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/LitReference.hlsl.meta
-
10Assets/ScriptableRenderPipeline/HDRenderPipeline/Material/Lit/SSSProfile/Resources.meta
-
10Assets/ScriptableRenderPipeline/HDRenderPipeline/Resources.meta
-
157Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/shadeopaque.compute
-
0/Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/Deferred.compute.meta
287
Assets/TestScenes/HDTest/CascadedShadowsTest.unity
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
m_EditorVersion: 2017.3.0a1 |
|||
m_EditorVersion: 2017.3.0a2 |
|
|||
#pragma kernel Deferred_Direct_Fptl SHADE_OPAQUE_ENTRY=Deferred_Direct_Fptl USE_FPTL_LIGHTLIST |
|||
#pragma kernel Deferred_Direct_Fptl_DebugDisplay SHADE_OPAQUE_ENTRY=Deferred_Direct_Fptl_DebugDisplay USE_FPTL_LIGHTLIST DEBUG_DISPLAY |
|||
#pragma kernel Deferred_Direct_Clustered SHADE_OPAQUE_ENTRY=Deferred_Direct_Clustered USE_CLUSTERED_LIGHTLIST |
|||
#pragma kernel Deferred_Direct_Clustered_DebugDisplay SHADE_OPAQUE_ENTRY=Deferred_Direct_Clustered_DebugDisplay USE_CLUSTERED_LIGHTLIST DEBUG_DISPLAY |
|||
|
|||
#pragma kernel Deferred_Indirect_Fptl_Variant0 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant0 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=0 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant1 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant1 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=1 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant2 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant2 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=2 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant3 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant3 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=3 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant4 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant4 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=4 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant5 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant5 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=5 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant6 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant6 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=6 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant7 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant7 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=7 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant8 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant8 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=8 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant9 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant9 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=9 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant10 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant10 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=10 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant11 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant11 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=11 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant12 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant12 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=12 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant13 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant13 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=13 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant14 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant14 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=14 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant15 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant15 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=15 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant16 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant16 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=16 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant17 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant17 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=17 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant18 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant18 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=18 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant19 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant19 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=19 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant20 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant20 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=20 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant21 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant21 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=21 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant22 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant22 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=22 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant23 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant23 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=23 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant24 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant24 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=24 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant25 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant25 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=25 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant26 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant26 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=26 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant27 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant27 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=27 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant28 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant28 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=28 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant29 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant29 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=29 |
|||
#pragma kernel Deferred_Indirect_Fptl_Variant30 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Fptl_Variant30 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=30 |
|||
|
|||
// TODO: We should remove these variant for cluster opaque and only keep tile opaque. |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant0 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant0 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=0 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant1 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant1 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=1 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant2 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant2 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=2 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant3 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant3 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=3 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant4 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant4 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=4 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant5 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant5 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=5 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant6 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant6 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=6 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant7 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant7 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=7 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant8 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant8 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=8 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant9 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant9 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=9 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant10 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant10 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=10 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant11 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant11 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=11 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant12 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant12 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=12 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant13 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant13 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=13 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant14 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant14 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=14 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant15 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant15 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=15 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant16 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant16 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=16 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant17 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant17 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=17 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant18 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant18 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=18 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant19 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant19 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=19 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant20 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant20 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=20 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant21 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant21 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=21 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant22 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant22 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=22 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant23 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant23 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=23 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant24 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant24 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=24 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant25 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant25 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=25 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant26 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant26 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=26 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant27 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant27 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=27 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant28 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant28 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=28 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant29 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant29 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=29 |
|||
#pragma kernel Deferred_Indirect_Clustered_Variant30 SHADE_OPAQUE_ENTRY=Deferred_Indirect_Clustered_Variant30 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=30 |
|||
|
|||
|
|||
#define LIGHTLOOP_TILE_PASS 1 |
|||
|
|||
//#pragma enable_d3d11_debug_symbols |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "../../../ShaderLibrary/Common.hlsl" |
|||
#include "../../Debug/DebugDisplay.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 "../../ShaderConfig.cs.hlsl" |
|||
#include "../../ShaderVariables.hlsl" |
|||
#include "../../Lighting/Lighting.hlsl" // This include Material.hlsl |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
DECLARE_GBUFFER_TEXTURE(_GBufferTexture); |
|||
|
|||
RWTexture2D<float3> diffuseLightingUAV; |
|||
RWTexture2D<float4> specularLightingUAV; |
|||
|
|||
CBUFFER_START(UnityDeferredCompute) |
|||
uint g_TileListOffset; |
|||
CBUFFER_END |
|||
|
|||
#if USE_INDIRECT |
|||
|
|||
StructuredBuffer<uint> g_TileList; |
|||
// Indirect |
|||
[numthreads(16, 16, 1)] |
|||
void SHADE_OPAQUE_ENTRY(uint2 groupThreadId : SV_GroupThreadID, uint groupId : SV_GroupID) |
|||
{ |
|||
uint tileIndex = g_TileList[g_TileListOffset + groupId]; |
|||
uint2 tileCoord = uint2(tileIndex & 0xFFFF, tileIndex >> 16); |
|||
uint2 pixelCoord = tileCoord * GetTileSize() + groupThreadId; |
|||
|
|||
uint featureFlags = TileVariantToFeatureFlags(VARIANT); |
|||
#else |
|||
|
|||
// Direct |
|||
[numthreads(16, 16, 1)] |
|||
void SHADE_OPAQUE_ENTRY(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupId : SV_GroupID) |
|||
{ |
|||
uint2 tileCoord = groupId; |
|||
uint2 pixelCoord = dispatchThreadId; |
|||
uint featureFlags = 0xFFFFFFFF; |
|||
|
|||
#endif |
|||
|
|||
// This need to stay in sync with deferred.shader |
|||
|
|||
PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw, tileCoord); |
|||
|
|||
float depth = LOAD_TEXTURE2D(_MainDepthTexture, posInput.unPositionSS).x; |
|||
|
|||
// For indirect case: we can still overlap inside a tile with the sky/background, reject it |
|||
// Can't rely on stencil as we are in compute shader |
|||
// TODO : if we have depth bounds test we could remove such a test ? |
|||
if (depth == UNITY_RAW_FAR_CLIP_VALUE) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput); |
|||
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS); |
|||
|
|||
FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS); |
|||
BSDFData bsdfData; |
|||
float3 bakeDiffuseLighting; |
|||
DECODE_FROM_GBUFFER(gbuffer, featureFlags, bsdfData, bakeDiffuseLighting); |
|||
|
|||
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); |
|||
|
|||
float3 diffuseLighting; |
|||
float3 specularLighting; |
|||
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, featureFlags, diffuseLighting, specularLighting); |
|||
|
|||
if (_EnableSSSAndTransmission != 0 && bsdfData.materialId == MATERIALID_LIT_SSS) |
|||
{ |
|||
// We SSSSS is enabled with use split lighting. |
|||
// SSSSS algorithm need to know which pixels contribute to SSS and which doesn't. We could use the stencil for that but it mean that it will increase the cost of SSSSS |
|||
// A simpler solution is to add a slight contribution here that isn't visible (here we chose fp16 min (which is also fp11 and fp10 min). |
|||
// The SSSSS algorithm will check if diffuse lighting is black and discard the pixel if it is the case |
|||
diffuseLighting.r = max(diffuseLighting.r, HFLT_MIN); |
|||
|
|||
specularLightingUAV[pixelCoord] = float4(specularLighting, 1.0); |
|||
diffuseLightingUAV[pixelCoord] = diffuseLighting; |
|||
} |
|||
else |
|||
{ |
|||
specularLightingUAV[pixelCoord] = float4(diffuseLighting + specularLighting, 1.0); |
|||
} |
|||
} |
|||
|
|
|||
//----------------------------------------------------------------------------- |
|||
// EvaluateBSDF_Line - Reference |
|||
//----------------------------------------------------------------------------- |
|||
|
|||
void IntegrateBSDF_LineRef(float3 V, float3 positionWS, |
|||
PreLightData preLightData, LightData lightData, BSDFData bsdfData, |
|||
out float3 diffuseLighting, out float3 specularLighting, |
|||
int sampleCount = 128) |
|||
{ |
|||
diffuseLighting = float3(0.0, 0.0, 0.0); |
|||
specularLighting = float3(0.0, 0.0, 0.0); |
|||
|
|||
const float len = lightData.size.x; |
|||
const float3 T = lightData.right; |
|||
const float3 P1 = lightData.positionWS - T * (0.5 * len); |
|||
const float dt = len * rcp(sampleCount); |
|||
const float off = 0.5 * dt; |
|||
|
|||
// Uniformly sample the line segment with the Pdf = 1 / len. |
|||
const float invPdf = len; |
|||
|
|||
for (int i = 0; i < sampleCount; ++i) |
|||
{ |
|||
// Place the sample in the middle of the interval. |
|||
float t = off + i * dt; |
|||
float3 sPos = P1 + t * T; |
|||
float3 unL = sPos - positionWS; |
|||
float dist2 = dot(unL, unL); |
|||
float3 L = normalize(unL); |
|||
float sinLT = length(cross(L, T)); |
|||
float NdotL = saturate(dot(bsdfData.normalWS, L)); |
|||
|
|||
if (NdotL > 0) |
|||
{ |
|||
float3 lightDiff, lightSpec; |
|||
|
|||
BSDF(V, L, positionWS, preLightData, bsdfData, lightDiff, lightSpec); |
|||
|
|||
diffuseLighting += lightDiff * (sinLT / dist2 * NdotL); |
|||
specularLighting += lightSpec * (sinLT / dist2 * NdotL); |
|||
} |
|||
} |
|||
|
|||
// The factor of 2 is due to the fact: Integral{0, 2 PI}{max(0, cos(x))dx} = 2. |
|||
float normFactor = 2.0 * invPdf * rcp(sampleCount); |
|||
|
|||
diffuseLighting *= normFactor * lightData.diffuseScale * lightData.color; |
|||
specularLighting *= normFactor * lightData.specularScale * lightData.color; |
|||
} |
|||
|
|||
//----------------------------------------------------------------------------- |
|||
// EvaluateBSDF_Area - Reference |
|||
//----------------------------------------------------------------------------- |
|||
|
|||
void IntegrateBSDF_AreaRef(float3 V, float3 positionWS, |
|||
PreLightData preLightData, LightData lightData, BSDFData bsdfData, |
|||
out float3 diffuseLighting, out float3 specularLighting, |
|||
uint sampleCount = 512) |
|||
{ |
|||
// Add some jittering on Hammersley2d |
|||
float2 randNum = InitRandom(V.xy * 0.5 + 0.5); |
|||
|
|||
diffuseLighting = float3(0.0, 0.0, 0.0); |
|||
specularLighting = float3(0.0, 0.0, 0.0); |
|||
|
|||
for (uint i = 0; i < sampleCount; ++i) |
|||
{ |
|||
float3 P = float3(0.0, 0.0, 0.0); // Sample light point. Random point on the light shape in local space. |
|||
float3 Ns = float3(0.0, 0.0, 0.0); // Unit surface normal at P |
|||
float lightPdf = 0.0; // Pdf of the light sample |
|||
|
|||
float2 u = Hammersley2d(i, sampleCount); |
|||
u = frac(u + randNum); |
|||
|
|||
// Lights in Unity point backward. |
|||
float4x4 localToWorld = float4x4(float4(lightData.right, 0.0), float4(lightData.up, 0.0), float4(-lightData.forward, 0.0), float4(lightData.positionWS, 1.0)); |
|||
|
|||
switch (lightData.lightType) |
|||
{ |
|||
case GPULIGHTTYPE_SPHERE: |
|||
SampleSphere(u, localToWorld, lightData.size.x, lightPdf, P, Ns); |
|||
break; |
|||
case GPULIGHTTYPE_HEMISPHERE: |
|||
SampleHemisphere(u, localToWorld, lightData.size.x, lightPdf, P, Ns); |
|||
break; |
|||
case GPULIGHTTYPE_CYLINDER: |
|||
SampleCylinder(u, localToWorld, lightData.size.x, lightData.size.y, lightPdf, P, Ns); |
|||
break; |
|||
case GPULIGHTTYPE_RECTANGLE: |
|||
SampleRectangle(u, localToWorld, lightData.size.x, lightData.size.y, lightPdf, P, Ns); |
|||
break; |
|||
case GPULIGHTTYPE_DISK: |
|||
SampleDisk(u, localToWorld, lightData.size.x, lightPdf, P, Ns); |
|||
break; |
|||
// case GPULIGHTTYPE_LINE: handled by a separate function. |
|||
} |
|||
|
|||
// Get distance |
|||
float3 unL = P - positionWS; |
|||
float sqrDist = dot(unL, unL); |
|||
float3 L = normalize(unL); |
|||
|
|||
// Cosine of the angle between the light direction and the normal of the light's surface. |
|||
float cosLNs = saturate(dot(-L, Ns)); |
|||
|
|||
// We calculate area reference light with the area integral rather than the solid angle one. |
|||
float illuminance = cosLNs * saturate(dot(bsdfData.normalWS, L)) / (sqrDist * lightPdf); |
|||
|
|||
float3 localDiffuseLighting = float3(0.0, 0.0, 0.0); |
|||
float3 localSpecularLighting = float3(0.0, 0.0, 0.0); |
|||
|
|||
if (illuminance > 0.0) |
|||
{ |
|||
BSDF(V, L, positionWS, preLightData, bsdfData, localDiffuseLighting, localSpecularLighting); |
|||
localDiffuseLighting *= lightData.color * illuminance * lightData.diffuseScale; |
|||
localSpecularLighting *= lightData.color * illuminance * lightData.specularScale; |
|||
} |
|||
|
|||
diffuseLighting += localDiffuseLighting; |
|||
specularLighting += localSpecularLighting; |
|||
} |
|||
|
|||
diffuseLighting /= float(sampleCount); |
|||
specularLighting /= float(sampleCount); |
|||
} |
|||
|
|||
//----------------------------------------------------------------------------- |
|||
// EvaluateBSDF_Env - Reference |
|||
// ---------------------------------------------------------------------------- |
|||
|
|||
// Ref: Moving Frostbite to PBR (Appendix A) |
|||
float3 IntegrateLambertIBLRef(LightLoopContext lightLoopContext, |
|||
float3 V, EnvLightData lightData, BSDFData bsdfData, |
|||
uint sampleCount = 4096) |
|||
{ |
|||
float3x3 localToWorld = float3x3(bsdfData.tangentWS, bsdfData.bitangentWS, bsdfData.normalWS); |
|||
float3 acc = float3(0.0, 0.0, 0.0); |
|||
|
|||
// Add some jittering on Hammersley2d |
|||
float2 randNum = InitRandom(V.xy * 0.5 + 0.5); |
|||
|
|||
for (uint i = 0; i < sampleCount; ++i) |
|||
{ |
|||
float2 u = Hammersley2d(i, sampleCount); |
|||
u = frac(u + randNum); |
|||
|
|||
float3 L; |
|||
float NdotL; |
|||
float weightOverPdf; |
|||
ImportanceSampleLambert(u, localToWorld, L, NdotL, weightOverPdf); |
|||
|
|||
if (NdotL > 0.0) |
|||
{ |
|||
float4 val = SampleEnv(lightLoopContext, lightData.envIndex, L, 0); |
|||
|
|||
// diffuse Albedo is apply here as describe in ImportanceSampleLambert function |
|||
acc += bsdfData.diffuseColor * LambertNoPI() * weightOverPdf * val.rgb; |
|||
} |
|||
} |
|||
|
|||
return acc / sampleCount; |
|||
} |
|||
|
|||
float3 IntegrateDisneyDiffuseIBLRef(LightLoopContext lightLoopContext, |
|||
float3 V, PreLightData preLightData, EnvLightData lightData, BSDFData bsdfData, |
|||
uint sampleCount = 4096) |
|||
{ |
|||
float3x3 localToWorld = float3x3(bsdfData.tangentWS, bsdfData.bitangentWS, bsdfData.normalWS); |
|||
float NdotV = max(preLightData.NdotV, MIN_N_DOT_V); |
|||
float3 acc = float3(0.0, 0.0, 0.0); |
|||
|
|||
// Add some jittering on Hammersley2d |
|||
float2 randNum = InitRandom(V.xy * 0.5 + 0.5); |
|||
|
|||
for (uint i = 0; i < sampleCount; ++i) |
|||
{ |
|||
float2 u = Hammersley2d(i, sampleCount); |
|||
u = frac(u + randNum); |
|||
|
|||
float3 L; |
|||
float NdotL; |
|||
float weightOverPdf; |
|||
// for Disney we still use a Cosine importance sampling, true Disney importance sampling imply a look up table |
|||
ImportanceSampleLambert(u, localToWorld, L, NdotL, weightOverPdf); |
|||
|
|||
if (NdotL > 0.0) |
|||
{ |
|||
float3 H = normalize(L + V); |
|||
float LdotH = dot(L, H); |
|||
// Note: we call DisneyDiffuse that require to multiply by Albedo / PI. Divide by PI is already taken into account |
|||
// in weightOverPdf of ImportanceSampleLambert call. |
|||
float disneyDiffuse = DisneyDiffuse(NdotV, NdotL, LdotH, bsdfData.perceptualRoughness); |
|||
|
|||
// diffuse Albedo is apply here as describe in ImportanceSampleLambert function |
|||
float4 val = SampleEnv(lightLoopContext, lightData.envIndex, L, 0); |
|||
acc += bsdfData.diffuseColor * disneyDiffuse * weightOverPdf * val.rgb; |
|||
} |
|||
} |
|||
|
|||
return acc / sampleCount; |
|||
} |
|||
|
|||
// Ref: Moving Frostbite to PBR (Appendix A) |
|||
float3 IntegrateSpecularGGXIBLRef(LightLoopContext lightLoopContext, |
|||
float3 V, PreLightData preLightData, EnvLightData lightData, BSDFData bsdfData, |
|||
uint sampleCount = 4096) |
|||
{ |
|||
float3x3 localToWorld = float3x3(bsdfData.tangentWS, bsdfData.bitangentWS, bsdfData.normalWS); |
|||
float NdotV = max(preLightData.NdotV, MIN_N_DOT_V); |
|||
float3 acc = float3(0.0, 0.0, 0.0); |
|||
|
|||
// Add some jittering on Hammersley2d |
|||
float2 randNum = InitRandom(V.xy * 0.5 + 0.5); |
|||
|
|||
for (uint i = 0; i < sampleCount; ++i) |
|||
{ |
|||
float2 u = Hammersley2d(i, sampleCount); |
|||
u = frac(u + randNum); |
|||
|
|||
float VdotH; |
|||
float NdotL; |
|||
float3 L; |
|||
float weightOverPdf; |
|||
|
|||
// GGX BRDF |
|||
if (bsdfData.materialId == MATERIALID_LIT_ANISO) |
|||
{ |
|||
ImportanceSampleAnisoGGX(u, V, localToWorld, bsdfData.roughnessT, bsdfData.roughnessB, NdotV, L, VdotH, NdotL, weightOverPdf); |
|||
} |
|||
else |
|||
{ |
|||
ImportanceSampleGGX(u, V, localToWorld, bsdfData.roughness, NdotV, L, VdotH, NdotL, weightOverPdf); |
|||
} |
|||
|
|||
|
|||
if (NdotL > 0.0) |
|||
{ |
|||
// Fresnel component is apply here as describe in ImportanceSampleGGX function |
|||
float3 FweightOverPdf = F_Schlick(bsdfData.fresnel0, VdotH) * weightOverPdf; |
|||
|
|||
float4 val = SampleEnv(lightLoopContext, lightData.envIndex, L, 0); |
|||
|
|||
acc += FweightOverPdf * val.rgb; |
|||
} |
|||
} |
|||
|
|||
return acc / sampleCount; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 0406917314064054eb0ef42f727a8889 |
|||
timeCreated: 1500913760 |
|||
licenseType: Pro |
|||
ShaderImporter: |
|||
externalObjects: {} |
|||
defaultTextures: [] |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 59a5ca19094a8c64099eded20685322f |
|||
folderAsset: yes |
|||
timeCreated: 1500627638 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
fileFormatVersion: 2 |
|||
guid: 2b0e7252e10375942943003cdd139be0 |
|||
folderAsset: yes |
|||
timeCreated: 1500627615 |
|||
licenseType: Pro |
|||
DefaultImporter: |
|||
externalObjects: {} |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#pragma kernel ShadeOpaque_Direct_Fptl SHADE_OPAQUE_ENTRY=ShadeOpaque_Direct_Fptl USE_FPTL_LIGHTLIST |
|||
#pragma kernel ShadeOpaque_Direct_Fptl_DebugDisplay SHADE_OPAQUE_ENTRY=ShadeOpaque_Direct_Fptl_DebugDisplay USE_FPTL_LIGHTLIST DEBUG_DISPLAY |
|||
#pragma kernel ShadeOpaque_Direct_Clustered SHADE_OPAQUE_ENTRY=ShadeOpaque_Direct_Clustered USE_CLUSTERED_LIGHTLIST |
|||
#pragma kernel ShadeOpaque_Direct_Clustered_DebugDisplay SHADE_OPAQUE_ENTRY=ShadeOpaque_Direct_Clustered_DebugDisplay USE_CLUSTERED_LIGHTLIST DEBUG_DISPLAY |
|||
|
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant0 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant0 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=0 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant1 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant1 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=1 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant2 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant2 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=2 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant3 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant3 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=3 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant4 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant4 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=4 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant5 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant5 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=5 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant6 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant6 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=6 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant7 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant7 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=7 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant8 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant8 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=8 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant9 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant9 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=9 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant10 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant10 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=10 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant11 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant11 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=11 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant12 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant12 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=12 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant13 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant13 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=13 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant14 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant14 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=14 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant15 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant15 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=15 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant16 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant16 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=16 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant17 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant17 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=17 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant18 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant18 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=18 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant19 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant19 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=19 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant20 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant20 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=20 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant21 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant21 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=21 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant22 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant22 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=22 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant23 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant23 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=23 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant24 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant24 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=24 |
|||
#pragma kernel ShadeOpaque_Indirect_Fptl_Variant25 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Fptl_Variant25 USE_FPTL_LIGHTLIST USE_INDIRECT VARIANT=25 |
|||
|
|||
// TODO: We should remove these variant for cluster opaque and only keep tile opaque. |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant0 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant0 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=0 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant1 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant1 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=1 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant2 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant2 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=2 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant3 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant3 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=3 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant4 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant4 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=4 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant5 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant5 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=5 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant6 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant6 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=6 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant7 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant7 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=7 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant8 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant8 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=8 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant9 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant9 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=9 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant10 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant10 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=10 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant11 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant11 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=11 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant12 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant12 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=12 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant13 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant13 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=13 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant14 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant14 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=14 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant15 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant15 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=15 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant16 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant16 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=16 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant17 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant17 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=17 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant18 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant18 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=18 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant19 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant19 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=19 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant20 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant20 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=20 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant21 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant21 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=21 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant22 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant22 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=22 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant23 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant23 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=23 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant24 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant24 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=24 |
|||
#pragma kernel ShadeOpaque_Indirect_Clustered_Variant25 SHADE_OPAQUE_ENTRY=ShadeOpaque_Indirect_Clustered_Variant25 USE_CLUSTERED_LIGHTLIST USE_INDIRECT VARIANT=25 |
|||
|
|||
|
|||
#define LIGHTLOOP_TILE_PASS 1 |
|||
#define LIGHTLOOP_TILE_DIRECT 1 |
|||
#define LIGHTLOOP_TILE_INDIRECT 1 |
|||
#define LIGHTLOOP_TILE_ALL 1 |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// Include |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
#include "../../../ShaderLibrary/Common.hlsl" |
|||
#include "../../Debug/DebugDisplay.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 "../../ShaderConfig.cs.hlsl" |
|||
#include "../../ShaderVariables.hlsl" |
|||
#include "../../Lighting/Lighting.hlsl" // This include Material.hlsl |
|||
|
|||
//------------------------------------------------------------------------------------- |
|||
// variable declaration |
|||
//------------------------------------------------------------------------------------- |
|||
|
|||
DECLARE_GBUFFER_TEXTURE(_GBufferTexture); |
|||
|
|||
RWTexture2D<float3> diffuseLightingUAV; |
|||
RWTexture2D<float4> specularLightingUAV; |
|||
|
|||
CBUFFER_START(UnityShadeOpaque) |
|||
uint g_TileListOffset; |
|||
CBUFFER_END |
|||
|
|||
#if USE_INDIRECT |
|||
StructuredBuffer<uint> g_TileList; |
|||
// Indirect |
|||
[numthreads(16, 16, 1)] |
|||
void SHADE_OPAQUE_ENTRY(uint2 groupThreadId : SV_GroupThreadID, uint groupId : SV_GroupID) |
|||
{ |
|||
uint tileIndex = g_TileList[g_TileListOffset + groupId]; |
|||
uint2 tileCoord = uint2(tileIndex & 0xFFFF, tileIndex >> 16); |
|||
uint2 pixelCoord = tileCoord * GetTileSize() + groupThreadId; |
|||
|
|||
PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw, tileCoord); |
|||
uint featureFlags = TileVariantToFeatureFlags(VARIANT); |
|||
#else |
|||
// Direct |
|||
[numthreads(16, 16, 1)] |
|||
void SHADE_OPAQUE_ENTRY(uint2 dispatchThreadId : SV_DispatchThreadID, uint2 groupId : SV_GroupID) |
|||
{ |
|||
uint2 pixelCoord = dispatchThreadId; |
|||
PositionInputs posInput = GetPositionInput(pixelCoord.xy, _ScreenSize.zw, groupId); |
|||
uint featureFlags = 0xFFFFFFFF; |
|||
#endif |
|||
|
|||
float depth = LOAD_TEXTURE2D(_MainDepthTexture, posInput.unPositionSS).x; |
|||
|
|||
// For indirect case: we can still overlap inside a tile with the sky/background, reject it |
|||
// Can't rely on stencil as we are in compute shader |
|||
// TODO : if we have depth bounds test we could remove such a test ? |
|||
if (depth == UNITY_RAW_FAR_CLIP_VALUE) |
|||
{ |
|||
return; |
|||
} |
|||
|
|||
UpdatePositionInput(depth, _InvViewProjMatrix, _ViewProjMatrix, posInput); |
|||
float3 V = GetWorldSpaceNormalizeViewDir(posInput.positionWS); |
|||
|
|||
FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS); |
|||
BSDFData bsdfData; |
|||
float3 bakeDiffuseLighting; |
|||
DECODE_FROM_GBUFFER(gbuffer, featureFlags, bsdfData, bakeDiffuseLighting); |
|||
|
|||
PreLightData preLightData = GetPreLightData(V, posInput, bsdfData); |
|||
|
|||
float3 diffuseLighting; |
|||
float3 specularLighting; |
|||
LightLoop(V, posInput, preLightData, bsdfData, bakeDiffuseLighting, featureFlags, diffuseLighting, specularLighting); |
|||
|
|||
if (_EnableSSSAndTransmission != 0 && bsdfData.materialId == MATERIALID_LIT_SSS) |
|||
{ |
|||
// We SSSSS is enabled with use split lighting. |
|||
// SSSSS algorithm need to know which pixels contribute to SSS and which doesn't. We could use the stencil for that but it mean that it will increase the cost of SSSSS |
|||
// A simpler solution is to add a slight contribution here that isn't visible (here we chose fp16 min (which is also fp11 and fp10 min). |
|||
// The SSSSS algorithm will check if diffuse lighting is black and discard the pixel if it is the case |
|||
diffuseLighting.r = max(diffuseLighting.r, HFLT_MIN); |
|||
|
|||
specularLightingUAV[pixelCoord] = float4(specularLighting, 1.0); |
|||
diffuseLightingUAV[pixelCoord] = diffuseLighting; |
|||
} |
|||
else |
|||
{ |
|||
specularLightingUAV[pixelCoord] = float4(diffuseLighting + specularLighting, 1.0); |
|||
} |
|||
} |
|||
|
撰写
预览
正在加载...
取消
保存
Reference in new issue