Pixel-Composer/shaders/sh_2d_light/sh_2d_light.fsh

30 lines
582 B
Plaintext
Raw Normal View History

2022-01-13 05:24:03 +01:00
//
// Simple passthrough fragment shader
//
2022-11-21 06:38:44 +01:00
//varying vec2 v_vTexcoord;
2022-01-13 05:24:03 +01:00
varying vec4 v_vColour;
uniform vec3 color;
uniform float intensity;
uniform float band;
uniform float atten;
void main() {
2022-12-27 04:00:50 +01:00
float bright = (v_vColour.r + v_vColour.b + v_vColour.g) / 3.;
bright = clamp(bright, 0., 1.);
2022-11-21 06:38:44 +01:00
2022-01-13 05:24:03 +01:00
if(atten == 0.)
2022-11-21 06:38:44 +01:00
bright = bright * bright;
2022-01-13 05:24:03 +01:00
else if(atten == 1.)
2022-11-21 06:38:44 +01:00
bright = 1. - (bright - 1.) * (bright - 1.);
else if(atten == 2.)
bright = bright;
bright *= intensity;
2022-01-13 05:24:03 +01:00
2022-11-21 06:38:44 +01:00
if(band > 0.)
2022-01-13 05:24:03 +01:00
bright = ceil(bright * band) / band;
2022-12-27 04:00:50 +01:00
gl_FragColor = vec4(color, 1.) * bright;
2022-01-13 05:24:03 +01:00
}