diff options
Diffstat (limited to 'engine/light.glsl')
-rw-r--r-- | engine/light.glsl | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/engine/light.glsl b/engine/light.glsl index 9f51237..92d3ec3 100644 --- a/engine/light.glsl +++ b/engine/light.glsl @@ -3,6 +3,8 @@ #ifndef LIGHT_GLSL #define LIGHT_GLSL +#preinclude "vertex_data.glsl" + struct Material { vec3 ambient; @@ -88,22 +90,20 @@ float calc_attenuation(in PointLight point_light, in vec3 position) vec3 calc_point_light( in PointLight light, - in vec3 frag_pos, - in vec3 normal, - in vec2 texture_coords, + in VertexData vertex_data, in vec3 view_pos, in Material material ) { - vec3 light_direction = normalize(light.position - frag_pos); - vec3 norm = normalize(normal); + vec3 light_direction = normalize(light.position - vertex_data.world_space_pos); + vec3 norm = normalize(vertex_data.world_space_normal); vec3 diffuse_light = calc_diffuse_light( material, light.phong, light_direction, norm, - texture_coords + vertex_data.texture_coords ); vec3 specular_light = calc_specular_light( @@ -112,11 +112,11 @@ vec3 calc_point_light( light_direction, norm, view_pos, - frag_pos, - texture_coords + vertex_data.world_space_pos, + vertex_data.texture_coords ); - float attenuation = calc_attenuation(light, frag_pos); + float attenuation = calc_attenuation(light, vertex_data.world_space_pos); diffuse_light *= attenuation; specular_light *= attenuation; |