Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script id= "vertexShader" type= "x-shader/x-vertex">
- attribute vec4 vertexPosition;
- attribute vec3 vertexNormal;
- uniform mat4 projectionMatrix;
- uniform mat4 modelMatrix;
- uniform vec3 lightDirection;
- uniform vec3 lightColor;
- uniform vec3 objectColor;
- varying mediump vec3 fragmentColor;
- void main() {
- vec4 p = modelMatrix * vertexPosition;
- vec3 n = normalize(mat3(modelMatrix) * vertexNormal);
- vec3 l = normalize(mat3(modelMatrix) * lightDirection);
- vec3 v = normalize(vec3(-p));
- vec3 h = normalize(v + l);
- float d = max(dot(n, l) , 0.0);
- float s = pow(max(dot(n, h), 0.0), 100.0);
- fragmentColor = lightColor * (objectColor * d + s);
- gl_Position = projectionMatrix * modelMatrix * vertexPosition;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement