feat: move light dir independently from camera
This commit is contained in:
parent
919d809467
commit
4d1d2ed477
|
@ -2,6 +2,7 @@
|
|||
|
||||
in vec3 Normal;
|
||||
in vec3 FragPos;
|
||||
in mat4x4 ModelViewProjection;
|
||||
|
||||
out vec4 FragColor;
|
||||
|
||||
|
@ -17,7 +18,7 @@ void main()
|
|||
|
||||
// Directional lighting
|
||||
vec3 directionalLightColor = vec3(1.0, 1.0, 1.0);
|
||||
vec3 lightPos = vec3(10.0, 7.0, -8.0);
|
||||
vec3 lightPos = (ModelViewProjection * vec4(6.0, -7.0, 8.0, 1.0)).xyz;
|
||||
vec3 normal = normalize(Normal);
|
||||
vec3 lightDir = normalize(lightPos - FragPos);
|
||||
float diff = max(dot(normal, lightDir), 0.0);
|
||||
|
|
|
@ -9,11 +9,13 @@ uniform mat4x4 _Projection;
|
|||
|
||||
out vec3 Normal;
|
||||
out vec3 FragPos;
|
||||
out mat4x4 ModelViewProjection;
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 pos = vec4(aPos, 1.0);
|
||||
mat4x4 mvp = _Projection * _View * _Model;
|
||||
ModelViewProjection = mvp;
|
||||
|
||||
gl_Position = mvp * pos;
|
||||
FragPos = vec3(_Model * pos);
|
||||
|
|
Loading…
Reference in New Issue