|
|
|
|
|
|
private ComputeShader buildDispatchIndirectShader { get { return m_Resources.buildDispatchIndirectShader; } } |
|
|
|
private ComputeShader clearDispatchIndirectShader { get { return m_Resources.clearDispatchIndirectShader; } } |
|
|
|
private ComputeShader deferredComputeShader { get { return m_Resources.deferredComputeShader; } } |
|
|
|
private ComputeShader deferredDirectionalShadowComputeShader { get { return m_Resources.deferredDirectionalShadowComputeShader; } } |
|
|
|
private ComputeShader screenSpaceShadowComputeShader { get { return m_Resources.screenSpaceShadowComputeShader; } } |
|
|
|
|
|
|
|
|
|
|
|
static int s_GenAABBKernel; |
|
|
|
|
|
|
s_shadeOpaqueDirectShadowMaskFptlKernel = deferredComputeShader.FindKernel("Deferred_Direct_ShadowMask_Fptl"); |
|
|
|
s_shadeOpaqueDirectShadowMaskFptlDebugDisplayKernel = deferredComputeShader.FindKernel("Deferred_Direct_ShadowMask_Fptl_DebugDisplay"); |
|
|
|
|
|
|
|
s_deferredDirectionalShadowKernel = deferredDirectionalShadowComputeShader.FindKernel("DeferredDirectionalShadow"); |
|
|
|
s_deferredDirectionalShadow_Contact_Kernel = deferredDirectionalShadowComputeShader.FindKernel("DeferredDirectionalShadow_Contact"); |
|
|
|
s_deferredContactShadowKernel = deferredDirectionalShadowComputeShader.FindKernel("DeferredContactShadow"); |
|
|
|
s_deferredDirectionalShadowKernel = screenSpaceShadowComputeShader.FindKernel("DeferredDirectionalShadow"); |
|
|
|
s_deferredDirectionalShadow_Contact_Kernel = screenSpaceShadowComputeShader.FindKernel("DeferredDirectionalShadow_Contact"); |
|
|
|
s_deferredContactShadowKernel = screenSpaceShadowComputeShader.FindKernel("DeferredContactShadow"); |
|
|
|
|
|
|
|
for (int variant = 0; variant < LightDefinitions.s_NumFeatureVariants; variant++) |
|
|
|
{ |
|
|
|
|
|
|
lightDirection.w = 0; |
|
|
|
} |
|
|
|
|
|
|
|
m_ShadowMgr.BindResources(cmd, deferredDirectionalShadowComputeShader, kernel); |
|
|
|
m_ShadowMgr.BindResources(cmd, screenSpaceShadowComputeShader, kernel); |
|
|
|
|
|
|
|
if (m_ContactShadows) |
|
|
|
{ |
|
|
|
|
|
|
Vector4 contactShadowParams = new Vector4(m_ContactShadows.length, m_ContactShadows.distanceScaleFactor, contactShadowFadeEnd, contactShadowOneOverFadeRange); |
|
|
|
cmd.SetComputeVectorParam(deferredDirectionalShadowComputeShader, HDShaderIDs._DirectionalContactShadowParams, contactShadowParams); |
|
|
|
cmd.SetComputeIntParam(deferredDirectionalShadowComputeShader, HDShaderIDs._DirectionalContactShadowSampleCount, m_ContactShadows.sampleCount); |
|
|
|
cmd.SetComputeVectorParam(screenSpaceShadowComputeShader, HDShaderIDs._DirectionalContactShadowParams, contactShadowParams); |
|
|
|
cmd.SetComputeIntParam(screenSpaceShadowComputeShader, HDShaderIDs._DirectionalContactShadowSampleCount, m_ContactShadows.sampleCount); |
|
|
|
cmd.SetComputeIntParam(deferredDirectionalShadowComputeShader, HDShaderIDs._DirectionalShadowIndex, m_CurrentSunLightShadowIndex); |
|
|
|
cmd.SetComputeVectorParam(deferredDirectionalShadowComputeShader, HDShaderIDs._DirectionalLightDirection, lightDirection); |
|
|
|
cmd.SetComputeVectorParam(deferredDirectionalShadowComputeShader, HDShaderIDs._PunctualLightPosition, lightPosition); |
|
|
|
cmd.SetComputeTextureParam(deferredDirectionalShadowComputeShader, kernel, HDShaderIDs._DeferredShadowTextureUAV, deferredShadowRT); |
|
|
|
cmd.SetComputeTextureParam(deferredDirectionalShadowComputeShader, kernel, HDShaderIDs._CameraDepthTexture, depthTexture); |
|
|
|
cmd.SetComputeIntParam(screenSpaceShadowComputeShader, HDShaderIDs._DirectionalShadowIndex, m_CurrentSunLightShadowIndex); |
|
|
|
cmd.SetComputeVectorParam(screenSpaceShadowComputeShader, HDShaderIDs._DirectionalLightDirection, lightDirection); |
|
|
|
cmd.SetComputeVectorParam(screenSpaceShadowComputeShader, HDShaderIDs._PunctualLightPosition, lightPosition); |
|
|
|
cmd.SetComputeTextureParam(screenSpaceShadowComputeShader, kernel, HDShaderIDs._DeferredShadowTextureUAV, deferredShadowRT); |
|
|
|
cmd.SetComputeTextureParam(screenSpaceShadowComputeShader, kernel, HDShaderIDs._CameraDepthTexture, depthTexture); |
|
|
|
|
|
|
|
int deferredShadowTileSize = 16; // Must match DeferreDirectionalShadow.compute
|
|
|
|
int numTilesX = (hdCamera.actualWidth + (deferredShadowTileSize - 1)) / deferredShadowTileSize; |
|
|
|
|
|
|
cmd.DispatchCompute(deferredDirectionalShadowComputeShader, kernel, numTilesX, numTilesY, 1); |
|
|
|
cmd.DispatchCompute(screenSpaceShadowComputeShader, kernel, numTilesX, numTilesY, 1); |
|
|
|
|
|
|
|
cmd.SetGlobalTexture(HDShaderIDs._DeferredShadowTexture, deferredShadowRT); |
|
|
|
} |
|
|
|