2021-32-bit-holiday-jam/shaders/pumpkin-frag.glsl

31 lines
953 B
Plaintext
Raw Normal View History

#define lowp
#define mediump
#define highp
#line 0
uniform lowp sampler2D uni_texture;
uniform lowp vec3 uni_min_bright;
uniform lowp vec3 uni_min_albedo;
2020-03-07 03:36:05 +00:00
varying lowp vec3 vary_color;
varying lowp vec3 vary_normal;
varying mediump vec2 vary_uv;
2020-03-07 14:16:51 +00:00
varying lowp vec3 vary_object_space_light;
2020-03-07 15:05:59 +00:00
varying lowp vec3 vary_object_space_sky;
void main (void) {
lowp vec3 normal = normalize (vary_normal);
2021-12-22 02:32:52 +00:00
lowp vec3 albedo = max (uni_min_albedo, texture2D (uni_texture, vary_uv).rgb);
2020-03-07 15:05:59 +00:00
lowp vec3 sky_color = pow (vec3 (89.0, 125.0, 206.0) / vec3 (255.0), vec3 (2.0));
2020-03-07 03:36:05 +00:00
2020-03-07 14:16:51 +00:00
lowp float sun_factor = dot (normal, vary_object_space_light);
2020-03-07 15:05:59 +00:00
lowp float sky_factor = dot (normal, vary_object_space_sky);
2020-03-07 03:36:05 +00:00
lowp vec3 sun = max (sun_factor, 0.0) * (vec3 (1.0) - sky_color);
lowp vec3 sky = (sky_factor * 0.5 + 0.5) * sky_color;
2021-12-19 01:23:00 +00:00
lowp vec3 diffuse_color = max (uni_min_bright, (sun + sky));
2021-12-22 02:32:52 +00:00
gl_FragColor = vec4 (albedo * sqrt (vary_color * diffuse_color), 1.0);
}