dbf-udg
diff sdr/phong.p.glsl @ 8:f0a47f46ee45
lalala
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 18 Feb 2013 06:53:44 +0200 |
parents | 603656331514 |
children | 1abbed71e9c9 |
line diff
1.1 --- a/sdr/phong.p.glsl Mon Feb 18 05:44:17 2013 +0200 1.2 +++ b/sdr/phong.p.glsl Mon Feb 18 06:53:44 2013 +0200 1.3 @@ -4,18 +4,25 @@ 1.4 { 1.5 vec3 n = normalize(normal); 1.6 vec3 v = -normalize(vpos); 1.7 - vec3 l = normalize(gl_LightSource[0].position.xyz); 1.8 1.9 - vec3 h = normalize(v + l); 1.10 + vec3 color = vec3(0.0, 0.0, 0.0); 1.11 1.12 - float ndotl = max(dot(n, l), 0.0); 1.13 - float ndoth = max(dot(n, h), 0.0); 1.14 - float spec = pow(ndoth, gl_FrontMaterial.shininess); 1.15 + for(int i=0; i<2; i++) { 1.16 + vec3 l = normalize(gl_LightSource[i].position.xyz); 1.17 + vec3 h = normalize(v + l); 1.18 + 1.19 + float ndotl = max(dot(n, l), 0.0); 1.20 + float ndoth = max(dot(n, h), 0.0); 1.21 + float spec = pow(ndoth, gl_FrontMaterial.shininess); 1.22 + 1.23 + vec3 dcol = gl_FrontMaterial.diffuse.xyz * gl_LightSource[i].diffuse.xyz; 1.24 + vec3 scol = gl_FrontMaterial.specular.xyz * gl_LightSource[i].diffuse.xyz; 1.25 + 1.26 + color += dcol * ndotl + scol * spec; 1.27 + } 1.28 1.29 vec3 acol = gl_FrontMaterial.ambient.xyz * gl_LightModel.ambient.xyz; 1.30 - vec3 dcol = gl_FrontMaterial.diffuse.xyz * gl_LightSource[0].diffuse.xyz; 1.31 - vec3 scol = gl_FrontMaterial.specular.xyz * gl_LightSource[0].specular.xyz; 1.32 1.33 - gl_FragColor.xyz = acol + dcol * ndotl + scol * spec; 1.34 + gl_FragColor.xyz = acol + color; 1.35 gl_FragColor.w = 1.0; 1.36 }