From 638c775707240d365432ed910a88a3cbf545a130 Mon Sep 17 00:00:00 2001 From: HampusM Date: Thu, 23 May 2024 20:22:08 +0200 Subject: refactor(engine): pass vertex data as struct to calc_point_light --- engine/fragment.glsl | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'engine/fragment.glsl') diff --git a/engine/fragment.glsl b/engine/fragment.glsl index 6e852f3..afeef25 100644 --- a/engine/fragment.glsl +++ b/engine/fragment.glsl @@ -1,6 +1,7 @@ #version 330 core #preinclude "light.glsl" +#preinclude "vertex_data.glsl" #define MAX_POINT_LIGHT_CNT 64 @@ -19,16 +20,20 @@ uniform int point_light_cnt; void main() { + VertexData vertex_data; + + vertex_data.texture_coords = in_texture_coords; + vertex_data.world_space_pos = in_frag_pos; + vertex_data.world_space_normal = in_normal; + vec3 ambient_light = calc_ambient_light(material, in_texture_coords); vec3 point_light_sum = vec3(0.0, 0.0, 0.0); - for (int pl_index= 0; pl_index < point_light_cnt; pl_index++) { + for (int pl_index = 0; pl_index < point_light_cnt; pl_index++) { point_light_sum += calc_point_light( point_lights[pl_index], - in_frag_pos, - in_normal, - in_texture_coords, + vertex_data, view_pos, material ); -- cgit v1.2.3-18-g5258