4 layout(constant_id=auto) const bool use_normal_map = false;
6 #pragma MSP stage(vertex)
7 vec4 get_vertex_position()
12 vec3 get_vertex_normal()
17 vec4 transform_position(vec4 pos)
19 return eye_obj_matrix*pos;
22 vec3 transform_normal(vec3 nor)
24 return eye_obj_normal_matrix*nor;
27 void standard_transform()
29 out vec4 eye_vertex = transform_position(get_vertex_position());
30 gl_Position = projection_matrix*eye_vertex;
32 out vec3 eye_normal = transform_normal(get_vertex_normal());
33 vec3 eye_tangent = transform_normal(tangent);
34 vec3 eye_binormal = transform_normal(binormal);
35 out mat3 eye_tbn_matrix = mat3(eye_tangent, eye_binormal, eye_normal);
37 out vec3 eye_look_dir = normalize(eye_vertex.xyz);
38 out vec3 tbn_look_dir = eye_look_dir*eye_tbn_matrix;
40 out vec3 eye_light_dir = normalize(light_sources[0].position.xyz-eye_vertex.xyz*light_sources[0].position.w);
41 out vec3 tbn_light_dir = eye_light_dir*eye_tbn_matrix;
43 out vec3 eye_halfway_dir = normalize(eye_light_dir-eye_look_dir);
44 out vec3 tbn_halfway_dir = eye_halfway_dir*eye_tbn_matrix;
46 out vec3 tbn_zenith_dir = eye_zenith_dir*eye_tbn_matrix;
47 out float fog_coord = eye_vertex.z;
49 for(int i=0; i<max_clip_planes; ++i)
50 gl_ClipDistance[i] = dot(eye_vertex, clip_planes[i].equation);
52 shadow_transform(eye_vertex);
55 void custom_transform()
66 #pragma MSP stage(fragment)
67 vec3 get_fragment_normal()
70 return normalize(texture(normal_map, texcoord.xy).xyz*2.0-1.0);
72 return vec3(0.0, 0.0, 1.0);
75 vec4 get_environment_sample(vec3 direction)
77 return texture(environment_map, direction);
80 vec3 get_reflection(vec3 normal, vec3 look)
82 vec3 reflect_dir = reflect(look, normal);
84 reflect_dir = eye_tbn_matrix*reflect_dir;
86 return get_environment_sample(env_eye_matrix*reflect_dir).rgb;
89 vec3 apply_fog(vec3 color)
91 float fog_value = exp(fog_coord*fog_density);
92 return mix(fog_color, color, fog_value);