TestPage

From WebGL Public Wiki
Jump to navigation Jump to search

Testing the code formatting engine:

<script id="vshader" type="x-shader/x-vertex">
  uniform mat4 pMatrix;
  uniform mat4 mvMatrix;
  uniform vec3 lightDir;

  attribute vec3 vNormal;
  attribute vec4 vColor;
  attribute vec4 vPosition;
        
  varying float v_Dot;
        
  void main()
  {
    gl_FrontColor = vColor;
    vec4 transNormal = mvMatrix * vec4(vNormal,1);
    v_Dot = max(dot(transNormal.xyz, lightDir), 0.0);
    gl_Position = pMatrix * mvMatrix * vPosition;
  }
</script>

<script id="fshader" type="x-shader/x-fragment">
  varying float v_Dot;
        
  void main()
  {
    gl_FragColor = vec4(gl_Color.xyz * v_Dot, gl_Color.a);
  }
</script>