Shadows - need to fix frame buffers

This commit is contained in:
Confideo-IOM
2026-07-28 00:26:04 +01:00
parent 3810f74e81
commit d48097c645
54 changed files with 623 additions and 100 deletions
@@ -45,7 +45,7 @@ layout(binding = 1) uniform uniform_output_textures
uint texture_ids[16];
};
layout(binding = 1) readonly buffer PositionsBuffer
layout(std430, binding = 1) readonly buffer PositionsBuffer
{
mat4 model_matrix[];
};
@@ -9,7 +9,7 @@ layout(binding = 0) uniform uniform_per_frame
uint light_count;
} ubo_per_frame;
layout(binding = 1) readonly buffer PositionsBuffer
layout(std430, binding = 1) readonly buffer PositionsBuffer
{
mat4 model_matrix[];
};
@@ -9,7 +9,7 @@ layout(binding = 0) uniform uniform_per_frame
uint light_count;
} ubo_per_frame;
layout(binding = 1) readonly buffer PositionsBuffer
layout(std430, binding = 1) readonly buffer PositionsBuffer
{
mat4 model_matrix[];
};
@@ -0,0 +1,17 @@
//*PIXEL*
#version 450
#extension GL_EXT_scalar_block_layout : enable
#extension GL_EXT_nonuniform_qualifier : enable
const uint DIRECTIONAL_LIGHT = 1;
const uint POINT_LIGHT = 2;
const uint SPOT_LIGHT = 3;
void main()
{
//gl_FragDepth = gl_FragCoord.z;
}
@@ -0,0 +1,45 @@
#version 450
layout(triangles, invocations = 6) in;
layout(triangle_strip, max_vertices = 3) out;
struct ShadowMapSet
{
uint entity_id;
uint cascade_count;
uint shadow_texture_id;
uint padding0;
float near_plane[8];
float far_plane[8];
mat4 light_space_proj[6];
mat4 light_space_view[6];
};
//Push constants updated for each light
layout(binding = 0) uniform shadow_per_frame
{
vec3 camera_pos;
uint shadow_idxs;
};
layout(std430, binding = 0) readonly buffer ShadowMapSets
{
ShadowMapSet shadows[10];
};
void main()
{
for (int i = 0; i < 3; ++i)
{
gl_Position = shadows[shadow_idxs].light_space_proj[gl_InvocationID] *
shadows[shadow_idxs].light_space_view[gl_InvocationID] *
gl_in[i].gl_Position;
gl_Layer = gl_InvocationID;
EmitVertex();
}
EndPrimitive();
}
@@ -0,0 +1,23 @@
//*VERTEX*
#version 450
#extension GL_EXT_buffer_reference : enable
layout(binding = 1) readonly buffer PositionsBuffer
{
mat4 model_matrix[];
};
layout (location = 0) in vec3 inPos; //12 bytes : 0
layout (location = 1) in vec2 inUV; //8 Bytes : 12
layout (location = 2) in uvec3 inChunkID; //12 Bytes : 20
layout (location = 3) in vec3 inNormal; //8 Bytes : 12
layout (location = 4) in vec3 inBiTangent;
layout (location = 5) in vec3 inTangent;
void main()
{
uint chunkid = inChunkID[0];
mat4 model = model_matrix[chunkid];
gl_Position = model * vec4(inPos, 1.0);
}