This commit is contained in:
Confideo-IOM
2026-08-18 16:23:20 +01:00
parent 282243a16b
commit 20c0794d10
66 changed files with 622 additions and 1144 deletions
@@ -128,6 +128,13 @@ const float PI = 3.14159265358979323846;
const float M_INV_PI = 0.31830988618379067153776752674503;
float sqr(float x) { return x*x; }
vec3 GetPositionFromView(mat4 view)
{
mat3 rot_mat = mat3(view);
vec3 d = vec3(view[3]); // Column-major translation column
return -d * rot_mat;
}
// ----------------------------------------------------------------------------
float DistributionGGX(vec3 N, vec3 H, float roughness)
{
@@ -490,7 +497,7 @@ float SampleCubemapShadow(vec3 frag_to_light, float far_plane, float view_distan
);
float shadow = 0.0;
float bias = 0.05;
float bias = 0.0005;
int samples = 20;
@@ -547,7 +554,8 @@ void main()
mat3 rot_mat = GetRotationOnlyMatrix(model);
vec3 light_direction = normalize(rot_mat * vec3(0,0,1));
vec3 light_pos = model[3].xyz;
vec3 light_pos = GetPositionFromView(model);
light_pos = model[3].xyx;
if(lights[i].light_type == HYDRA_LIGHT_DIRECTIONAL)
{
Lo += DirectionalShading(normal, diffuse.xyz, rough, metal, lights[i].intensity, light_direction, light_pos, world_pos, ubo_per_frame.viewer_pos);
@@ -562,10 +570,11 @@ void main()
else if(lights[i].light_type == HYDRA_LIGHT_POINT)
{
float shadow = 0;
if(lights[i].shadow_caster == 1)
{
float view_to_frag = length(light_pos - ubo_per_frame.viewer_pos );
shadow = CalculatePointShadow(world_pos, i, view_to_frag, light_pos);
shadow = CalculatePointShadow(world_pos, lights[i].shadow_map_id, view_to_frag, light_pos);
}
Lo += PointShading(normal,
@@ -579,7 +588,7 @@ void main()
lights[i].quadratic,
world_pos,
ubo_per_frame.viewer_pos,
shadow);
shadow);
}
else if(lights[i].light_type == HYDRA_LIGHT_SPOT)
@@ -609,8 +618,6 @@ void main()
world_pos,
ubo_per_frame.viewer_pos,
shadow) * lights[i].diffuse.xyz;
}
}