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

31 lines
953 B
GLSL

#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;
varying lowp vec3 vary_color;
varying lowp vec3 vary_normal;
varying mediump vec2 vary_uv;
varying lowp vec3 vary_object_space_light;
varying lowp vec3 vary_object_space_sky;
void main (void) {
lowp vec3 normal = normalize (vary_normal);
lowp vec3 albedo = vary_color * max (uni_min_albedo, texture2D (uni_texture, vary_uv).rgb);
lowp vec3 sky_color = pow (vec3 (89.0, 125.0, 206.0) / vec3 (255.0), vec3 (2.0));
lowp float sun_factor = dot (normal, vary_object_space_light);
lowp float sky_factor = dot (normal, vary_object_space_sky);
lowp vec3 sun = max (sun_factor, 0.0) * (vec3 (1.0) - sky_color);
lowp vec3 sky = (sky_factor * 0.5 + 0.5) * sky_color;
lowp vec3 diffuse_color = albedo * max (uni_min_bright, (sun + sky));
gl_FragColor = vec4 (sqrt (diffuse_color), 1.0);
}