Point light working
This commit is contained in:
@@ -0,0 +1,74 @@
|
||||
#version 450
|
||||
|
||||
layout(triangles, invocations = 6) in;
|
||||
layout(triangle_strip, max_vertices = 3) out;
|
||||
|
||||
|
||||
struct PointShadowMapSet
|
||||
{
|
||||
uint entity_id;
|
||||
uint shadow_id;
|
||||
uint shadow_texture_id;
|
||||
uint frame_buffer_id;
|
||||
float near_plane;
|
||||
float far_plane;
|
||||
uint padding[2];
|
||||
mat4 light_space_proj;
|
||||
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 = 7) readonly buffer point_shadow_map_sets
|
||||
{
|
||||
PointShadowMapSet point_shadows[];
|
||||
};
|
||||
|
||||
layout (location=0) in VS_OUT
|
||||
{
|
||||
vec2 vsUV;
|
||||
flat uint vsMaterialID;
|
||||
}vs_in[];
|
||||
|
||||
layout (location=0) out GEOM_OUT
|
||||
{
|
||||
vec2 vsUV;
|
||||
flat uint vsMaterialID;
|
||||
vec4 frag_pos;
|
||||
flat uint shad_idx;
|
||||
flat vec3 light_pos;
|
||||
}geom_out;
|
||||
|
||||
void main()
|
||||
{
|
||||
mat4 view = point_shadows[shadow_idxs].light_space_view[gl_InvocationID];
|
||||
mat4 proj = point_shadows[shadow_idxs].light_space_proj;
|
||||
|
||||
mat3 rot_mat = mat3(view);
|
||||
vec3 d = vec3(view[3]); // Column-major translation column
|
||||
vec3 light_pos = -d * rot_mat;
|
||||
|
||||
for (int i = 0; i < 3; ++i)
|
||||
{
|
||||
geom_out.light_pos = light_pos;
|
||||
geom_out.shad_idx = shadow_idxs;
|
||||
geom_out.frag_pos = gl_in[i].gl_Position;
|
||||
gl_Layer = gl_InvocationID;
|
||||
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();
|
||||
}
|
||||
EndPrimitive();
|
||||
}
|
||||
Reference in New Issue
Block a user