Skip to content

Instantly share code, notes, and snippets.

@supahfunk
Created February 2, 2022 21:06
Show Gist options
  • Save supahfunk/02ccfc5fc08d40bbada88b1cf8fe43b5 to your computer and use it in GitHub Desktop.
Save supahfunk/02ccfc5fc08d40bbada88b1cf8fe43b5 to your computer and use it in GitHub Desktop.
Matcap material glsl
/* Vertex shader */
vNormal = normalize(vec3(world * vec4(normal, 0.0))); // Normal in model
/* Fragment shader */
// Move normal to view space
highp vec2 muv = vec2(view * vec4(normalize(vNormal), 0))*0.5+vec2(0.5,0.5);
// read texture inverting Y value
gl_FragColor = texture2D(matcapTexture, vec2(muv.x, 1.0-muv.y));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment