parent
6b91f3c493
commit
a2d5a1fd44
18 changed files with 41 additions and 68 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -11,16 +11,12 @@ layout(push_constant) uniform PushConsts {
|
|||
uint cascadeIndex;
|
||||
} pushConsts;
|
||||
|
||||
layout (binding = 0) uniform UBO {
|
||||
layout (set = 0, binding = 3) uniform UBO {
|
||||
mat4[SHADOW_MAP_CASCADE_COUNT] cascadeViewProjMat;
|
||||
} ubo;
|
||||
|
||||
layout (location = 0) out vec2 outUV;
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
outUV = inUV;
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -19,13 +19,16 @@ layout (location = 0) out vec4 outFragColor;
|
|||
|
||||
layout (set = 0, binding = 2) uniform UBO {
|
||||
vec4 cascadeSplits;
|
||||
mat4 cascadeViewProjMat[SHADOW_MAP_CASCADE_COUNT];
|
||||
mat4 inverseViewMat;
|
||||
vec3 lightDir;
|
||||
float _pad;
|
||||
int colorCascades;
|
||||
} ubo;
|
||||
|
||||
layout (set = 0, binding = 3) uniform CVPM {
|
||||
mat4 matrices[SHADOW_MAP_CASCADE_COUNT];
|
||||
} cascadeViewProjMatrices;
|
||||
|
||||
const mat4 biasMat = mat4(
|
||||
0.5, 0.0, 0.0, 0.0,
|
||||
0.0, 0.5, 0.0, 0.0,
|
||||
|
|
@ -84,7 +87,7 @@ void main()
|
|||
}
|
||||
|
||||
// Depth compare for shadowing
|
||||
vec4 shadowCoord = (biasMat * ubo.cascadeViewProjMat[cascadeIndex]) * vec4(inPos, 1.0);
|
||||
vec4 shadowCoord = (biasMat * cascadeViewProjMatrices.matrices[cascadeIndex]) * vec4(inPos, 1.0);
|
||||
|
||||
float shadow = 0;
|
||||
if (enablePCF == 1) {
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -22,10 +22,6 @@ layout(push_constant) uniform PushConsts {
|
|||
uint cascadeIndex;
|
||||
} pushConsts;
|
||||
|
||||
out gl_PerVertex {
|
||||
vec4 gl_Position;
|
||||
};
|
||||
|
||||
void main()
|
||||
{
|
||||
outColor = inColor;
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -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) {
|
||||
|
|
|
|||
Binary file not shown.
Binary file not shown.
Loading…
Add table
Add a link
Reference in a new issue