aouellets of Academic Technical Team Code Base
5/8/2018 - 3:30 PM

yellow ray shader

yellow shader

<script name="yellowray" 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     = 0.2;

  void main() {
    vec4 color     = vec4(1.0, 1.0, 0, 1.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="yellowray" 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>