Created
September 4, 2014 00:40
-
-
Save eevee/9cf655e617859d2765f7 to your computer and use it in GitHub Desktop.
outline shader for THREE.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var outline_shader = { | |
uniforms: { | |
"linewidth": { type: "f", value: 0.3 }, | |
}, | |
vertex_shader: [ | |
"uniform float linewidth;", | |
"void main() {", | |
"vec4 mvPosition = modelViewMatrix * vec4( position, 1.0 );", | |
"vec4 displacement = vec4( normalize( normalMatrix * normal ) * linewidth, 0.0 ) + mvPosition;", | |
"gl_Position = projectionMatrix * displacement;", | |
"}" | |
].join("\n"), | |
fragment_shader: [ | |
"void main() {", | |
"gl_FragColor = vec4( 0.0, 0.0, 0.0, 1.0 );", | |
"}" | |
].join("\n") | |
}; | |
var outline_material = new THREE.ShaderMaterial({ | |
uniforms: THREE.UniformsUtils.clone(outline_shader.uniforms), | |
vertexShader: outline_shader.vertex_shader, | |
fragmentShader: outline_shader.fragment_shader | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment