rev |
line source |
nuclear@12
|
1 /*
|
nuclear@12
|
2 Printblobs - typography display hack
|
nuclear@12
|
3 Copyright (C) 2013 John Tsiombikas <nuclear@member.fsf.org>
|
nuclear@12
|
4
|
nuclear@12
|
5 This program is free software: you can redistribute it and/or modify
|
nuclear@12
|
6 it under the terms of the GNU General Public License as published by
|
nuclear@12
|
7 the Free Software Foundation, either version 3 of the License, or
|
nuclear@12
|
8 (at your option) any later version.
|
nuclear@12
|
9
|
nuclear@12
|
10 This program is distributed in the hope that it will be useful,
|
nuclear@12
|
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
nuclear@12
|
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
nuclear@12
|
13 GNU General Public License for more details.
|
nuclear@12
|
14
|
nuclear@12
|
15 You should have received a copy of the GNU General Public License
|
nuclear@12
|
16 along with this program. If not, see <http://www.gnu.org/licenses/>.
|
nuclear@12
|
17 */
|
nuclear@7
|
18 varying vec3 normal, vpos;
|
nuclear@7
|
19
|
nuclear@7
|
20 void main()
|
nuclear@7
|
21 {
|
nuclear@7
|
22 vec3 n = normalize(normal);
|
nuclear@7
|
23 vec3 v = -normalize(vpos);
|
nuclear@7
|
24
|
nuclear@8
|
25 vec3 color = vec3(0.0, 0.0, 0.0);
|
nuclear@7
|
26
|
nuclear@8
|
27 for(int i=0; i<2; i++) {
|
nuclear@8
|
28 vec3 l = normalize(gl_LightSource[i].position.xyz);
|
nuclear@8
|
29 vec3 h = normalize(v + l);
|
nuclear@8
|
30
|
nuclear@8
|
31 float ndotl = max(dot(n, l), 0.0);
|
nuclear@8
|
32 float ndoth = max(dot(n, h), 0.0);
|
nuclear@8
|
33 float spec = pow(ndoth, gl_FrontMaterial.shininess);
|
nuclear@8
|
34
|
nuclear@8
|
35 vec3 dcol = gl_FrontMaterial.diffuse.xyz * gl_LightSource[i].diffuse.xyz;
|
nuclear@8
|
36 vec3 scol = gl_FrontMaterial.specular.xyz * gl_LightSource[i].diffuse.xyz;
|
nuclear@8
|
37
|
nuclear@8
|
38 color += dcol * ndotl + scol * spec;
|
nuclear@8
|
39 }
|
nuclear@7
|
40
|
nuclear@7
|
41 vec3 acol = gl_FrontMaterial.ambient.xyz * gl_LightModel.ambient.xyz;
|
nuclear@7
|
42
|
nuclear@8
|
43 gl_FragColor.xyz = acol + color;
|
nuclear@7
|
44 gl_FragColor.w = 1.0;
|
nuclear@7
|
45 }
|