2021-32-bit-holiday-jam/shaders/terrain-vert.glsl

22 lines
536 B
GLSL

#define lowp
#define mediump
#define highp
#line 0
attribute highp vec4 attr_pos;
attribute lowp vec3 attr_normal;
attribute lowp vec3 attr_color;
uniform highp mat4 uni_mvp;
varying lowp vec3 vary_color;
void main (void) {
vec3 sun_dir = normalize (vec3 (1.0, 1.0, 4.0));
vec3 sun_light = vec3 (1.0, 0.75, 0.5) * sqrt (max (0.0, dot (attr_normal, sun_dir)));
vec3 sky_light = vec3 (0.0, 0.25, 0.5) * (attr_normal.z * 0.5 + 0.5);
vary_color = sqrt (attr_color * (sun_light + sky_light));
gl_Position = uni_mvp * attr_pos;
}