if ( computeShader )
{
// bind buffers
cb . SetComputeBufferParam ( computeShader , computeKernel , HDShaderIDs . ShadowDatasExp , s_ShadowDataBuffer ) ;
cb . SetComputeBufferParam ( computeShader , computeKernel , HDShaderIDs . ShadowPayloads , s_ShadowPayloadBuffer ) ;
cb . SetComputeBufferParam ( computeShader , computeKernel , HDShaderIDs . _ ShadowDatasExp, s_ShadowDataBuffer ) ;
cb . SetComputeBufferParam ( computeShader , computeKernel , HDShaderIDs . _ ShadowPayloads, s_ShadowPayloadBuffer ) ;
cb . SetComputeTextureParam ( computeShader , computeKernel , HDShaderIDs . ShadowmapExp_VSM_0 , tex [ 0 ] ) ;
cb . SetComputeTextureParam ( computeShader , computeKernel , HDShaderIDs . ShadowmapExp_VSM_1 , tex [ 1 ] ) ;
cb . SetComputeTextureParam ( computeShader , computeKernel , HDShaderIDs . ShadowmapExp_VSM_2 , tex [ 2 ] ) ;
cb . SetComputeTextureParam ( computeShader , computeKernel , HDShaderIDs . ShadowmapExp_PCF , tex [ 3 ] ) ;
cb . SetComputeTextureParam ( computeShader , computeKernel , HDShaderIDs . _ ShadowmapExp_VSM_0, tex [ 0 ] ) ;
cb . SetComputeTextureParam ( computeShader , computeKernel , HDShaderIDs . _ ShadowmapExp_VSM_1, tex [ 1 ] ) ;
cb . SetComputeTextureParam ( computeShader , computeKernel , HDShaderIDs . _ ShadowmapExp_VSM_2, tex [ 2 ] ) ;
cb . SetComputeTextureParam ( computeShader , computeKernel , HDShaderIDs . _ ShadowmapExp_PCF, tex [ 3 ] ) ;
cb . SetGlobalBuffer ( HDShaderIDs . ShadowDatasExp , s_ShadowDataBuffer ) ;
cb . SetGlobalBuffer ( HDShaderIDs . ShadowPayloads , s_ShadowPayloadBuffer ) ;
cb . SetGlobalBuffer ( HDShaderIDs . _ ShadowDatasExp, s_ShadowDataBuffer ) ;
cb . SetGlobalBuffer ( HDShaderIDs . _ ShadowPayloads, s_ShadowPayloadBuffer ) ;
cb . SetGlobalTexture ( HDShaderIDs . ShadowmapExp_VSM_0 , tex [ 0 ] ) ;
cb . SetGlobalTexture ( HDShaderIDs . ShadowmapExp_VSM_1 , tex [ 1 ] ) ;
cb . SetGlobalTexture ( HDShaderIDs . ShadowmapExp_VSM_2 , tex [ 2 ] ) ;
cb . SetGlobalTexture ( HDShaderIDs . ShadowmapExp_PCF , tex [ 3 ] ) ;
cb . SetGlobalTexture ( HDShaderIDs . _ ShadowmapExp_VSM_0, tex [ 0 ] ) ;
cb . SetGlobalTexture ( HDShaderIDs . _ ShadowmapExp_VSM_1, tex [ 1 ] ) ;
cb . SetGlobalTexture ( HDShaderIDs . _ ShadowmapExp_VSM_2, tex [ 2 ] ) ;
cb . SetGlobalTexture ( HDShaderIDs . _ ShadowmapExp_PCF, tex [ 3 ] ) ;
}
// TODO: Currently samplers are hard coded in ShadowContext.hlsl, so we can't really set them here
m_DeferredAllMaterialSRT = Utilities . CreateEngineMaterial ( m_Resources . deferredShader ) ;
m_DeferredAllMaterialSRT . EnableKeyword ( "LIGHTLOOP_TILE_PASS" ) ;
m_DeferredAllMaterialSRT . DisableKeyword ( "OUTPUT_SPLIT_LIGHTING" ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . StencilRef , ( int ) StencilLightingUsage . RegularLighting ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . StencilCmp , ( int ) CompareFunction . Equal ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . SrcBlend , ( int ) BlendMode . One ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . DstBlend , ( int ) BlendMode . Zero ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . _ StencilRef, ( int ) StencilLightingUsage . RegularLighting ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . _ StencilCmp, ( int ) CompareFunction . Equal ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . _ SrcBlend, ( int ) BlendMode . One ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . _ DstBlend, ( int ) BlendMode . Zero ) ;
m_DeferredAllMaterialMRT . SetInt ( HDShaderIDs . StencilRef , ( int ) StencilLightingUsage . SplitLighting ) ;
m_DeferredAllMaterialMRT . SetInt ( HDShaderIDs . StencilCmp , ( int ) CompareFunction . Equal ) ;
m_DeferredAllMaterialMRT . SetInt ( HDShaderIDs . SrcBlend , ( int ) BlendMode . One ) ;
m_DeferredAllMaterialMRT . SetInt ( HDShaderIDs . DstBlend , ( int ) BlendMode . Zero ) ;
m_DeferredAllMaterialMRT . SetInt ( HDShaderIDs . _ StencilRef, ( int ) StencilLightingUsage . SplitLighting ) ;
m_DeferredAllMaterialMRT . SetInt ( HDShaderIDs . _ StencilCmp, ( int ) CompareFunction . Equal ) ;
m_DeferredAllMaterialMRT . SetInt ( HDShaderIDs . _ SrcBlend, ( int ) BlendMode . One ) ;
m_DeferredAllMaterialMRT . SetInt ( HDShaderIDs . _ DstBlend, ( int ) BlendMode . Zero ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . StencilRef , ( int ) StencilLightingUsage . RegularLighting ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . StencilCmp , ( int ) CompareFunction . Equal ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . SrcBlend , ( int ) BlendMode . One ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . DstBlend , ( int ) BlendMode . Zero ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . _ StencilRef, ( int ) StencilLightingUsage . RegularLighting ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . _ StencilCmp, ( int ) CompareFunction . Equal ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . _ SrcBlend, ( int ) BlendMode . One ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . _ DstBlend, ( int ) BlendMode . Zero ) ;
m_SingleDeferredMaterialMRT . SetInt ( HDShaderIDs . StencilRef , ( int ) StencilLightingUsage . SplitLighting ) ;
m_SingleDeferredMaterialMRT . SetInt ( HDShaderIDs . StencilCmp , ( int ) CompareFunction . Equal ) ;
m_SingleDeferredMaterialMRT . SetInt ( HDShaderIDs . SrcBlend , ( int ) BlendMode . One ) ;
m_SingleDeferredMaterialMRT . SetInt ( HDShaderIDs . DstBlend , ( int ) BlendMode . Zero ) ;
m_SingleDeferredMaterialMRT . SetInt ( HDShaderIDs . _ StencilRef, ( int ) StencilLightingUsage . SplitLighting ) ;
m_SingleDeferredMaterialMRT . SetInt ( HDShaderIDs . _ StencilCmp, ( int ) CompareFunction . Equal ) ;
m_SingleDeferredMaterialMRT . SetInt ( HDShaderIDs . _ SrcBlend, ( int ) BlendMode . One ) ;
m_SingleDeferredMaterialMRT . SetInt ( HDShaderIDs . _ DstBlend, ( int ) BlendMode . Zero ) ;
m_DebugViewTilesMaterial = Utilities . CreateEngineMaterial ( m_Resources . debugViewTilesShader ) ;
void VoxelLightListGeneration ( CommandBuffer cmd , Camera camera , Matrix4x4 projscr , Matrix4x4 invProjscr , RenderTargetIdentifier cameraDepthBufferRT )
{
// clear atomic offset index
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_ClearVoxelAtomicKernel , HDShaderIDs . LayeredSingleIdxBuffer , s_GlobalLightListAtomic ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_ClearVoxelAtomicKernel , HDShaderIDs . g_ LayeredSingleIdxBuffer, s_GlobalLightListAtomic ) ;
cmd . SetComputeIntParam ( buildPerVoxelLightListShader , HDShaderIDs . EnvLightIndexShift , m_lightList . lights . Count ) ;
cmd . SetComputeIntParam ( buildPerVoxelLightListShader , HDShaderIDs . iNrVisibLights , m_lightCount ) ;
cmd . SetComputeMatrixParam ( buildPerVoxelLightListShader , HDShaderIDs . mScrProjection , projscr ) ;
cmd . SetComputeMatrixParam ( buildPerVoxelLightListShader , HDShaderIDs . mInvScrProjection , invProjscr ) ;
cmd . SetComputeIntParam ( buildPerVoxelLightListShader , HDShaderIDs . _ EnvLightIndexShift, m_lightList . lights . Count ) ;
cmd . SetComputeIntParam ( buildPerVoxelLightListShader , HDShaderIDs . g_ iNrVisibLights, m_lightCount ) ;
cmd . SetComputeMatrixParam ( buildPerVoxelLightListShader , HDShaderIDs . g_ mScrProjection, projscr ) ;
cmd . SetComputeMatrixParam ( buildPerVoxelLightListShader , HDShaderIDs . g_ mInvScrProjection, invProjscr ) ;
cmd . SetComputeIntParam ( buildPerVoxelLightListShader , HDShaderIDs . iLog2NumClusters , k_Log2NumClusters ) ;
cmd . SetComputeIntParam ( buildPerVoxelLightListShader , HDShaderIDs . g_ iLog2NumClusters, k_Log2NumClusters ) ;
//Vector4 v2_near = invProjscr * new Vector4(0.0f, 0.0f, 0.0f, 1.0f);
//Vector4 v2_far = invProjscr * new Vector4(0.0f, 0.0f, 1.0f, 1.0f);
var farPlane = camera . farClipPlane ;
cmd . SetComputeFloatParam ( buildPerVoxelLightListShader , HDShaderIDs . fNearPlane , nearPlane ) ;
cmd . SetComputeFloatParam ( buildPerVoxelLightListShader , HDShaderIDs . fFarPlane , farPlane ) ;
cmd . SetComputeFloatParam ( buildPerVoxelLightListShader , HDShaderIDs . g_ fNearPlane, nearPlane ) ;
cmd . SetComputeFloatParam ( buildPerVoxelLightListShader , HDShaderIDs . g_ fFarPlane, farPlane ) ;
cmd . SetComputeFloatParam ( buildPerVoxelLightListShader , HDShaderIDs . fClustScale , m_ClustScale ) ;
cmd . SetComputeFloatParam ( buildPerVoxelLightListShader , HDShaderIDs . fClustBase , k_ClustLogBase ) ;
cmd . SetComputeFloatParam ( buildPerVoxelLightListShader , HDShaderIDs . g_ fClustScale, m_ClustScale ) ;
cmd . SetComputeFloatParam ( buildPerVoxelLightListShader , HDShaderIDs . g_ fClustBase, k_ClustLogBase ) ;
cmd . SetComputeTextureParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . depth_tex , cameraDepthBufferRT ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . vLayeredLightList , s_PerVoxelLightLists ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . LayeredOffset , s_PerVoxelOffset ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . LayeredSingleIdxBuffer , s_GlobalLightListAtomic ) ;
cmd . SetComputeTextureParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . g_ depth_tex, cameraDepthBufferRT ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . g_ vLayeredLightList, s_PerVoxelLightLists ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . g_ LayeredOffset, s_PerVoxelOffset ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . g_ LayeredSingleIdxBuffer, s_GlobalLightListAtomic ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . vBigTileLightList , s_BigTileLightList ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . g_ vBigTileLightList, s_BigTileLightList ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . logBaseBuffer , s_PerTileLogBaseTweak ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . g_ logBaseBuffer, s_PerTileLogBaseTweak ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . vBoundsBuffer , s_AABBBoundsBuffer ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . LightVolumeData , s_LightVolumeDataBuffer ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . data , s_ConvexBoundsBuffer ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . g_ vBoundsBuffer, s_AABBBoundsBuffer ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . _ LightVolumeData, s_LightVolumeDataBuffer ) ;
cmd . SetComputeBufferParam ( buildPerVoxelLightListShader , s_GenListPerVoxelKernel , HDShaderIDs . g_ data, s_ConvexBoundsBuffer ) ;
var numTilesX = GetNumTileClusteredX ( camera ) ;
var numTilesY = GetNumTileClusteredY ( camera ) ;
var projh = temp * proj ;
var invProjh = projh . inverse ;
cmd . SetComputeIntParam ( buildScreenAABBShader , HDShaderIDs . iNrVisibLights , m_lightCount ) ;
cmd . SetComputeBufferParam ( buildScreenAABBShader , s_GenAABBKernel , HDShaderIDs . data , s_ConvexBoundsBuffer ) ;
cmd . SetComputeIntParam ( buildScreenAABBShader , HDShaderIDs . g_ iNrVisibLights, m_lightCount ) ;
cmd . SetComputeBufferParam ( buildScreenAABBShader , s_GenAABBKernel , HDShaderIDs . g_ data, s_ConvexBoundsBuffer ) ;
cmd . SetComputeMatrixParam ( buildScreenAABBShader , HDShaderIDs . mProjection , projh ) ;
cmd . SetComputeMatrixParam ( buildScreenAABBShader , HDShaderIDs . mInvProjection , invProjh ) ;
cmd . SetComputeBufferParam ( buildScreenAABBShader , s_GenAABBKernel , HDShaderIDs . vBoundsBuffer , s_AABBBoundsBuffer ) ;
cmd . SetComputeMatrixParam ( buildScreenAABBShader , HDShaderIDs . g_ mProjection, projh ) ;
cmd . SetComputeMatrixParam ( buildScreenAABBShader , HDShaderIDs . g_ mInvProjection, invProjh ) ;
cmd . SetComputeBufferParam ( buildScreenAABBShader , s_GenAABBKernel , HDShaderIDs . g_ vBoundsBuffer, s_AABBBoundsBuffer ) ;
cmd . DispatchCompute ( buildScreenAABBShader , s_GenAABBKernel , ( m_lightCount + 7 ) / 8 , 1 , 1 ) ;
}
cmd . SetComputeIntParams ( buildPerBigTileLightListShader , HDShaderIDs . viDimensions , w , h ) ;
cmd . SetComputeIntParam ( buildPerBigTileLightListShader , HDShaderIDs . EnvLightIndexShift , m_lightList . lights . Count ) ;
cmd . SetComputeIntParam ( buildPerBigTileLightListShader , HDShaderIDs . iNrVisibLights , m_lightCount ) ;
cmd . SetComputeMatrixParam ( buildPerBigTileLightListShader , HDShaderIDs . mScrProjection , projscr ) ;
cmd . SetComputeMatrixParam ( buildPerBigTileLightListShader , HDShaderIDs . mInvScrProjection , invProjscr ) ;
cmd . SetComputeFloatParam ( buildPerBigTileLightListShader , HDShaderIDs . fNearPlane , camera . nearClipPlane ) ;
cmd . SetComputeFloatParam ( buildPerBigTileLightListShader , HDShaderIDs . fFarPlane , camera . farClipPlane ) ;
cmd . SetComputeBufferParam ( buildPerBigTileLightListShader , s_GenListPerBigTileKernel , HDShaderIDs . vLightList , s_BigTileLightList ) ;
cmd . SetComputeBufferParam ( buildPerBigTileLightListShader , s_GenListPerBigTileKernel , HDShaderIDs . vBoundsBuffer , s_AABBBoundsBuffer ) ;
cmd . SetComputeBufferParam ( buildPerBigTileLightListShader , s_GenListPerBigTileKernel , HDShaderIDs . LightVolumeData , s_LightVolumeDataBuffer ) ;
cmd . SetComputeBufferParam ( buildPerBigTileLightListShader , s_GenListPerBigTileKernel , HDShaderIDs . data , s_ConvexBoundsBuffer ) ;
cmd . SetComputeIntParams ( buildPerBigTileLightListShader , HDShaderIDs . g_ viDimensions, w , h ) ;
cmd . SetComputeIntParam ( buildPerBigTileLightListShader , HDShaderIDs . _ EnvLightIndexShift, m_lightList . lights . Count ) ;
cmd . SetComputeIntParam ( buildPerBigTileLightListShader , HDShaderIDs . g_ iNrVisibLights, m_lightCount ) ;
cmd . SetComputeMatrixParam ( buildPerBigTileLightListShader , HDShaderIDs . g_ mScrProjection, projscr ) ;
cmd . SetComputeMatrixParam ( buildPerBigTileLightListShader , HDShaderIDs . g_ mInvScrProjection, invProjscr ) ;
cmd . SetComputeFloatParam ( buildPerBigTileLightListShader , HDShaderIDs . g_ fNearPlane, camera . nearClipPlane ) ;
cmd . SetComputeFloatParam ( buildPerBigTileLightListShader , HDShaderIDs . g_ fFarPlane, camera . farClipPlane ) ;
cmd . SetComputeBufferParam ( buildPerBigTileLightListShader , s_GenListPerBigTileKernel , HDShaderIDs . g_ vLightList, s_BigTileLightList ) ;
cmd . SetComputeBufferParam ( buildPerBigTileLightListShader , s_GenListPerBigTileKernel , HDShaderIDs . g_ vBoundsBuffer, s_AABBBoundsBuffer ) ;
cmd . SetComputeBufferParam ( buildPerBigTileLightListShader , s_GenListPerBigTileKernel , HDShaderIDs . _ LightVolumeData, s_LightVolumeDataBuffer ) ;
cmd . SetComputeBufferParam ( buildPerBigTileLightListShader , s_GenListPerBigTileKernel , HDShaderIDs . g_ data, s_ConvexBoundsBuffer ) ;
cmd . DispatchCompute ( buildPerBigTileLightListShader , s_GenListPerBigTileKernel , numBigTilesX , numBigTilesY , 1 ) ;
}
if ( usingFptl ) // optimized for opaques only
{
cmd . SetComputeIntParams ( buildPerTileLightListShader , HDShaderIDs . viDimensions , w , h ) ;
cmd . SetComputeIntParam ( buildPerTileLightListShader , HDShaderIDs . EnvLightIndexShift , m_lightList . lights . Count ) ;
cmd . SetComputeIntParam ( buildPerTileLightListShader , HDShaderIDs . iNrVisibLights , m_lightCount ) ;
cmd . SetComputeIntParams ( buildPerTileLightListShader , HDShaderIDs . g_ viDimensions, w , h ) ;
cmd . SetComputeIntParam ( buildPerTileLightListShader , HDShaderIDs . _ EnvLightIndexShift, m_lightList . lights . Count ) ;
cmd . SetComputeIntParam ( buildPerTileLightListShader , HDShaderIDs . g_ iNrVisibLights, m_lightCount ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . vBoundsBuffer , s_AABBBoundsBuffer ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . LightVolumeData , s_LightVolumeDataBuffer ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . data , s_ConvexBoundsBuffer ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . g_ vBoundsBuffer, s_AABBBoundsBuffer ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . _ LightVolumeData, s_LightVolumeDataBuffer ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . g_ data, s_ConvexBoundsBuffer ) ;
cmd . SetComputeMatrixParam ( buildPerTileLightListShader , HDShaderIDs . mScrProjection , projscr ) ;
cmd . SetComputeMatrixParam ( buildPerTileLightListShader , HDShaderIDs . mInvScrProjection , invProjscr ) ;
cmd . SetComputeTextureParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . depth_tex , cameraDepthBufferRT ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . vLightList , s_LightList ) ;
cmd . SetComputeMatrixParam ( buildPerTileLightListShader , HDShaderIDs . g_ mScrProjection, projscr ) ;
cmd . SetComputeMatrixParam ( buildPerTileLightListShader , HDShaderIDs . g_ mInvScrProjection, invProjscr ) ;
cmd . SetComputeTextureParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . g_ depth_tex, cameraDepthBufferRT ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . g_ vLightList, s_LightList ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . vBigTileLightList , s_BigTileLightList ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . g_ vBigTileLightList, s_BigTileLightList ) ;
if ( enableFeatureVariants )
{
baseFeatureFlags | = ( uint ) LightFeatureFlags . Directional ;
}
if ( Shader . GetGlobalInt ( HDShaderIDs . EnvLightSkyEnabled ) ! = 0 )
if ( Shader . GetGlobalInt ( HDShaderIDs . _ EnvLightSkyEnabled) ! = 0 )
{
baseFeatureFlags | = ( uint ) LightFeatureFlags . Sky ;
}
}
cmd . SetComputeIntParam ( buildPerTileLightListShader , HDShaderIDs . BaseFeatureFlags , ( int ) baseFeatureFlags ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . TileFeatureFlags , s_TileFeatureFlags ) ;
cmd . SetComputeIntParam ( buildPerTileLightListShader , HDShaderIDs . g_ BaseFeatureFlags, ( int ) baseFeatureFlags ) ;
cmd . SetComputeBufferParam ( buildPerTileLightListShader , s_GenListPerTileKernel , HDShaderIDs . g_ TileFeatureFlags, s_TileFeatureFlags ) ;
}
cmd . DispatchCompute ( buildPerTileLightListShader , s_GenListPerTileKernel , numTilesX , numTilesY , 1 ) ;
baseFeatureFlags | = LightDefinitions . s_LightFeatureMaskFlags ;
}
cmd . SetComputeIntParam ( buildMaterialFlagsShader , HDShaderIDs . BaseFeatureFlags , ( int ) baseFeatureFlags ) ;
cmd . SetComputeIntParams ( buildMaterialFlagsShader , HDShaderIDs . viDimensions , w , h ) ;
cmd . SetComputeBufferParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . TileFeatureFlags , s_TileFeatureFlags ) ;
cmd . SetComputeIntParam ( buildMaterialFlagsShader , HDShaderIDs . g_ BaseFeatureFlags, ( int ) baseFeatureFlags ) ;
cmd . SetComputeIntParams ( buildMaterialFlagsShader , HDShaderIDs . g_ viDimensions, w , h ) ;
cmd . SetComputeBufferParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . g_ TileFeatureFlags, s_TileFeatureFlags ) ;
cmd . SetComputeTextureParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . StencilTexture , stencilTextureRT ) ;
cmd . SetComputeTextureParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . GBufferTexture0 , HDShaderIDs . GBufferTexture0 ) ;
cmd . SetComputeTextureParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . GBufferTexture1 , HDShaderIDs . GBufferTexture1 ) ;
cmd . SetComputeTextureParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . GBufferTexture2 , HDShaderIDs . GBufferTexture2 ) ;
cmd . SetComputeTextureParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . GBufferTexture3 , HDShaderIDs . GBufferTexture3 ) ;
cmd . SetComputeTextureParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . _ StencilTexture, stencilTextureRT ) ;
cmd . SetComputeTextureParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . _ GBufferTexture0, HDShaderIDs . _ GBufferTexture0) ;
cmd . SetComputeTextureParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . _ GBufferTexture1, HDShaderIDs . _ GBufferTexture1) ;
cmd . SetComputeTextureParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . _ GBufferTexture2, HDShaderIDs . _ GBufferTexture2) ;
cmd . SetComputeTextureParam ( buildMaterialFlagsShader , buildMaterialFlagsKernel , HDShaderIDs . _ GBufferTexture3, HDShaderIDs . _ GBufferTexture3) ;
cmd . SetComputeBufferParam ( clearDispatchIndirectShader , s_ClearDispatchIndirectKernel , HDShaderIDs . DispatchIndirectBuffer , s_DispatchIndirectBuffer ) ;
cmd . SetComputeBufferParam ( clearDispatchIndirectShader , s_ClearDispatchIndirectKernel , HDShaderIDs . g_ DispatchIndirectBuffer, s_DispatchIndirectBuffer ) ;
cmd . SetComputeBufferParam ( buildDispatchIndirectShader , s_BuildDispatchIndirectKernel , HDShaderIDs . DispatchIndirectBuffer , s_DispatchIndirectBuffer ) ;
cmd . SetComputeBufferParam ( buildDispatchIndirectShader , s_BuildDispatchIndirectKernel , HDShaderIDs . TileList , s_TileList ) ;
cmd . SetComputeBufferParam ( buildDispatchIndirectShader , s_BuildDispatchIndirectKernel , HDShaderIDs . TileFeatureFlags , s_TileFeatureFlags ) ;
cmd . SetComputeIntParam ( buildDispatchIndirectShader , HDShaderIDs . NumTiles , numTiles ) ;
cmd . SetComputeIntParam ( buildDispatchIndirectShader , HDShaderIDs . NumTilesX , numTilesX ) ;
cmd . SetComputeBufferParam ( buildDispatchIndirectShader , s_BuildDispatchIndirectKernel , HDShaderIDs . g_ DispatchIndirectBuffer, s_DispatchIndirectBuffer ) ;
cmd . SetComputeBufferParam ( buildDispatchIndirectShader , s_BuildDispatchIndirectKernel , HDShaderIDs . g_ TileList, s_TileList ) ;
cmd . SetComputeBufferParam ( buildDispatchIndirectShader , s_BuildDispatchIndirectKernel , HDShaderIDs . g_ TileFeatureFlags, s_TileFeatureFlags ) ;
cmd . SetComputeIntParam ( buildDispatchIndirectShader , HDShaderIDs . g_ NumTiles, numTiles ) ;
cmd . SetComputeIntParam ( buildDispatchIndirectShader , HDShaderIDs . g_ NumTilesX, numTilesX ) ;
cmd . DispatchCompute ( buildDispatchIndirectShader , s_BuildDispatchIndirectKernel , ( numTiles + 6 3 ) / 6 4 , 1 , 1 ) ;
}
}
{
m_ShadowMgr . BindResources ( cmd , activeComputeShader , activeComputeKernel ) ;
SetGlobalBuffer ( HDShaderIDs . vLightListGlobal , ! usingFptl ? s_PerVoxelLightLists : s_LightList ) ; // opaques list (unless MSAA possibly)
SetGlobalBuffer ( HDShaderIDs . g_ vLightListGlobal, ! usingFptl ? s_PerVoxelLightLists : s_LightList ) ; // opaques list (unless MSAA possibly)
SetGlobalTexture ( HDShaderIDs . CookieTextures , m_CookieTexArray . GetTexCache ( ) ) ;
SetGlobalTexture ( HDShaderIDs . CookieCubeTextures , m_CubeCookieTexArray . GetTexCache ( ) ) ;
SetGlobalTexture ( HDShaderIDs . EnvTextures , m_CubeReflTexArray . GetTexCache ( ) ) ;
SetGlobalTexture ( HDShaderIDs . _ CookieTextures, m_CookieTexArray . GetTexCache ( ) ) ;
SetGlobalTexture ( HDShaderIDs . _ CookieCubeTextures, m_CubeCookieTexArray . GetTexCache ( ) ) ;
SetGlobalTexture ( HDShaderIDs . _ EnvTextures, m_CubeReflTexArray . GetTexCache ( ) ) ;
SetGlobalBuffer ( HDShaderIDs . DirectionalLightDatas , s_DirectionalLightDatas ) ;
SetGlobalInt ( HDShaderIDs . DirectionalLightCount , m_lightList . directionalLights . Count ) ;
SetGlobalBuffer ( HDShaderIDs . LightDatas , s_LightDatas ) ;
SetGlobalInt ( HDShaderIDs . PunctualLightCount , m_punctualLightCount ) ;
SetGlobalInt ( HDShaderIDs . AreaLightCount , m_areaLightCount ) ;
SetGlobalBuffer ( HDShaderIDs . EnvLightDatas , s_EnvLightDatas ) ;
SetGlobalInt ( HDShaderIDs . EnvLightCount , m_lightList . envLights . Count ) ;
SetGlobalBuffer ( HDShaderIDs . ShadowDatas , s_shadowDatas ) ;
SetGlobalVectorArray ( HDShaderIDs . DirShadowSplitSpheres , m_lightList . directionalShadowSplitSphereSqr ) ;
SetGlobalBuffer ( HDShaderIDs . _ DirectionalLightDatas, s_DirectionalLightDatas ) ;
SetGlobalInt ( HDShaderIDs . _ DirectionalLightCount, m_lightList . directionalLights . Count ) ;
SetGlobalBuffer ( HDShaderIDs . _ LightDatas, s_LightDatas ) ;
SetGlobalInt ( HDShaderIDs . _ PunctualLightCount, m_punctualLightCount ) ;
SetGlobalInt ( HDShaderIDs . _ AreaLightCount, m_areaLightCount ) ;
SetGlobalBuffer ( HDShaderIDs . _ EnvLightDatas, s_EnvLightDatas ) ;
SetGlobalInt ( HDShaderIDs . _ EnvLightCount, m_lightList . envLights . Count ) ;
SetGlobalBuffer ( HDShaderIDs . _ ShadowDatas, s_shadowDatas ) ;
SetGlobalVectorArray ( HDShaderIDs . _ DirShadowSplitSpheres, m_lightList . directionalShadowSplitSphereSqr ) ;
SetGlobalInt ( HDShaderIDs . NumTileFtplX , GetNumTileFtplX ( camera ) ) ;
SetGlobalInt ( HDShaderIDs . NumTileFtplY , GetNumTileFtplY ( camera ) ) ;
SetGlobalInt ( HDShaderIDs . _ NumTileFtplX, GetNumTileFtplX ( camera ) ) ;
SetGlobalInt ( HDShaderIDs . _ NumTileFtplY, GetNumTileFtplY ( camera ) ) ;
SetGlobalInt ( HDShaderIDs . NumTileClusteredX , GetNumTileClusteredX ( camera ) ) ;
SetGlobalInt ( HDShaderIDs . NumTileClusteredY , GetNumTileClusteredY ( camera ) ) ;
SetGlobalInt ( HDShaderIDs . _ NumTileClusteredX, GetNumTileClusteredX ( camera ) ) ;
SetGlobalInt ( HDShaderIDs . _ NumTileClusteredY, GetNumTileClusteredY ( camera ) ) ;
SetGlobalBuffer ( HDShaderIDs . vBigTileLightList , s_BigTileLightList ) ;
SetGlobalBuffer ( HDShaderIDs . g_ vBigTileLightList, s_BigTileLightList ) ;
SetGlobalFloat ( HDShaderIDs . fClustScale , m_ClustScale ) ;
SetGlobalFloat ( HDShaderIDs . fClustBase , k_ClustLogBase ) ;
SetGlobalFloat ( HDShaderIDs . fNearPlane , camera . nearClipPlane ) ;
SetGlobalFloat ( HDShaderIDs . fFarPlane , camera . farClipPlane ) ;
SetGlobalInt ( HDShaderIDs . iLog2NumClusters , k_Log2NumClusters ) ;
SetGlobalFloat ( HDShaderIDs . g_ fClustScale, m_ClustScale ) ;
SetGlobalFloat ( HDShaderIDs . g_ fClustBase, k_ClustLogBase ) ;
SetGlobalFloat ( HDShaderIDs . g_ fNearPlane, camera . nearClipPlane ) ;
SetGlobalFloat ( HDShaderIDs . g_ fFarPlane, camera . farClipPlane ) ;
SetGlobalInt ( HDShaderIDs . g_ iLog2NumClusters, k_Log2NumClusters ) ;
SetGlobalInt ( HDShaderIDs . isLogBaseBufferEnabled , k_UseDepthBuffer ? 1 : 0 ) ;
SetGlobalInt ( HDShaderIDs . g_ isLogBaseBufferEnabled, k_UseDepthBuffer ? 1 : 0 ) ;
SetGlobalBuffer ( HDShaderIDs . vLayeredOffsetsBuffer , s_PerVoxelOffset ) ;
SetGlobalBuffer ( HDShaderIDs . g_ vLayeredOffsetsBuffer, s_PerVoxelOffset ) ;
SetGlobalBuffer ( HDShaderIDs . logBaseBuffer , s_PerTileLogBaseTweak ) ;
SetGlobalBuffer ( HDShaderIDs . g_ logBaseBuffer, s_PerTileLogBaseTweak ) ;
}
}
}
if ( GetFeatureVariantsEnabled ( ) )
{
// featureVariants
m_DebugViewTilesMaterial . SetInt ( HDShaderIDs . NumTiles , numTiles ) ;
m_DebugViewTilesMaterial . SetInt ( HDShaderIDs . ViewTilesFlags , ( int ) lightingDebug . tileDebugByCategory ) ;
m_DebugViewTilesMaterial . SetVector ( HDShaderIDs . MousePixelCoord , mousePixelCoord ) ;
m_DebugViewTilesMaterial . SetBuffer ( HDShaderIDs . TileList , s_TileList ) ;
m_DebugViewTilesMaterial . SetBuffer ( HDShaderIDs . DispatchIndirectBuffer , s_DispatchIndirectBuffer ) ;
m_DebugViewTilesMaterial . SetInt ( HDShaderIDs . _ NumTiles, numTiles ) ;
m_DebugViewTilesMaterial . SetInt ( HDShaderIDs . _ ViewTilesFlags, ( int ) lightingDebug . tileDebugByCategory ) ;
m_DebugViewTilesMaterial . SetVector ( HDShaderIDs . _ MousePixelCoord, mousePixelCoord ) ;
m_DebugViewTilesMaterial . SetBuffer ( HDShaderIDs . g_ TileList, s_TileList ) ;
m_DebugViewTilesMaterial . SetBuffer ( HDShaderIDs . g_ DispatchIndirectBuffer, s_DispatchIndirectBuffer ) ;
m_DebugViewTilesMaterial . EnableKeyword ( bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST" ) ;
m_DebugViewTilesMaterial . DisableKeyword ( ! bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST" ) ;
m_DebugViewTilesMaterial . DisableKeyword ( "SHOW_LIGHT_CATEGORIES" ) ;
else if ( lightingDebug . tileDebugByCategory ! = TileSettings . TileDebug . None )
{
// lightCategories
m_DebugViewTilesMaterial . SetInt ( HDShaderIDs . ViewTilesFlags , ( int ) lightingDebug . tileDebugByCategory ) ;
m_DebugViewTilesMaterial . SetVector ( HDShaderIDs . MousePixelCoord , mousePixelCoord ) ;
m_DebugViewTilesMaterial . SetInt ( HDShaderIDs . _ ViewTilesFlags, ( int ) lightingDebug . tileDebugByCategory ) ;
m_DebugViewTilesMaterial . SetVector ( HDShaderIDs . _ MousePixelCoord, mousePixelCoord ) ;
m_DebugViewTilesMaterial . EnableKeyword ( bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST" ) ;
m_DebugViewTilesMaterial . DisableKeyword ( ! bUseClusteredForDeferred ? "USE_CLUSTERED_LIGHTLIST" : "USE_FPTL_LIGHTLIST" ) ;
m_DebugViewTilesMaterial . EnableKeyword ( "SHOW_LIGHT_CATEGORIES" ) ;
// If SSS is disable, do lighting for both split lighting and no split lighting
if ( ! debugDisplaySettings . renderingDebugSettings . enableSSSAndTransmission )
{
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . StencilRef , ( int ) StencilLightingUsage . NoLighting ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . StencilCmp , ( int ) CompareFunction . NotEqual ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . _ StencilRef, ( int ) StencilLightingUsage . NoLighting ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . _ StencilCmp, ( int ) CompareFunction . NotEqual ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . StencilRef , ( int ) StencilLightingUsage . RegularLighting ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . StencilCmp , ( int ) CompareFunction . Equal ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . _ StencilRef, ( int ) StencilLightingUsage . RegularLighting ) ;
m_SingleDeferredMaterialSRT . SetInt ( HDShaderIDs . _ StencilCmp, ( int ) CompareFunction . Equal ) ;
}
Utilities . DrawFullScreen ( cmd , m_SingleDeferredMaterialSRT , colorBuffers [ 0 ] , depthStencilBuffer ) ;
if ( enableFeatureVariants )
numVariants = LightDefinitions . s_NumFeatureVariants ;
int debugViewMaterial = Shader . GetGlobalInt ( HDShaderIDs . DebugViewMaterial ) ;
int debugLightingMode = Shader . GetGlobalInt ( HDShaderIDs . DebugLightingMode ) ;
Vector4 debugLightingAlbedo = Shader . GetGlobalVector ( HDShaderIDs . DebugLightingAlbedo ) ;
Vector4 debugLightingSmoothness = Shader . GetGlobalVector ( HDShaderIDs . DebugLightingSmoothness ) ;
int debugViewMaterial = Shader . GetGlobalInt ( HDShaderIDs . _ DebugViewMaterial) ;
int debugLightingMode = Shader . GetGlobalInt ( HDShaderIDs . _ DebugLightingMode) ;
Vector4 debugLightingAlbedo = Shader . GetGlobalVector ( HDShaderIDs . _ DebugLightingAlbedo) ;
Vector4 debugLightingSmoothness = Shader . GetGlobalVector ( HDShaderIDs . _ DebugLightingSmoothness) ;
Texture ltcData = Shader . GetGlobalTexture ( HDShaderIDs . LtcData ) ;
Texture preIntegratedFGD = Shader . GetGlobalTexture ( HDShaderIDs . PreIntegratedFGD ) ;
Texture ltcGGXMatrix = Shader . GetGlobalTexture ( HDShaderIDs . LtcGGXMatrix ) ;
Texture ltcDisneyDiffuseMatrix = Shader . GetGlobalTexture ( HDShaderIDs . LtcDisneyDiffuseMatrix ) ;
Texture ltcMultiGGXFresnelDisneyDiffuse = Shader . GetGlobalTexture ( HDShaderIDs . LtcMultiGGXFresnelDisneyDiffuse ) ;
Texture ltcData = Shader . GetGlobalTexture ( HDShaderIDs . _ LtcData) ;
Texture preIntegratedFGD = Shader . GetGlobalTexture ( HDShaderIDs . _ PreIntegratedFGD) ;
Texture ltcGGXMatrix = Shader . GetGlobalTexture ( HDShaderIDs . _ LtcGGXMatrix) ;
Texture ltcDisneyDiffuseMatrix = Shader . GetGlobalTexture ( HDShaderIDs . _ LtcDisneyDiffuseMatrix) ;
Texture ltcMultiGGXFresnelDisneyDiffuse = Shader . GetGlobalTexture ( HDShaderIDs . _ LtcMultiGGXFresnelDisneyDiffuse) ;
Matrix4x4 invScrProjection = Shader . GetGlobalMatrix ( HDShaderIDs . mInvScrProjection ) ;
int useTileLightList = Shader . GetGlobalInt ( HDShaderIDs . UseTileLightList ) ;
Matrix4x4 invScrProjection = Shader . GetGlobalMatrix ( HDShaderIDs . g_ mInvScrProjection) ;
int useTileLightList = Shader . GetGlobalInt ( HDShaderIDs . _ UseTileLightList) ;
Vector4 time = Shader . GetGlobalVector ( HDShaderIDs . Time ) ;
Vector4 sinTime = Shader . GetGlobalVector ( HDShaderIDs . SinTime ) ;
Vector4 cosTime = Shader . GetGlobalVector ( HDShaderIDs . CosTime ) ;
Vector4 time = Shader . GetGlobalVector ( HDShaderIDs . _ Time) ;
Vector4 sinTime = Shader . GetGlobalVector ( HDShaderIDs . _ SinTime) ;
Vector4 cosTime = Shader . GetGlobalVector ( HDShaderIDs . _ CosTime) ;
Vector4 worldSpaceCameraPos = Shader . GetGlobalVector ( HDShaderIDs . WorldSpaceCameraPos ) ;
Vector4 projectionParams = Shader . GetGlobalVector ( HDShaderIDs . ProjectionParams ) ;
Vector4 screenParams = Shader . GetGlobalVector ( HDShaderIDs . ScreenParams ) ;
Vector4 zbufferParams = Shader . GetGlobalVector ( HDShaderIDs . ZBufferParams ) ;
Vector4 worldSpaceCameraPos = Shader . GetGlobalVector ( HDShaderIDs . _ WorldSpaceCameraPos) ;
Vector4 projectionParams = Shader . GetGlobalVector ( HDShaderIDs . _ ProjectionParams) ;
Vector4 screenParams = Shader . GetGlobalVector ( HDShaderIDs . _ ScreenParams) ;
Vector4 zbufferParams = Shader . GetGlobalVector ( HDShaderIDs . _ ZBufferParams) ;
int envLightSkyEnabled = Shader . GetGlobalInt ( HDShaderIDs . EnvLightSkyEnabled ) ;
float ambientOcclusionDirectLightStrenght = Shader . GetGlobalFloat ( HDShaderIDs . AmbientOcclusionDirectLightStrenght ) ;
int envLightSkyEnabled = Shader . GetGlobalInt ( HDShaderIDs . _ EnvLightSkyEnabled) ;
float ambientOcclusionDirectLightStrenght = Shader . GetGlobalFloat ( HDShaderIDs . _ AmbientOcclusionDirectLightStrenght) ;
int enableSSSAndTransmission = Shader . GetGlobalInt ( HDShaderIDs . EnableSSSAndTransmission ) ;
int texturingModeFlags = Shader . GetGlobalInt ( HDShaderIDs . TexturingModeFlags ) ;
int transmissionFlags = Shader . GetGlobalInt ( HDShaderIDs . TransmissionFlags ) ;
Vector4 [ ] thicknessRemaps = Shader . GetGlobalVectorArray ( HDShaderIDs . ThicknessRemaps ) ;
Vector4 [ ] shapeParams = Shader . GetGlobalVectorArray ( HDShaderIDs . ShapeParams ) ;
Vector4 [ ] transmissionTints = Shader . GetGlobalVectorArray ( HDShaderIDs . TransmissionTints ) ;
int enableSSSAndTransmission = Shader . GetGlobalInt ( HDShaderIDs . _ EnableSSSAndTransmission) ;
int texturingModeFlags = Shader . GetGlobalInt ( HDShaderIDs . _ TexturingModeFlags) ;
int transmissionFlags = Shader . GetGlobalInt ( HDShaderIDs . _ TransmissionFlags) ;
Vector4 [ ] thicknessRemaps = Shader . GetGlobalVectorArray ( HDShaderIDs . _ ThicknessRemaps) ;
Vector4 [ ] shapeParams = Shader . GetGlobalVectorArray ( HDShaderIDs . _ ShapeParams) ;
Vector4 [ ] transmissionTints = Shader . GetGlobalVectorArray ( HDShaderIDs . _ TransmissionTints) ;
Texture skyTexture = Shader . GetGlobalTexture ( HDShaderIDs . SkyTexture ) ;
Texture skyTexture = Shader . GetGlobalTexture ( HDShaderIDs . _ SkyTexture) ;
for ( int variant = 0 ; variant < numVariants ; variant + + )
{
hdCamera . SetupComputeShader ( deferredComputeShader , cmd ) ;
// TODO: Update value like in ApplyDebugDisplaySettings() call. Sadly it is high likely that this will not be keep in sync. we really need to get rid of this by making global parameters visible to compute shaders
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . DebugViewMaterial , debugViewMaterial ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . DebugLightingMode , debugLightingMode ) ;
cmd . SetComputeVectorParam ( deferredComputeShader , HDShaderIDs . DebugLightingAlbedo , debugLightingAlbedo ) ;
cmd . SetComputeVectorParam ( deferredComputeShader , HDShaderIDs . DebugLightingSmoothness , debugLightingSmoothness ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . _ DebugViewMaterial, debugViewMaterial ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . _ DebugLightingMode, debugLightingMode ) ;
cmd . SetComputeVectorParam ( deferredComputeShader , HDShaderIDs . _ DebugLightingAlbedo, debugLightingAlbedo ) ;
cmd . SetComputeVectorParam ( deferredComputeShader , HDShaderIDs . _ DebugLightingSmoothness, debugLightingSmoothness ) ;
cmd . SetComputeBufferParam ( deferredComputeShader , kernel , HDShaderIDs . vLightListGlobal , bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList ) ;
cmd . SetComputeBufferParam ( deferredComputeShader , kernel , HDShaderIDs . g_ vLightListGlobal, bUseClusteredForDeferred ? s_PerVoxelLightLists : s_LightList ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . MainDepthTexture , depthTexture ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . GBufferTexture0 , HDShaderIDs . GBufferTexture0 ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . GBufferTexture1 , HDShaderIDs . GBufferTexture1 ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . GBufferTexture2 , HDShaderIDs . GBufferTexture2 ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . GBufferTexture3 , HDShaderIDs . GBufferTexture3 ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . AmbientOcclusionTexture , HDShaderIDs . AmbientOcclusionTexture ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ MainDepthTexture, depthTexture ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ GBufferTexture0, HDShaderIDs . _ GBufferTexture0) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ GBufferTexture1, HDShaderIDs . _ GBufferTexture1) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ GBufferTexture2, HDShaderIDs . _ GBufferTexture2) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ GBufferTexture3, HDShaderIDs . _ GBufferTexture3) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ AmbientOcclusionTexture, HDShaderIDs . _ AmbientOcclusionTexture) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . LtcData , ltcData ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . PreIntegratedFGD , preIntegratedFGD ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . LtcGGXMatrix , ltcGGXMatrix ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . LtcDisneyDiffuseMatrix , ltcDisneyDiffuseMatrix ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . LtcMultiGGXFresnelDisneyDiffuse , ltcMultiGGXFresnelDisneyDiffuse ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ LtcData, ltcData ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ PreIntegratedFGD, preIntegratedFGD ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ LtcGGXMatrix, ltcGGXMatrix ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ LtcDisneyDiffuseMatrix, ltcDisneyDiffuseMatrix ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ LtcMultiGGXFresnelDisneyDiffuse, ltcMultiGGXFresnelDisneyDiffuse ) ;
cmd . SetComputeMatrixParam ( deferredComputeShader , HDShaderIDs . mInvScrProjection , invScrProjection ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . UseTileLightList , useTileLightList ) ;
cmd . SetComputeMatrixParam ( deferredComputeShader , HDShaderIDs . g_ mInvScrProjection, invScrProjection ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . _ UseTileLightList, useTileLightList ) ;
cmd . SetComputeVectorParam ( deferredComputeShader , HDShaderIDs . Time , time ) ;
cmd . SetComputeVectorParam ( deferredComputeShader , HDShaderIDs . SinTime , sinTime ) ;
cmd . SetComputeVectorParam ( deferredComputeShader , HDShaderIDs . CosTime , cosTime ) ;
cmd . SetComputeVectorParam ( deferredComputeShader , HDShaderIDs . _ Time, time ) ;
cmd . SetComputeVectorParam ( deferredComputeShader , HDShaderIDs . _ SinTime, sinTime ) ;
cmd . SetComputeVectorParam ( deferredComputeShader , HDShaderIDs . _ CosTime, cosTime ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . EnvLightSkyEnabled , envLightSkyEnabled ) ;
cmd . SetComputeFloatParam ( deferredComputeShader , HDShaderIDs . AmbientOcclusionDirectLightStrenght , ambientOcclusionDirectLightStrenght ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . _ EnvLightSkyEnabled, envLightSkyEnabled ) ;
cmd . SetComputeFloatParam ( deferredComputeShader , HDShaderIDs . _ AmbientOcclusionDirectLightStrenght, ambientOcclusionDirectLightStrenght ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . SkyTexture , skyTexture ? skyTexture : m_DefaultTexture2DArray ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . _ SkyTexture, skyTexture ? skyTexture : m_DefaultTexture2DArray ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . EnableSSSAndTransmission , enableSSSAndTransmission ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . TexturingModeFlags , texturingModeFlags ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . TransmissionFlags , transmissionFlags ) ;
cmd . SetComputeVectorArrayParam ( deferredComputeShader , HDShaderIDs . ThicknessRemaps , thicknessRemaps ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . _ EnableSSSAndTransmission, enableSSSAndTransmission ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . _ TexturingModeFlags, texturingModeFlags ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . _ TransmissionFlags, transmissionFlags ) ;
cmd . SetComputeVectorArrayParam ( deferredComputeShader , HDShaderIDs . _ ThicknessRemaps, thicknessRemaps ) ;
cmd . SetComputeVectorArrayParam ( deferredComputeShader , HDShaderIDs . ShapeParams , shapeParams ) ;
cmd . SetComputeVectorArrayParam ( deferredComputeShader , HDShaderIDs . TransmissionTints , transmissionTints ) ;
cmd . SetComputeVectorArrayParam ( deferredComputeShader , HDShaderIDs . _ ShapeParams, shapeParams ) ;
cmd . SetComputeVectorArrayParam ( deferredComputeShader , HDShaderIDs . _ TransmissionTints, transmissionTints ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . specularLightingUAV , colorBuffers [ 0 ] ) ;
cmd . SetComputeTextureParam ( deferredComputeShader , kernel , HDShaderIDs . diffuseLightingUAV , colorBuffers [ 1 ] ) ;
if ( enableFeatureVariants )
{
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . TileListOffset , variant * numTiles ) ;
cmd . SetComputeBufferParam ( deferredComputeShader , kernel , HDShaderIDs . TileList , s_TileList ) ;
cmd . SetComputeIntParam ( deferredComputeShader , HDShaderIDs . g_ TileListOffset, variant * numTiles ) ;
cmd . SetComputeBufferParam ( deferredComputeShader , kernel , HDShaderIDs . g_ TileList, s_TileList ) ;
cmd . DispatchCompute ( deferredComputeShader , kernel , s_DispatchIndirectBuffer , ( uint ) variant * 3 * sizeof ( uint ) ) ;
}
else
// If SSS is disable, do lighting for both split lighting and no split lighting
if ( ! debugDisplaySettings . renderingDebugSettings . enableSSSAndTransmission )
{
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . StencilRef , ( int ) StencilLightingUsage . NoLighting ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . StencilCmp , ( int ) CompareFunction . NotEqual ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . _ StencilRef, ( int ) StencilLightingUsage . NoLighting ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . _ StencilCmp, ( int ) CompareFunction . NotEqual ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . StencilRef , ( int ) StencilLightingUsage . RegularLighting ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . StencilCmp , ( int ) CompareFunction . Equal ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . _ StencilRef, ( int ) StencilLightingUsage . RegularLighting ) ;
m_DeferredAllMaterialSRT . SetInt ( HDShaderIDs . _ StencilCmp, ( int ) CompareFunction . Equal ) ;
}
Utilities . SelectKeyword ( m_DeferredAllMaterialSRT , "USE_CLUSTERED_LIGHTLIST" , "USE_FPTL_LIGHTLIST" , bUseClusteredForDeferred ) ;
// say that we want to use tile of single loop
cmd . EnableShaderKeyword ( "LIGHTLOOP_TILE_PASS" ) ;
cmd . DisableShaderKeyword ( "LIGHTLOOP_SINGLE_PASS" ) ;
cmd . SetGlobalFloat ( HDShaderIDs . UseTileLightList , useFptl ? 1 : 0 ) ; // leaving this as a dynamic toggle for now for forward opaques to keep shader variants down.
cmd . SetGlobalBuffer ( HDShaderIDs . vLightListGlobal , useFptl ? s_LightList : s_PerVoxelLightLists ) ;
cmd . SetGlobalFloat ( HDShaderIDs . _ UseTileLightList, useFptl ? 1 : 0 ) ; // leaving this as a dynamic toggle for now for forward opaques to keep shader variants down.
cmd . SetGlobalBuffer ( HDShaderIDs . g_ vLightListGlobal, useFptl ? s_LightList : s_PerVoxelLightLists ) ;
}
}
}