Pixel-Composer/shaders/sh_2d_light/sh_2d_light.fsh

24 lines
567 B
Text
Raw Normal View History

varying vec2 v_vTexcoord;
2022-01-13 05:24:03 +01:00
varying vec4 v_vColour;
2024-10-01 10:15:07 +02:00
uniform vec4 color;
2022-01-13 05:24:03 +01:00
uniform float intensity;
uniform float band;
uniform int atten;
uniform float exponent;
2022-01-13 05:24:03 +01:00
void main() {
vec4 samp = texture2D( gm_BaseTexture, v_vTexcoord);
float bright = (samp.r + samp.b + samp.g) / 3.;
2022-11-21 06:38:44 +01:00
if(atten == 0) bright = pow(bright, exponent);
else if(atten == 1) bright = 1. - pow(1. - bright, exponent);
else if(atten == 2) bright = bright;
2022-11-21 06:38:44 +01:00
bright *= intensity;
2022-01-13 05:24:03 +01:00
if(band > 0.) bright = ceil(bright * band) / band;
2022-01-13 05:24:03 +01:00
gl_FragColor = vec4(color.rgb * bright, 1.);
2022-01-13 05:24:03 +01:00
}