Fill
Stroke
Vertex shader:
attribute vec3 pos; attribute vec3 color; uniform mat4 model; uniform mat4 view; uniform mat4 proj; // Interpolated position and color for fragment shading. varying vec3 ipos; varying vec3 icolor; void main(void) { ipos = pos; icolor = color; gl_Position = proj * view * model * vec4(pos, 1.0); }
Fragment shader:
varying mediump vec3 ipos; varying mediump vec3 icolor; //uniform mediump vec3 color; void main(void) { mediump float dist = distance(ipos, vec3(0.5, 0.5, 0.5)); mediump float prox = clamp(1.0 - dist, 0.0, 1.0); gl_FragColor = vec4(icolor * prox, 1.0); }
Abstraction vertex shader:
attribute vec3 pos; attribute vec3 color; uniform mat4 model; uniform mat4 view; uniform mat4 proj; // Interpolated position and color for fragment shading. varying vec3 ipos; varying vec3 icolor; void main(void) { ipos = pos; icolor = color; gl_Position = proj * view * model * vec4(pos, 1.0); }
Abstraction fragment shader:
varying mediump vec3 ipos; varying mediump vec3 icolor; void main(void) { mediump float dist = distance(ipos, vec3(0.5, 0.5, 0.5)); mediump float prox = clamp(1.0 - dist, 0.0, 1.0); gl_FragColor = vec4(icolor * prox, 0.2); }