aouellets of Academic Technical Team Code Base
9/5/2018 - 2:05 PM

Black Shader

<script name="black" type="x-shader/x-fragment">
  precision mediump float;

  varying vec3 I;
  varying vec3 N;

  const float edgeFalloff = 1.0;
  const float intensity   = 1.0;
  const float ambient     = 1.0;

  void main() {
    vec4 color     = vec4(0, 0, 0, 0);
    float opacity  = abs(dot(normalize(-N), normalize(-I)));
    opacity        = ambient + intensity*(1.0-pow(opacity,edgeFalloff));
    gl_FragColor   = opacity * color;
    gl_FragColor.a = opacity;
  }
</script>

<script name="black" type="x-shader/x-vertex">
  attribute vec3 vertexPosition;
  attribute vec3 vertexNormal;

  varying vec3 I;
  varying vec3 N;

  uniform mat4 modelViewProjectionMatrix;
  uniform mat4 modelViewMatrix;
  uniform mat4 normalMatrix;

  void main() {
    vec4 vp4    = vec4(vertexPosition,1.0);
    vec4 P      = modelViewMatrix * vp4;
    I           = P.xyz - vec3(0);
    N           = vec3(normalMatrix * vec4(vertexNormal,0.0));
    gl_Position = modelViewProjectionMatrix * vp4;
  }
</script>