source: trunk/neercs/video/test.lolfx @ 1447

Last change on this file since 1447 was 1447, checked in by sam, 8 years ago

neercs: create a skeleton for neercs.

File size: 1.5 KB
Line 
1
2-- GLSL.Vert --
3#version 100
4
5attribute vec3 in_Vertex;
6attribute vec3 in_Normal;
7attribute vec4 in_Color;
8uniform mat4 in_ModelView;
9uniform mat4 in_Proj;
10uniform mat3 in_NormalMat;
11uniform float in_Damage;
12varying vec4 pass_Color;
13
14void main(void)
15{
16    /* Material properties */
17    vec3 specular_reflect = vec3(0.8, 0.75, 0.4);
18    float specular_power = 60.0;
19
20    /* World properties */
21    float ambient_mul = 0.5;
22    vec3 light_dir = normalize(vec3(0.3, 0.3, 0.7));
23    vec3 ambient_color = vec3(0.25, 0.2, 0.35);
24    vec3 diffuse_color = vec3(1.0, 1.0, 0.6);
25    vec3 specular_color = vec3(1.0, 1.0, 0.6);
26
27    vec3 tnorm = normalize(in_NormalMat * in_Normal);
28    vec4 eye = in_ModelView * vec4(in_Vertex, 1.0);
29
30    vec3 s = light_dir; /* normalize(eye - lightpos); */
31    vec3 v = normalize(-eye.xyz);
32    vec3 r = reflect(-s, tnorm);
33
34    vec3 ambient = ambient_color;
35    float sdotn = max(dot(s, tnorm), 0.0);
36    vec3 diffuse = diffuse_color * sdotn;
37    vec3 specular = vec3(0.0, 0.0, 0.0);
38    if (sdotn > 0.0)
39        specular = specular_color * specular_reflect
40                 * pow(max(dot(r, v), 0.0), specular_power);
41    vec3 light = ambient + diffuse + specular;
42
43    vec4 real_color = in_Damage * vec4(1.2, 1.2, 1.2, 1.0)
44                    + (1.0 - in_Damage) * in_Color;
45    pass_Color = real_color * vec4(light, 1.0);
46    gl_Position = in_Proj * eye;
47}
48
49-- GLSL.Frag --
50#version 100
51
52precision highp float;
53varying vec4 pass_Color;
54
55void main(void) {
56    gl_FragColor = pass_Color;
57}
58
Note: See TracBrowser for help on using the repository browser.