dbf-udg

view sdr/phong.p.glsl @ 12:1abbed71e9c9

cleanup, copyright statements and notices, readme files
author John Tsiombikas <nuclear@member.fsf.org>
date Wed, 20 Feb 2013 05:45:27 +0200
parents f0a47f46ee45
children
line source
1 /*
2 Printblobs - typography display hack
3 Copyright (C) 2013 John Tsiombikas <nuclear@member.fsf.org>
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.
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.
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 varying vec3 normal, vpos;
20 void main()
21 {
22 vec3 n = normalize(normal);
23 vec3 v = -normalize(vpos);
25 vec3 color = vec3(0.0, 0.0, 0.0);
27 for(int i=0; i<2; i++) {
28 vec3 l = normalize(gl_LightSource[i].position.xyz);
29 vec3 h = normalize(v + l);
31 float ndotl = max(dot(n, l), 0.0);
32 float ndoth = max(dot(n, h), 0.0);
33 float spec = pow(ndoth, gl_FrontMaterial.shininess);
35 vec3 dcol = gl_FrontMaterial.diffuse.xyz * gl_LightSource[i].diffuse.xyz;
36 vec3 scol = gl_FrontMaterial.specular.xyz * gl_LightSource[i].diffuse.xyz;
38 color += dcol * ndotl + scol * spec;
39 }
41 vec3 acol = gl_FrontMaterial.ambient.xyz * gl_LightModel.ambient.xyz;
43 gl_FragColor.xyz = acol + color;
44 gl_FragColor.w = 1.0;
45 }