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

28 lines
861 B
Plaintext
Raw Normal View History

#define lowp
#define mediump
#define highp
#line 0
uniform lowp sampler2D uni_texture;
uniform lowp vec3 uni_albedo;
uniform lowp vec3 uni_object_space_light;
uniform lowp vec3 uni_min_bright;
uniform lowp vec3 uni_min_albedo;
//varying lowp vec4 vary_color;
varying lowp vec3 vary_normal;
varying mediump vec2 vary_uv;
void main (void) {
lowp vec3 normal = normalize (vary_normal);
lowp vec3 albedo = uni_albedo * max (uni_min_albedo, texture2D (uni_texture, vary_uv).rgb);
//lowp vec3 albedo = vec3 (vary_uv, 0.0);
lowp float diffuse_factor = dot (normal, uni_object_space_light);
lowp vec3 sun = max (diffuse_factor, 0.0) * vec3 (0.95, 0.9, 0.85);
lowp vec3 sky = (diffuse_factor * 0.45 + 0.55) * vec3 (0.05, 0.1, 0.15);
lowp vec3 diffuse_color = albedo * max (uni_min_bright, (sun + sky));
gl_FragColor = vec4 (sqrt (diffuse_color), 1.0);
}