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 vec3 shadow_coord = (shd_eye_matrix*eye_vertex).xyz;
48 out float fog_coord = eye_vertex.z;
50 for(int i=0; i<max_clip_planes; ++i)
51 gl_ClipDistance[i] = dot(eye_vertex, clip_planes[i].equation);
53 shadow_transform(eye_vertex);
56 void custom_transform()
67 #pragma MSP stage(fragment)
68 vec3 get_fragment_normal()
71 return normalize(texture(normal_map, texcoord.xy).xyz*2.0-1.0);
73 return vec3(0.0, 0.0, 1.0);
76 vec4 get_environment_sample(vec3 direction)
78 return texture(environment_map, direction);
81 vec3 get_reflection(vec3 normal, vec3 look)
83 vec3 reflect_dir = reflect(look, normal);
85 reflect_dir = eye_tbn_matrix*reflect_dir;
87 return get_environment_sample(env_eye_matrix*reflect_dir).rgb;
90 vec3 apply_fog(vec3 color)
92 float fog_value = exp(fog_coord*fog_density);
93 return mix(fog_color, color, fog_value);