]> git.sur5r.net Git - fstl/blob - gl/mesh_surfaceangle.frag
New upstream version 0.10.0
[fstl] / gl / mesh_surfaceangle.frag
1 #version 120
2
3 uniform float zoom;
4
5 varying vec3 ec_pos;
6
7 void main() {
8     vec3 ec_normal = normalize(cross(dFdx(ec_pos), dFdy(ec_pos)));
9     ec_normal.z *= zoom;
10     ec_normal = normalize(ec_normal);
11     //rotated 10deg around the red axis for better color match
12     float x = dot(ec_normal, vec3(1.0, 0.0, 0.0));
13     float y = dot(ec_normal, vec3(0.0, 0.985, 0.174));
14     float z = dot(ec_normal, vec3(0.0, -0.174, 0.985));
15
16     gl_FragColor = vec4(0.5-0.5*x, 0.5-0.5*y, 0.5+0.5*z, 1.0);
17 }