source: trunk/tests/md2_test/obj.frag @ 189

Last change on this file since 189 was 189, checked in by epyon, 12 years ago
  • formats - full md2 implementation, including re-indexing and frame animation
  • tests/md2_test - with Mancubi For Added Fun (tm)
File size: 1.1 KB
Line 
1#version 120
2
3uniform sampler2D diffuse;
4uniform vec4 light_diffuse;
5uniform vec4 light_specular;
6
7varying vec2 v_texcoord;
8varying vec3 v_normal;
9varying vec3 v_light_vector;
10varying vec3 v_view_vector;
11 
12void main(void) {
13        vec3 nnormal         = normalize( v_normal );
14        vec3 nlight_vector   = normalize( v_light_vector );
15        vec3 nview_vector    = normalize( v_view_vector );
16        vec3 nreflect_vector = reflect( -nlight_vector, nnormal );
17
18        float specular_value = clamp( dot( nreflect_vector, nview_vector ), 0.0, 1.0 );
19        specular_value       = pow( specular_value, 6.0 );
20        float diffuse_value  = max( dot( nlight_vector, nnormal ), 0.0 );
21
22        vec3 diff_texel      = vec3( texture2D( diffuse, v_texcoord ) );       
23       
24        float final_specular = specular_value * 0.2;
25        float final_diffuse  = diffuse_value * 0.5;
26        float final_ambient  = 0.3;
27
28        vec3 ambient_color   = final_ambient * diff_texel;
29        vec3 diffuse_color   = light_diffuse.xyz * final_diffuse * diff_texel;
30        vec3 specular_color  = light_specular.xyz * final_specular;
31
32        gl_FragColor = vec4( ambient_color + diffuse_color + specular_color, 1.0 );
33//      gl_FragColor = vec4( diff_texel, 1.0 );
34}
Note: See TracBrowser for help on using the repository browser.