varying highp vec2 textureCoordinate; uniform sampler2D inputImageTexture; uniform float enables[5]; uniform float time; #define PI 3.1415926 vec4 addSpotlight( vec2 spotCoord, float direction, float maxLight, float minLight ,vec4 lightColor ) { vec4 color = texture2D(inputImageTexture,textureCoordinate); vec4 result = vec4(0.0); vec2 tanvec = textureCoordinate - spotCoord; float tanv = tanvec.x/tanvec.y; float vangle = atan(tanv); vangle = abs(vangle + direction); if(vangle < maxLight) { result = color*lightColor; if(vangle > minLight) { result = mix(result,vec4(0.0),smoothstep(minLight,maxLight,vangle)); } } return vec4(result.rgb,color.a); } float rand(in float x, in float y) { return fract(sin(dot(vec2(x, y), vec2(12.9898, 78.233))) * 43758.5453); } void main() { float fLightY = 1.08; vec4 colorA = addSpotlight(vec2(0.00455,fLightY), PI/4.5, 0.4, 0.1, vec4(1.0,0.0,0.0 ,1.0)); vec4 colorB = addSpotlight(vec2(0.24772,fLightY), PI/8.0, 0.4, 0.1, vec4(1.0,1.0,0.0 ,1.0)); vec4 colorC = addSpotlight(vec2(0.5 ,fLightY), 0.0, 0.4, 0.1, vec4(0.0,1.0,0.0 ,1.0)); vec4 colorD = addSpotlight(vec2(0.75228,fLightY), - PI/8.0, 0.4, 0.1, vec4(1.0,0.0,1.0 ,1.0)); vec4 colorE = addSpotlight(vec2(0.99545 ,fLightY), - PI/4.5, 0.4, 0.1, vec4(0.0,0.0,1.0 ,1.0)); gl_FragColor = vec4(vec4(colorA*enables[0] + colorB*enables[1] + colorC*enables[2] + colorD*enables[3] + colorE*enables[4]).rgb,colorA.a); }