Skip to content
This repository was archived by the owner on Apr 28, 2021. It is now read-only.

Commit c3e7a31

Browse files
TsurHermanSimonDanisch
authored andcommitted
Fix Light rendering (#188)
Change the Light rendering such that the light position is given in eye space as is the common practice. Previous implementation had light position given in model space which makes it extra hard to render a few models in the same world with some fixed lighting.
1 parent dbdcb1c commit c3e7a31

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

assets/shader/util.vert

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -238,9 +238,9 @@ void render(vec3 vertex, vec3 normal, mat4 viewmodel, mat4 projection, vec3 ligh
238238
{
239239
vec4 position_camspace = viewmodel * vec4(vertex, 1);
240240
// normal in world space
241-
o_normal = normal;
241+
o_normal = vec3(transpose(inverse(viewmodel)) * vec4(normal,0));
242242
// direction to light
243-
o_lightdir = normalize(light[3] - vertex);
243+
o_lightdir = normalize(light[3] - vec3(position_camspace));
244244
// direction to camera
245245
o_vertex = -position_camspace.xyz;
246246
// screen space coordinates of the vertex

0 commit comments

Comments
 (0)