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

22 lines
536 B
Plaintext
Raw Permalink Normal View History

2020-12-25 17:16:14 +00:00
#define lowp
#define mediump
#define highp
#line 0
attribute highp vec4 attr_pos;
2020-12-25 17:58:56 +00:00
attribute lowp vec3 attr_normal;
2020-12-25 17:16:14 +00:00
attribute lowp vec3 attr_color;
uniform highp mat4 uni_mvp;
varying lowp vec3 vary_color;
void main (void) {
2020-12-25 17:58:56 +00:00
vec3 sun_dir = normalize (vec3 (1.0, 1.0, 4.0));
2020-12-25 18:38:51 +00:00
vec3 sun_light = vec3 (1.0, 0.75, 0.5) * sqrt (max (0.0, dot (attr_normal, sun_dir)));
2020-12-25 17:58:56 +00:00
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));
2020-12-25 17:16:14 +00:00
gl_Position = uni_mvp * attr_pos;
}