source: trunk/tests/render_test/box.frag @ 528

Last change on this file since 528 was 238, checked in by epyon, 11 years ago
  • mesh data interface and usage
  • new wavefront importer (old pending removal)
  • updates to test projects
File size: 791 bytes
Line 
1#version 120
2varying vec3 f_coord;
3varying vec3 f_normal;
4varying vec3 f_material;
5varying float f_diffuse_value;
6uniform sampler2D nv_t_diffuse;
7uniform vec3 light;
8 
9void main(void) {
10        float w = f_material.x;
11        bool secondary = f_normal.y < 0.1;
12        float remmod  = floor( w / 16 + 0.5 );
13        float modulus = w - remmod * 16;
14        float dist = distance( light, f_coord );
15        float dmod = clamp(5.0 - dist, 0.0, 1.0) * f_diffuse_value;
16
17        if (secondary)
18                gl_FragColor = texture2D(nv_t_diffuse, vec2((fract(f_coord.z - f_coord.x) + modulus ), ( fract(-f_coord.y) + remmod) )  / 16.0);
19        else
20                gl_FragColor = texture2D(nv_t_diffuse, vec2((fract(f_coord.z) + modulus ), ( fract(f_coord.x) + remmod) )  / 16.0);
21        gl_FragColor = vec4( gl_FragColor.xyz * (f_diffuse_value + 0.4), 1.0 );
22}
Note: See TracBrowser for help on using the repository browser.