added license to scripts and shaders
[dd2d.git] / data / shaders / srlight_ambient.frag
blob1b31ab08c89f867b7b0ae12798aaf99f47f54198
1 /* DooM2D: Midnight on the Firing Line
2  * coded by Ketmar // Invisible Vector <ketmar@ketmar.no-ip.org>
3  * Understanding is not required. Only obedience.
4  *
5  * This program is free software: you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation, either version 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 #version 130
20 #define PI 3.1415926
22 uniform sampler2D texBg; // background
23 uniform sampler2D texOcc; // occluders
24 uniform vec2 mapPixSize;
25 uniform vec4 lightColor;
26 //uniform vec2 lightPos;
29 //gl_FragCoord: [0..lightTexSize)
31 #define lit (1.0)
34 void main (void) {
35   vec2 btxy = gl_FragCoord.xy;
36   //btxy.y = mapPixSize.y-btxy.y-1.0;
37   //vec2 ocxy = vec2(btxy.x, mapPixSize.y-btxy.y)/mapPixSize;
38   vec4 color;
40   // has some light here
41   vec4 bcolor = texture2D(texBg, btxy/mapPixSize);
42   if (lightColor.r+lightColor.g+lightColor.b == 0.0) {
43     color = bcolor*vec4(vec3(lightColor.a), lit);
44   } else {
45     color = lightColor*lit;
46     color += bcolor*lit;
47     color.a = lit/2.0;
48   }
50   gl_FragColor = color;