Sun + dynamic lighting

This commit is contained in:
Anuken
2020-02-28 13:18:06 -05:00
parent 21bd7a75f0
commit 120d96c775
14 changed files with 360 additions and 97 deletions
+4 -1
View File
@@ -1,7 +1,10 @@
attribute vec4 a_position;
attribute vec3 a_normal;
attribute vec4 a_color;
uniform mat4 u_projModelView;
uniform vec3 u_lightdir;
varying vec4 v_col;
const vec3 ambientColor = vec3(1.0);
@@ -11,7 +14,7 @@ const vec3 v1 = vec3(1.0, 0.0, 1.0);
const vec3 v2 = vec3(1.0, 0.5, 0.0);
void main(){
vec3 norc = ambientColor * (diffuse + vec3(clamp((dot(a_normal, ambientDir) + 1.0) / 2.0, 0.0, 1.0)));
vec3 norc = ambientColor * (diffuse + vec3(clamp((dot(a_normal, u_lightdir) + 1.0) / 2.0, 0.0, 1.0)));
v_col = a_color * vec4(norc, 1.0);
gl_Position = u_projModelView * a_position;