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

Commit

Permalink
Fix Light rendering (#188)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
TsurHerman authored and SimonDanisch committed Jul 27, 2017
1 parent dbdcb1c commit c3e7a31
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions assets/shader/util.vert
Original file line number Diff line number Diff line change
Expand Up @@ -238,9 +238,9 @@ void render(vec3 vertex, vec3 normal, mat4 viewmodel, mat4 projection, vec3 ligh
{
vec4 position_camspace = viewmodel * vec4(vertex, 1);
// normal in world space
o_normal = normal;
o_normal = vec3(transpose(inverse(viewmodel)) * vec4(normal,0));
// direction to light
o_lightdir = normalize(light[3] - vertex);
o_lightdir = normalize(light[3] - vec3(position_camspace));
// direction to camera
o_vertex = -position_camspace.xyz;
// screen space coordinates of the vertex
Expand Down

0 comments on commit c3e7a31

Please sign in to comment.