1 uniform LightParameters
7 uniform mat4 view_proj;
8 layout(constant_id=auto) const bool use_light = true;
9 layout(constant_id=auto) const bool use_ambient = true;
11 #pragma MSP stage(vertex)
12 layout(location=0) in vec4 vertex;
13 layout(location=1) in vec3 normal;
16 out vec4 world_vertex = model*vertex;
17 out vec3 world_normal = mat3(model)*normal;
18 gl_Position = view_proj*world_vertex;
21 #pragma MSP stage(fragment)
22 layout(location=0) out vec4 frag_color;
23 vec4 get_light_position()
25 return light_position;
27 float get_light_intensity(vec3 dir)
29 return max(dot(dir, normalize(world_normal)), 0.0);
37 vec3 color = vec3(0.0);
40 vec4 light_pos = get_light_position();
41 vec3 dir = normalize(light_pos.xyz-world_vertex.xyz*light_pos.w);
42 color += get_light_intensity(dir);
45 color += get_ambient();
46 frag_color = vec4(color, 1.0);
49 // Compile mode: module
51 /* Expected output: vertex
52 layout(location=0) uniform mat4 model;
53 layout(location=4) uniform mat4 view_proj;
54 layout(location=0) in vec4 vertex;
55 layout(location=1) in vec3 normal;
56 layout(location=0) out vec4 world_vertex;
57 layout(location=1) out vec3 world_normal;
60 world_vertex = model*vertex;
61 world_normal = mat3(model[0].xyz, model[1].xyz, model[2].xyz)*normal;
62 gl_Position = view_proj*world_vertex;
66 /* Expected output: fragment
67 layout(binding=57) uniform LightParameters
72 layout(constant_id=669465692) const bool use_light = true;
73 layout(constant_id=1735871552) const bool use_ambient = true;
74 layout(location=0) out vec4 frag_color;
75 layout(location=1) in vec3 world_normal;
76 layout(location=0) in vec4 world_vertex;
79 vec3 color = vec3(0.0);
82 vec4 _return = light_position;
83 color += max(dot(normalize(_return.xyz-world_vertex.xyz*_return.w), normalize(world_normal)), 0.0);
87 frag_color = vec4(color, 1.0);