tesspot
diff sdr/bezier.p.glsl @ 2:178a9e3c3c8c
isolines
author | John Tsiombikas <nuclear@member.fsf.org> |
---|---|
date | Mon, 03 Dec 2012 07:30:39 +0200 |
parents | 72b7f9f2eead |
children |
line diff
1.1 --- a/sdr/bezier.p.glsl Sun Dec 02 17:16:32 2012 +0200 1.2 +++ b/sdr/bezier.p.glsl Mon Dec 03 07:30:39 2012 +0200 1.3 @@ -1,7 +1,11 @@ 1.4 #version 410 compatibility 1.5 1.6 +uniform int tess_level; 1.7 + 1.8 in vec3 normal; 1.9 in vec3 vpos; 1.10 +in vec2 uv; 1.11 + 1.12 1.13 void main() 1.14 { 1.15 @@ -15,12 +19,21 @@ 1.16 float ndotl = max(dot(n, l), 0.0); 1.17 float ndoth = max(dot(n, h), 0.0); 1.18 1.19 + vec3 ka = gl_FrontMaterial.ambient.xyz; 1.20 vec3 kd = gl_FrontMaterial.diffuse.xyz; 1.21 vec3 ks = gl_FrontMaterial.specular.xyz; 1.22 float shin = gl_FrontMaterial.shininess; 1.23 1.24 vec3 diffuse = kd * ndotl * gl_LightSource[0].diffuse.xyz; 1.25 vec3 specular = ks * pow(ndoth, shin) * gl_LightSource[0].specular.xyz; 1.26 + vec3 ambient = ka * gl_LightModel.ambient.xyz; 1.27 + vec3 color = ambient + diffuse + specular; 1.28 1.29 - gl_FragColor = vec4(diffuse + specular, gl_FrontMaterial.diffuse.w); 1.30 + vec2 tess_uv = mod(uv * float(tess_level), 1.0); 1.31 + 1.32 +#define STEPSZ 0.1 1.33 + float wire = smoothstep(0.0, STEPSZ, tess_uv.x) * smoothstep(1.0, 1.0 - STEPSZ, tess_uv.x); 1.34 + wire *= smoothstep(0.0, STEPSZ, tess_uv.y) * smoothstep(1.0, 1.0 - STEPSZ, tess_uv.y); 1.35 + 1.36 + gl_FragColor = vec4(mix(vec3(0.0, 0.0, 0.0), color, wire), gl_FrontMaterial.diffuse.w); 1.37 }