X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;ds=sidebyside;f=gl%2Fmesh_surfaceangle.frag;fp=gl%2Fmesh_surfaceangle.frag;h=3ee94ddff05f8ff83c86b90b443b44b17c48bf9d;hb=dd4a156f8787b310568d82161bddd478b0938499;hp=0000000000000000000000000000000000000000;hpb=0da9fdf2b9623665a991990e57485a007645eba6;p=fstl diff --git a/gl/mesh_surfaceangle.frag b/gl/mesh_surfaceangle.frag new file mode 100644 index 0000000..3ee94dd --- /dev/null +++ b/gl/mesh_surfaceangle.frag @@ -0,0 +1,17 @@ +#version 120 + +uniform float zoom; + +varying vec3 ec_pos; + +void main() { + vec3 ec_normal = normalize(cross(dFdx(ec_pos), dFdy(ec_pos))); + ec_normal.z *= zoom; + ec_normal = normalize(ec_normal); + //rotated 10deg around the red axis for better color match + float x = dot(ec_normal, vec3(1.0, 0.0, 0.0)); + float y = dot(ec_normal, vec3(0.0, 0.985, 0.174)); + float z = dot(ec_normal, vec3(0.0, -0.174, 0.985)); + + gl_FragColor = vec4(0.5-0.5*x, 0.5-0.5*y, 0.5+0.5*z, 1.0); +}