2023-08-02 08:52:57 +00:00
|
|
|
#version 450
|
|
|
|
#extension GL_GOOGLE_include_directive : enable
|
|
|
|
|
2023-08-02 10:34:37 +00:00
|
|
|
layout (set = 0, binding = 0) buffer ShadowMatrices {
|
|
|
|
mat4 shadow_mats[];
|
|
|
|
};
|
2023-08-02 08:52:57 +00:00
|
|
|
layout (set = 3, binding = 0) uniform sampler2DArrayShadow shadow_map[32];
|
|
|
|
|
|
|
|
float
|
2023-08-02 15:05:41 +00:00
|
|
|
shadow (uint map_id, uint layer, uint mat_id, vec3 pos, vec3 lpos)
|
2023-08-02 08:52:57 +00:00
|
|
|
{
|
2023-08-02 10:34:37 +00:00
|
|
|
vec4 p = shadow_mats[mat_id] * vec4 (pos, 1);
|
2023-08-05 10:59:53 +00:00
|
|
|
p = p / p.w;
|
2023-08-02 10:34:37 +00:00
|
|
|
float depth = p.z;
|
|
|
|
vec2 uv = (p.xy + vec2(1)) / 2;
|
|
|
|
return texture (shadow_map[map_id], vec4 (uv, layer, depth));
|
2023-08-02 08:52:57 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#include "lighting_main.finc"
|