Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script type="x-shader/x-vertex" id="vs">
- attribute vec3 VertexPosition;
- attribute vec3 VertexNormal;
- attribute vec2 TextureCoord;
- uniform mat4 World;
- uniform mat4 View;
- uniform mat4 Projection;
- uniform vec3 AmbientLight;
- uniform float AmbientLightIntensity;
- uniform vec3 DiffuseLight;
- uniform float DiffuseLightIntensity;
- uniform vec3 DiffuseLightSource;
- uniform mat4 WorldTransposedInverse;
- varying vec2 TexCoord;
- varying vec4 Lighting;
- void main(void)
- {
- gl_Position = Projection * View * World * vec4(VertexPosition, 1.0);
- TexCoord = TextureCoord;
- vec4 Normal = normalize(WorldTransposedInverse * vec4(VertexNormal, 1.0));
- float DiffuseLightVertexIntensity = dot(Normal, normalize(vec4(DiffuseLightSource, 1.0)));
- Lighting = vec4(AmbientLight * AmbientLightIntensity + DiffuseLight * DiffuseLightIntensity * DiffuseLightVertexIntensity, 1.0);
- }
- </script>
- <script type="x-shader/x-fragment" id="fs">
- #ifdef GL_ES
- precision highp float;
- #endif
- varying vec2 TexCoord;
- varying vec4 Lighting;
- uniform sampler2D SamplerState;
- uniform bool EnableLighting;
- void main(void)
- {
- vec4 textureColor = vec4(texture2D(SamplerState, TexCoord).rgb, 1.0);
- if(EnableLighting)
- gl_FragColor = clamp(textureColor + Lighting, 0.0, 1.0);
- else
- gl_FragColor = textureColor;
- }
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement