Skip to content

Instantly share code, notes, and snippets.

@shakesoda
Created November 16, 2016 19:20
Show Gist options
  • Save shakesoda/0a538e5b55e946597b0ff80fbc8b1898 to your computer and use it in GitHub Desktop.
Save shakesoda/0a538e5b55e946597b0ff80fbc8b1898 to your computer and use it in GitHub Desktop.
varying vec3 f_normal;
#ifdef VERTEX
attribute vec3 VertexNormal;
uniform mat4 u_view, u_model, u_projection;
vec4 position(mat4 mvp, vec4 v_position) {
f_normal = (u_model * vec4(VertexNormal, 1.0)).xyz;
return u_projection * u_view * u_model * v_position;
}
#endif
#ifdef PIXEL
uniform vec3 u_light_direction;
vec4 effect(vec4 color, Image texture, vec2 texture_coords, vec2 screen_coords) {
vec4 out_color = texture2D(texture, texture_coords);
out_color.a = 1.0;
out_color *= color;
out_color *= dot(normalize(f_normal, u_light_direction));
return out_color;
}
#endif
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment