Spot started

This commit is contained in:
Confideo-IOM
2026-08-04 22:40:48 +01:00
parent f51b435a9d
commit 6d7d7571b5
48 changed files with 1086 additions and 1222 deletions
@@ -321,12 +321,12 @@ float SampleShadow(vec4 frag_clip_space, sampler2DArray sampler_shadow_map, uint
vec3 CalculateDirectionalShadow(vec4 world_pos, uint shadow_idx, vec3 normal, vec3 light_dir, vec3 viewer_pos)
{
float shadow = 0;
float shadow = 1;
//measure the distance of the fragment from the light
float frag_distance = abs(length(viewer_pos - world_pos.xyz));
uint shadow_trans_idx = 5;
uint shadow_trans_idx = 6;
uint ignore_shadow = 0;
//Work out which shadowmap is appropriate for this distance
for(uint i = 0; i < 6; i++)
@@ -340,7 +340,7 @@ vec3 CalculateDirectionalShadow(vec4 world_pos, uint shadow_idx, vec3 normal, ve
break;
}
}
if(ignore_shadow == 1)
{
vec4 translated_pixel = shadows[shadow_idx].light_space_proj[shadow_trans_idx] *
@@ -348,21 +348,29 @@ vec3 CalculateDirectionalShadow(vec4 world_pos, uint shadow_idx, vec3 normal, ve
world_pos;
uvec2 shadow_handle = textures[shadows[shadow_idx].shadow_texture_id];
shadow = 1.0 - SampleShadow(translated_pixel, sampler2DArray(shadow_handle), shadow_trans_idx, normal, light_dir);
}
return vec3(shadow);
//return 1.0 - shadow;
if(shadow_trans_idx == 0)
{
return vec3(1,0,0) * shadow;
}
if(shadow_trans_idx == 1)
{
return vec3(0,1,0) * shadow;
return vec3(1,1,0) * shadow;
}
if(shadow_trans_idx == 2)
{
return vec3(0,0,1) * shadow;
return vec3(0.5,0.5,1) * shadow;
}
if(shadow_trans_idx == 3)
{
return vec3(1,0,1) * shadow;
}
if(shadow_trans_idx == 4)
{
return vec3(1,1,1) * shadow;
}
return vec3(0,1,1) * shadow;
}
@@ -50,7 +50,7 @@ void main()
diffuse_val = diffuse_val * texture(sampler2D(diffuse_handle), geom_out.vsUV.xy);
if(mat.diffuse_texture_id== 10)
{
output_colour = vec4(0,0,1,1);
output_colour = vec4(0,0,1,1);
}
}
@@ -0,0 +1,63 @@
//*PIXEL*
#version 460
#extension GL_ARB_bindless_texture : require
const uint DIRECTIONAL_LIGHT = 1;
const uint POINT_LIGHT = 2;
const uint SPOT_LIGHT = 3;
uint INVALID_HYDRA_ID = 4294967295;
struct MaterialStore
{
vec4 diffuse_colour;
vec4 matalic_rough;
uint diffuse_texture_id;
uint metallic_rough_texture_id;
uint normal_texture_id;
uint padding[1];
};
layout(std430, binding = 2) readonly buffer material_buffer
{
MaterialStore materials[1000];
};
layout(std430, binding = 3) readonly buffer texture_buffer
{
uvec2 textures[1000];
};
layout (location=0) in VS_OUT
{
vec2 vsUV;
flat uint vsMaterialID;
}vs_out;
layout (location=0) out vec4 output_colour;
void main()
{
MaterialStore mat = materials[vs_out.vsMaterialID];
vec4 diffuse_val = mat.diffuse_colour;
output_colour = vec4(1,0,0,1);
if(mat.diffuse_texture_id != INVALID_HYDRA_ID)
{
output_colour = vec4(0,1,0,1);
uvec2 diffuse_handle = textures[mat.diffuse_texture_id];
diffuse_val = diffuse_val * texture(sampler2D(diffuse_handle), vs_out.vsUV.xy);
if(mat.diffuse_texture_id== 10)
{
output_colour = vec4(0,0,1,1);
}
}
if(diffuse_val[3] < 1.0)
{
discard;
output_colour = vec4(0,1,1,1);
}
}
@@ -0,0 +1,30 @@
//*VERTEX*
#version 460
layout(binding = 1) readonly buffer positions_buffer
{
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;
layout (location=0) out VS_OUT
{
vec2 vsUV;
flat uint vsMaterialID;
}vs_out;
void main()
{
uint chunkid = inChunkID[0];
mat4 model = model_matrix[chunkid];
gl_Position = model * vec4(inPos, 1.0);
vs_out.vsUV = inUV;
vs_out.vsMaterialID = inChunkID[1];
}