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);
31 /* Expected output: vertex
32 layout(location=0) uniform mat4 model;
33 layout(location=4) uniform mat4 view_projection;
34 layout(location=8) uniform vec3 light_dir;
35 layout(location=0) in vec3 position;
36 layout(location=1) in vec3 normal;
37 layout(location=2) in vec3 tangent;
38 layout(location=3) in vec3 binormal;
39 layout(location=4) in vec2 texcoord;
40 layout(location=0) out vec3 tbn_light_dir;
41 layout(location=1) out vec2 _vs_out_texcoord;
44 mat3 normal_matrix = mat3(model[0].xyz, model[1].xyz, model[2].xyz);
45 tbn_light_dir = mat3(normal_matrix*tangent, normal_matrix*binormal, normal_matrix*normal)*light_dir;
46 gl_Position = view_projection*model*vec4(position, 1.0);
47 _vs_out_texcoord = texcoord;
48 gl_Position.z = gl_Position.z*2.0-gl_Position.w;
52 /* Expected output: fragment
53 layout(location=9, binding=25) uniform sampler2D normalmap;
54 layout(location=0) out vec4 frag_color;
55 layout(location=1) in vec2 _vs_out_texcoord;
56 layout(location=0) in vec3 tbn_light_dir;
59 frag_color = vec4(vec3(dot(vec3(texture(normalmap, _vs_out_texcoord).xyz)*2.0-1.0, normalize(tbn_light_dir))), 1.0);