2 uniform mat4 view_projection;
3 uniform vec3 light_dir;
4 uniform sampler2D normalmap;
6 #pragma MSP stage(vertex)
7 layout(location=0) in vec3 position;
8 layout(location=1) in vec3 normal;
9 layout(location=2) in vec3 tangent;
10 layout(location=3) in vec3 binormal;
11 layout(location=4) in vec2 texcoord;
14 mat3 normal_matrix = mat3(model);
15 mat3 tbn_matrix = mat3(normal_matrix*tangent, normal_matrix*binormal, normal_matrix*normal);
16 out vec3 tbn_light_dir = tbn_matrix*light_dir;
17 gl_Position = view_projection*model*vec4(position, 1);
21 #pragma MSP stage(fragment)
22 layout(location=0) out vec4 frag_color;
25 vec3 normal = vec3(texture(normalmap, texcoord))*2.0-1.0;
26 frag_color = vec4(vec3(dot(normal, normalize(tbn_light_dir))), 1);
29 /* Expected output: vertex
30 layout(location=0) uniform mat4 model;
31 layout(location=4) uniform mat4 view_projection;
32 layout(location=8) uniform vec3 light_dir;
33 layout(location=0) in vec3 position;
34 layout(location=1) in vec3 normal;
35 layout(location=2) in vec3 tangent;
36 layout(location=3) in vec3 binormal;
37 layout(location=4) in vec2 texcoord;
38 layout(location=0) out vec3 tbn_light_dir;
39 layout(location=1) out vec2 _vs_out_texcoord;
42 mat3 normal_matrix = mat3(model[0].xyz, model[1].xyz, model[2].xyz);
43 tbn_light_dir = mat3(normal_matrix*tangent, normal_matrix*binormal, normal_matrix*normal)*light_dir;
44 gl_Position = view_projection*model*vec4(position, float(1));
45 _vs_out_texcoord = texcoord;
49 /* Expected output: fragment
50 layout(location=9, binding=25) uniform sampler2D normalmap;
51 layout(location=0) out vec4 frag_color;
52 layout(location=1) in vec2 _vs_out_texcoord;
53 layout(location=0) in vec3 tbn_light_dir;
56 frag_color = vec4(vec3(dot(vec3(texture(normalmap, _vs_out_texcoord).xyz)*2.0-1.0, normalize(tbn_light_dir))), float(1));