Home | History | Annotate | Download | only in smoke
      1 #version 310 es
      2 
      3 layout(location = 0) in vec3 in_pos;
      4 layout(location = 1) in vec3 in_normal;
      5 
      6 layout(std140, set = 0, binding = 0) readonly buffer param_block {
      7 	vec3 light_pos;
      8 	vec3 light_color;
      9 	mat4 model;
     10 	mat4 view_projection;
     11 } params;
     12 
     13 out vec3 color;
     14 
     15 void 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