Simplify descriptor setup

Refs #1157
This commit is contained in:
Sascha Willems 2024-10-06 15:17:11 +02:00
parent 6b91f3c493
commit a2d5a1fd44
18 changed files with 41 additions and 68 deletions

View file

@ -1,4 +1,5 @@
// Copyright 2020 Google LLC
// Copyright 2024 Sascha Willems
struct VSInput
{
@ -17,8 +18,7 @@ struct PushConsts {
struct UBO {
float4x4 cascadeViewProjMat[SHADOW_MAP_CASCADE_COUNT];
};
cbuffer ubo : register(b0) { UBO ubo; }
cbuffer ubo : register(b3) { UBO ubo; }
struct VSOutput
{

View file

@ -1,4 +1,5 @@
// Copyright 2020 Google LLC
// Copyright 2024 Sascha Willems
#define SHADOW_MAP_CASCADE_COUNT 4
@ -22,7 +23,6 @@ struct VSOutput
struct UBO {
float4 cascadeSplits;
float4x4 cascadeViewProjMat[SHADOW_MAP_CASCADE_COUNT];
float4x4 inverseViewMat;
float3 lightDir;
float _pad;
@ -30,6 +30,11 @@ struct UBO {
};
cbuffer ubo : register(b2) { UBO ubo; };
struct CVPM {
float4x4 matrices[SHADOW_MAP_CASCADE_COUNT];
};
cbuffer cascadeViewProjMatrices : register(b3) { CVPM cascadeViewProjMatrices; }
static const float4x4 biasMat = float4x4(
0.5, 0.0, 0.0, 0.5,
0.0, 0.5, 0.0, 0.5,
@ -90,7 +95,7 @@ float4 main(VSOutput input) : SV_TARGET
}
// Depth compare for shadowing
float4 shadowCoord = mul(biasMat, mul(ubo.cascadeViewProjMat[cascadeIndex], float4(input.Pos, 1.0)));
float4 shadowCoord = mul(biasMat, mul(cascadeViewProjMatrices.matrices[cascadeIndex], float4(input.Pos, 1.0)));
float shadow = 0;
if (enablePCF == 1) {