• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#version 310 es
2
3layout(location = 0) in vec3 in_pos;
4layout(location = 1) in vec3 in_normal;
5
6layout(std140, push_constant) uniform param_block {
7	vec3 light_pos;
8	vec3 light_color;
9	mat4 model;
10	mat4 view_projection;
11} params;
12
13layout(location = 0) out vec3 color;
14
15void main()
16{
17	vec3 world_light = vec3(params.model * vec4(params.light_pos, 1.0));
18	vec3 world_pos = vec3(params.model * vec4(in_pos, 1.0));
19	vec3 world_normal = mat3(params.model) * in_normal;
20
21	vec3 light_dir = world_light - world_pos;
22	float brightness = dot(light_dir, world_normal) / length(light_dir) / length(world_normal);
23	brightness = abs(brightness);
24
25	gl_Position = params.view_projection * vec4(world_pos, 1.0);
26	color = params.light_color * brightness;
27}
28