PageRenderTime 82ms CodeModel.GetById 40ms app.highlight 1ms RepoModel.GetById 39ms app.codeStats 1ms

/Resources/shaders/pointLightingPixel.vsh

http://github.com/tartiflop/ojgl
Vertex Shader File | 45 lines | 32 code | 13 blank | 0 comment | 1 complexity | fb1da95f34d75120c005d17c5a3f4e5f MD5 | raw file
 1#define MAX_LIGHTS 8
 2
 3struct Material {
 4	vec4 ambientColor;
 5	vec4 diffuseColor;
 6	vec4 specularColor;
 7	float shininess;
 8};
 9
10
11attribute vec4 a_vertex;
12attribute vec3 a_normal;
13attribute vec2 a_texCoord;
14
15uniform mat4 u_mvpMatrix;
16uniform mat4 u_mvMatrix;
17uniform mat3 u_normalMatrix;
18
19uniform vec4 u_sceneAmbientColor;
20
21uniform Material u_material;
22uniform bool u_lightingEnabled;
23
24varying vec4 v_ambient;
25varying vec2 v_texCoord;
26
27varying vec4 v_ecPosition3;
28varying vec3 v_normal;
29varying vec3 v_eye;
30
31
32void main(void) {
33	v_ecPosition3 = u_mvMatrix * a_vertex;
34	v_eye = -vec3(normalize(v_ecPosition3));
35
36	v_normal = u_normalMatrix * a_normal;
37	v_normal = normalize(v_normal);
38	
39	if (u_lightingEnabled) {
40		v_ambient = u_sceneAmbientColor * u_material.ambientColor;
41	}
42	
43	gl_Position = u_mvpMatrix * a_vertex;
44	v_texCoord = a_texCoord;
45}