+++ /dev/null
-// Deprecated; use phong.glsl instead.
-import msp_interface;
-
-const bool use_vertex_color = false;
-
-const bool use_lighting = false;
-const bool use_specular = false;
-const bool use_sky = false;
-const bool use_fog = false;
-
-const bool use_diffuse_map = false;
-const bool use_normal_map = false;
-
-const bool use_shadow_map = false;
-
-const bool use_environment_map = false;
-
-#pragma MSP stage(vertex)
-vec4 get_vertex_position()
-{
- return vertex;
-}
-
-vec3 get_vertex_normal()
-{
- return normal;
-}
-
-void singlepass_transform_and_lighting()
-{
- out vec4 eye_vertex = eye_obj_matrix*get_vertex_position();
- gl_Position = projection_matrix*eye_vertex;
-
- out vec3 eye_normal = eye_obj_normal_matrix*get_vertex_normal();
- vec3 eye_tangent = eye_obj_normal_matrix*tangent;
- vec3 eye_binormal = eye_obj_normal_matrix*binormal;
- out mat3 eye_tbn_matrix = mat3(eye_tangent, eye_binormal, eye_normal);
-
- out vec3 incident_dir = normalize(eye_vertex.xyz);
- if(use_normal_map)
- incident_dir = incident_dir*eye_tbn_matrix;
-
- vec3 ldir = normalize(light_sources[0].position.xyz-eye_vertex.xyz*light_sources[0].position.w);
- if(use_normal_map)
- ldir = ldir*eye_tbn_matrix;
- out vec3 light_dir = ldir;
-
- out vec3 tbn_zenith_dir = eye_zenith_dir*eye_tbn_matrix;
- out vec3 shadow_coord = (shd_eye_matrix*eye_vertex).xyz;
- out float fog_coord = eye_vertex.z;
-
- for(int i=0; i<max_clip_planes; ++i)
- gl_ClipDistance[i] = dot(eye_vertex, clip_planes[i].equation);
-}
-
-void main()
-{
- singlepass_transform_and_lighting();
- passthrough;
-}
-
-#pragma MSP stage(fragment)
-vec4 get_diffuse_sample()
-{
- return texture(diffuse_map, texcoord.xy);
-}
-
-vec3 get_normal_sample()
-{
- return texture(normal_map, texcoord.xy).xyz*2.0-1.0;
-}
-
-vec4 get_environment_sample(vec3 direction)
-{
- return texture(environment_map, direction);
-}
-
-vec3 normal;
-vec4 diffuse_sample;
-
-vec3 singlepass_lighting()
-{
- float shadow_sample = texture(shadow_map, shadow_coord);
- float shadow_intensity = mix(1.0, shadow_sample, shadow_darkness);
-
- vec3 ambient_light = ambient_color.rgb;
- if(use_sky)
- {
- vec3 zenith_dir;
- if(use_normal_map)
- zenith_dir = tbn_zenith_dir;
- else
- zenith_dir = eye_zenith_dir;
- float skylight_intensity = dot(normal, zenith_dir)*0.5+0.5;
- ambient_light += skylight_intensity*sky_color.rgb;
- }
-
- vec3 n_light_dir = normalize(light_dir);
- float diffuse_intensity = max(dot(normal, n_light_dir), 0.0);
- if(use_shadow_map)
- diffuse_intensity *= shadow_intensity;
- vec3 diffuse_light = diffuse_intensity*light_sources[0].diffuse.rgb;
-
- vec3 half_vec = normalize(light_dir-incident_dir);
- float specular_intensity = pow(max(dot(half_vec, normal), 0.0), basic_material.shininess);
- if(use_shadow_map)
- specular_intensity *= shadow_intensity;
- vec3 specular_light = specular_intensity*light_sources[0].specular.rgb;
-
- vec3 result = basic_material.diffuse.rgb*ambient_light+basic_material.diffuse.rgb*diffuse_light;
- if(use_diffuse_map)
- result *= diffuse_sample.rgb;
- if(use_specular)
- result += basic_material.specular.rgb*specular_light;
-
- return result;
-}
-
-float singlepass_transparency()
-{
- float alpha = basic_material.diffuse.a;
- if(use_diffuse_map)
- alpha *= diffuse_sample.a;
- return alpha;
-}
-
-vec3 singlepass_reflection()
-{
- vec3 reflect_dir = reflect(incident_dir, normal);
- if(use_normal_map)
- reflect_dir = eye_tbn_matrix*reflect_dir;
-
- return get_environment_sample(env_eye_matrix*reflect_dir).rgb;
-}
-
-vec4 singlepass_color()
-{
- vec4 result = vec4(1.0);
- if(use_vertex_color)
- result *= color;
- if(use_diffuse_map)
- result *= get_diffuse_sample();
- return result;
-}
-
-void main()
-{
- if(use_normal_map)
- normal = get_normal_sample();
- else
- normal = normalize(eye_normal);
-
- diffuse_sample = get_diffuse_sample();
-
- vec4 final_color;
- if(use_lighting)
- final_color = vec4(singlepass_lighting(), singlepass_transparency());
- else
- final_color = singlepass_color();
-
- if(use_environment_map)
- final_color += vec4(singlepass_reflection(), 0.0);
- if(use_fog)
- {
- float fog_value = exp(fog_coord*fog_density);
- final_color = vec4(mix(fog_color.rgb, final_color.rgb, fog_value), final_color.a);
- }
-
- frag_color = final_color;
-}