Mindustry/core/assets/shaders/sun.frag

34 lines
711 B
GLSL
Raw Normal View History

2020-02-29 01:18:06 +07:00
#ifdef GL_ES
precision mediump float;
precision lowp int;
#define INTEGER lowp int
#else
#define INTEGER int
2020-02-29 01:18:06 +07:00
#endif
2020-03-30 05:34:00 +07:00
//#define GRADIENTS
#define step 0.5
2020-02-29 01:18:06 +07:00
const int MAX_COLORS = 10;
uniform INTEGER u_colornum;
2020-02-29 01:18:06 +07:00
uniform vec4 u_colors[MAX_COLORS];
varying float v_height;
void main() {
2020-03-30 05:34:00 +07:00
#ifdef GRADIENTS
int from = int(v_height * float(u_colornum));
int to = int(clamp(float(int(v_height * float(u_colornum) + 1.0)), 0.0, float(u_colornum)-1.0));
float alpha = fract(v_height * float(u_colornum));
alpha = floor(alpha / step) * step;
gl_FragColor = vec4(mix(u_colors[from], u_colors[to], alpha));
#else
gl_FragColor = u_colors[int(v_height * float(u_colornum))];
#endif
2020-02-29 01:18:06 +07:00
}