9 uniform sampler2D normal_map;
10 uniform samplerCube environment_map;
12 layout(constant_id=auto) const bool use_normal_map = false;
14 #pragma MSP stage(vertex)
15 virtual vec4 get_vertex_position()
20 virtual vec3 get_vertex_normal()
25 virtual vec4 transform_position(vec4 pos)
27 return eye_obj_matrix*pos;
30 virtual vec3 transform_normal(vec3 nor)
32 return eye_obj_normal_matrix*nor;
35 void standard_transform()
37 out vec4 eye_vertex = transform_position(get_vertex_position());
38 gl_Position = projection_matrix*eye_vertex;
40 out vec3 eye_normal = transform_normal(get_vertex_normal());
41 vec3 eye_tangent = transform_normal(tangent);
42 vec3 eye_binormal = transform_normal(binormal);
43 out mat3 eye_tbn_matrix = mat3(eye_tangent, eye_binormal, eye_normal);
45 out vec3 eye_look_dir = normalize(eye_vertex.xyz);
46 out vec3 tbn_look_dir = eye_look_dir*eye_tbn_matrix;
48 out vec3 eye_light_dir = normalize(light_sources[0].position.xyz-eye_vertex.xyz*light_sources[0].position.w);
49 out vec3 tbn_light_dir = eye_light_dir*eye_tbn_matrix;
51 out vec3 eye_halfway_dir = normalize(eye_light_dir-eye_look_dir);
52 out vec3 tbn_halfway_dir = eye_halfway_dir*eye_tbn_matrix;
54 out vec3 tbn_zenith_dir = eye_zenith_dir*eye_tbn_matrix;
55 out float fog_coord = eye_vertex.z;
57 for(int i=0; i<max_clip_planes; ++i)
58 gl_ClipDistance[i] = dot(eye_vertex, clip_planes[i].equation);
60 shadow_transform(eye_vertex);
63 virtual void custom_transform()
74 #pragma MSP stage(fragment)
75 virtual vec3 get_fragment_normal()
78 return normalize(texture(normal_map, texcoord.xy).xyz*2.0-1.0);
80 return vec3(0.0, 0.0, 1.0);
83 virtual vec4 get_environment_sample(vec3 direction)
85 return texture(environment_map, direction);
88 virtual vec3 get_reflection(vec3 normal, vec3 look)
90 vec3 reflect_dir = reflect(look, normal);
92 reflect_dir = eye_tbn_matrix*reflect_dir;
94 return get_environment_sample(env_eye_matrix*reflect_dir).rgb;
97 vec3 apply_fog(vec3 color)
99 float fog_value = exp(fog_coord*fog_density);
100 return mix(fog_color.rgb, color, fog_value);