Advertisement
drockw2

Untitled

Nov 20th, 2014
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <script id= "vertexShader" type= "x-shader/x-vertex">
  2.        
  3.             attribute vec4 vertexPosition;
  4.             attribute vec3 vertexNormal;
  5.             uniform mat4 projectionMatrix;
  6.             uniform mat4 modelMatrix;
  7.             uniform vec3 lightDirection;
  8.             uniform vec3 lightColor;
  9.             uniform vec3 objectColor;
  10.             varying mediump vec3 fragmentColor;
  11.            
  12.             void main() {
  13.             vec4 p = modelMatrix * vertexPosition;
  14.             vec3 n = normalize(mat3(modelMatrix) * vertexNormal);
  15.             vec3 l = normalize(mat3(modelMatrix) * lightDirection);
  16.             vec3 v = normalize(vec3(-p));
  17.             vec3 h = normalize(v + l);
  18.             float d = max(dot(n, l) , 0.0);
  19.             float s = pow(max(dot(n, h), 0.0), 100.0);
  20.            
  21.             fragmentColor = lightColor * (objectColor * d + s);
  22.             gl_Position = projectionMatrix * modelMatrix * vertexPosition;
  23.  
  24.         }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement