diff options
author | pommicket <pommicket@gmail.com> | 2021-09-25 22:15:59 -0400 |
---|---|---|
committer | pommicket <pommicket@gmail.com> | 2021-09-25 22:15:59 -0400 |
commit | 4502fee2542cf3a2523d6bb615faa5009cfd00aa (patch) | |
tree | dcf7abc69c6b3bc82219f473b5aaf8e0172133bb /mainf.glsl | |
parent | 8ea1d64652f3b287139bd775a75cc13f0678e5d6 (diff) |
an object
Diffstat (limited to 'mainf.glsl')
-rw-r--r-- | mainf.glsl | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/mainf.glsl b/mainf.glsl new file mode 100644 index 0000000..46ebdcb --- /dev/null +++ b/mainf.glsl @@ -0,0 +1,22 @@ +uniform vec3 u_color; +uniform vec3 u_directional_light1; // (direction to light) +uniform vec3 u_directional_light1_color; +uniform vec3 u_directional_light2; +uniform vec3 u_directional_light2_color; +uniform vec3 u_ambient_light; +uniform int u_lighting_enabled; + +varying vec3 normal; + +void main() { + vec3 N = normalize(normal); + vec3 L; + if (u_lighting_enabled != 0) { + L = max(0.0, dot(u_directional_light1, N)) * u_directional_light1_color + + max(0.0, dot(u_directional_light2, N)) * u_directional_light2_color + + u_ambient_light; + } else { + L = vec3(1.0, 1.0, 1.0); + } + gl_FragColor = vec4(L * u_color, 1.0); +} |