浏览代码
Moved material classification to separate pass
Moved material classification to separate pass
Light and material classification are now orthogonal and can now be enabled/disabled independently/RenderPassXR_Sandbox
Rune Stubbe
8 年前
当前提交
4e715f16
共有 14 个文件被更改,包括 240 次插入 和 90 次删除
-
6Assets/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/Shaders/LDPipe_LitShaderLightProbes/LightingData.asset
-
12Assets/ScriptableRenderPipeline/HDRenderPipeline/Editor/HDRenderPipelineInspector.cs
-
9Assets/ScriptableRenderPipeline/HDRenderPipeline/HDRenderPipelineAsset.asset
-
7Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/LightDefinition.cs.hlsl
-
22Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/FeatureFlags.hlsl
-
88Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs
-
2Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/TilePass.cs.hlsl
-
49Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/lightlistbuild.compute
-
8Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/HDRenderPipelineResources.asset
-
4Assets/ScriptableRenderPipeline/HDRenderPipeline/RenderPipelineResources/RenderPipelineResources.cs
-
33Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/builddispatchindirect.compute
-
9Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/builddispatchindirect.compute.meta
-
72Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/materialflags.compute
-
9Assets/ScriptableRenderPipeline/HDRenderPipeline/Lighting/TilePass/materialflags.compute.meta
6
Assets/GraphicsTests/RenderPipeline/LightweightPipeline/Scenes/Shaders/LDPipe_LitShaderLightProbes/LightingData.asset
文件差异内容过多而无法显示
查看文件
文件差异内容过多而无法显示
查看文件
|
|||
#pragma kernel BuildDispatchIndirect |
|||
|
|||
|
|||
#include "TilePass.cs.hlsl" |
|||
|
|||
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl |
|||
#include "../../Material/Material.hlsl" // This includes Material.hlsl |
|||
|
|||
#include "FeatureFlags.hlsl" |
|||
|
|||
RWBuffer<uint> g_DispatchIndirectBuffer : register( u0 ); // Indirect arguments have to be in a _buffer_, not a structured buffer |
|||
RWStructuredBuffer<uint> g_TileList; |
|||
StructuredBuffer<uint> g_TileFeatureFlags; |
|||
|
|||
uniform uint g_NumTiles; |
|||
uniform uint g_NumTilesX; |
|||
|
|||
[numthreads(64, 1, 1)] |
|||
void BuildDispatchIndirect(uint dispatchThreadId : SV_DispatchThreadID) |
|||
{ |
|||
if (dispatchThreadId >= g_NumTiles) |
|||
return; |
|||
|
|||
uint featureFlags = g_TileFeatureFlags[dispatchThreadId]; |
|||
|
|||
uint tileY = (dispatchThreadId + 0.5f) / (float)g_NumTilesX; // Integer division is extremely expensive, so we better avoid it |
|||
uint tileX = dispatchThreadId - tileY * g_NumTilesX; |
|||
|
|||
uint variant = FeatureFlagsToTileVariant(featureFlags); |
|||
uint offset; |
|||
InterlockedAdd(g_DispatchIndirectBuffer[variant * 3 + 0], 1, offset); |
|||
g_TileList[variant * g_NumTiles + offset] = (tileY << 16) | tileX; |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: 4eb1b418be7044c40bb5200496c50f14 |
|||
timeCreated: 1496925839 |
|||
licenseType: Pro |
|||
ComputeShaderImporter: |
|||
currentAPIMask: 4 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
|
|||
#pragma kernel MaterialFlagsGen_Write MATERIALFLAGSGEN=MaterialFlagsGen_Write |
|||
#pragma kernel MaterialFlagsGen_Or MATERIALFLAGSGEN=MaterialFlagsGen_Or USE_OR |
|||
|
|||
//#pragma #pragma enable_d3d11_debug_symbols |
|||
|
|||
#include "../../../ShaderLibrary/common.hlsl" |
|||
#include "ShaderBase.hlsl" |
|||
#include "TilePass.cs.hlsl" |
|||
|
|||
#define UNITY_MATERIAL_LIT // Need to be define before including Material.hlsl |
|||
#include "../../Material/Material.hlsl" // This includes Material.hlsl |
|||
#include "FeatureFlags.hlsl" |
|||
|
|||
#define USE_MATERIAL_FEATURE_FLAGS |
|||
#define NR_THREADS 64 |
|||
|
|||
uniform uint2 g_viDimensions; |
|||
|
|||
Texture2D g_depth_tex : register( t0 ); |
|||
|
|||
groupshared uint ldsFeatureFlags; |
|||
RWStructuredBuffer<uint> g_TileFeatureFlags; |
|||
uniform uint g_BaseFeatureFlags; |
|||
|
|||
DECLARE_GBUFFER_TEXTURE(_GBufferTexture); |
|||
|
|||
[numthreads(NR_THREADS, 1, 1)] |
|||
void MATERIALFLAGSGEN(uint threadID : SV_GroupIndex, uint3 u3GroupID : SV_GroupID) |
|||
{ |
|||
uint2 tileIDX = u3GroupID.xy; |
|||
|
|||
uint iWidth = g_viDimensions.x; |
|||
uint iHeight = g_viDimensions.y; |
|||
uint nrTilesX = (iWidth+15)/16; |
|||
|
|||
uint2 viTilLL = 16*tileIDX; |
|||
|
|||
float2 invScreenSize = float2(1.0f / iWidth, 1.0f / iHeight); |
|||
|
|||
if (threadID == 0) |
|||
{ |
|||
ldsFeatureFlags = 0; |
|||
} |
|||
GroupMemoryBarrierWithGroupSync(); |
|||
|
|||
uint materialFeatureFlags = g_BaseFeatureFlags; |
|||
[unroll] |
|||
for(int i = 0; i < 4; i++) |
|||
{ |
|||
int idx = i * NR_THREADS + threadID; |
|||
uint2 uCrd = min( uint2(viTilLL.x + (idx & 0xf), viTilLL.y + (idx >> 4)), uint2(iWidth - 1, iHeight - 1)); |
|||
|
|||
if (FetchDepth(g_depth_tex, uCrd) < VIEWPORT_SCALE_Z) |
|||
{ |
|||
PositionInputs posInput = GetPositionInput(uCrd, invScreenSize); |
|||
FETCH_GBUFFER(gbuffer, _GBufferTexture, posInput.unPositionSS); |
|||
materialFeatureFlags |= MATERIAL_FEATURE_FLAGS_FROM_GBUFFER(gbuffer); |
|||
} |
|||
} |
|||
|
|||
InterlockedOr(ldsFeatureFlags, materialFeatureFlags); //TODO: driver might optimize this or we might have to do a manual reduction |
|||
GroupMemoryBarrierWithGroupSync(); |
|||
|
|||
if(threadID == 0) |
|||
{ |
|||
#ifdef USE_OR |
|||
g_TileFeatureFlags[tileIDX.y * nrTilesX + tileIDX.x] |= ldsFeatureFlags; |
|||
#else |
|||
g_TileFeatureFlags[tileIDX.y * nrTilesX + tileIDX.x] = ldsFeatureFlags; |
|||
#endif |
|||
} |
|||
} |
|
|||
fileFormatVersion: 2 |
|||
guid: fb3eda953cd6e634e877fb777be2cd08 |
|||
timeCreated: 1496923318 |
|||
licenseType: Pro |
|||
ComputeShaderImporter: |
|||
currentAPIMask: 4 |
|||
userData: |
|||
assetBundleName: |
|||
assetBundleVariant: |
撰写
预览
正在加载...
取消
保存
Reference in new issue