metasurf

annotate examples/metaballs/sdr/frag.glsl @ 3:52664d3451ad

added volume rendering example
author John Tsiombikas <nuclear@member.fsf.org>
date Tue, 25 Oct 2011 13:30:03 +0300
parents
children
rev   line source
nuclear@0 1 varying vec3 vpos, ldir, norm;
nuclear@0 2
nuclear@0 3 void main()
nuclear@0 4 {
nuclear@0 5 vec3 n = normalize(norm);
nuclear@0 6 vec3 l = normalize(ldir);
nuclear@0 7 vec3 v = -normalize(vpos);
nuclear@0 8 vec3 h = normalize(v + l);
nuclear@0 9
nuclear@0 10 const vec3 kd = vec3(0.42, 0.6, 0.43);
nuclear@0 11
nuclear@0 12 float diff = abs(dot(n, l));
nuclear@0 13 float spec = pow(abs(dot(n, h)), 60.0);
nuclear@0 14
nuclear@0 15 vec3 dcol = kd * diff;
nuclear@0 16 vec3 scol = vec3(0.8, 0.8, 0.8) * spec;
nuclear@0 17
nuclear@0 18 gl_FragColor = vec4(dcol + scol, 1.0);
nuclear@0 19 }