Files
HydraV3/HydraEngine/source/ShaderFiles/shadow_cascade_shader.geom
T

63 lines
1.3 KiB
GLSL
Raw Normal View History

2026-07-28 00:26:04 +01:00
#version 450
layout(triangles, invocations = 6) in;
layout(triangle_strip, max_vertices = 3) out;
2026-08-06 21:11:33 +01:00
struct DirectionalShadowMapSet
2026-07-28 00:26:04 +01:00
{
uint entity_id;
2026-08-06 21:11:33 +01:00
uint shadow_id;
2026-07-28 00:26:04 +01:00
uint shadow_texture_id;
2026-07-28 19:02:45 +01:00
uint frame_buffer_id;
2026-07-28 00:26:04 +01:00
float near_plane[8];
float far_plane[8];
mat4 light_space_proj[6];
mat4 light_space_view[6];
};
2026-08-06 21:11:33 +01:00
2026-07-28 00:26:04 +01:00
//Push constants updated for each light
layout(binding = 0) uniform shadow_per_frame
{
vec3 camera_pos;
uint shadow_idxs;
};
2026-08-06 21:11:33 +01:00
layout (std430, binding = 5) readonly buffer directional_shadow_map_sets
2026-07-28 00:26:04 +01:00
{
2026-08-06 21:11:33 +01:00
DirectionalShadowMapSet directional_shadows[];
2026-07-28 00:26:04 +01:00
};
2026-08-03 22:34:52 +01:00
2026-08-06 21:11:33 +01:00
2026-08-03 22:34:52 +01:00
layout (location=0) in VS_OUT
{
vec2 vsUV;
flat uint vsMaterialID;
}vs_in[];
layout (location=0) out GEOM_OUT
{
vec2 vsUV;
flat uint vsMaterialID;
}geom_out;
2026-07-28 00:26:04 +01:00
void main()
2026-08-03 22:34:52 +01:00
{
2026-08-06 21:11:33 +01:00
mat4 view = directional_shadows[shadow_idxs].light_space_view[gl_InvocationID];
mat4 proj = directional_shadows[shadow_idxs].light_space_proj[gl_InvocationID];
2026-08-03 22:34:52 +01:00
2026-07-28 00:26:04 +01:00
for (int i = 0; i < 3; ++i)
{
gl_Layer = gl_InvocationID;
2026-08-03 22:34:52 +01:00
vec4 clip_space_pos = proj * view * gl_in[i].gl_Position;
gl_Position = clip_space_pos;
geom_out.vsMaterialID = vs_in[gl_InvocationID].vsMaterialID;
geom_out.vsUV = vs_in[gl_InvocationID].vsUV;
EmitVertex();
2026-07-28 00:26:04 +01:00
}
EndPrimitive();
}