Created
March 20, 2015 19:04
-
-
Save paulklemm/d4eec3e1648c49219376 to your computer and use it in GitHub Desktop.
RCube Shader
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
<script type="x-shader/x-vertex" id="vertexshader"> | |
attribute float alpha; | |
varying float vAlpha; | |
// Coloring: https://stackoverflow.com/questions/25740054/three-js-passing-vertex-colors-to-fragment-shader | |
varying vec3 vColor; | |
void main() { | |
vColor = color; | |
vAlpha = alpha; | |
mat4 newViewMatrix = modelViewMatrix; | |
mat4 newProjectionMatrix = projectionMatrix; | |
vec4 mvPosition = newViewMatrix * vec4( position, 1.0 ); | |
// gl_PointSize = 3700.0 / length( mvPosition.xyz ); | |
// gl_PointSize = 1200.0 / length( mvPosition.xyz ); | |
gl_PointSize = 3000.0 / length( mvPosition.xyz ); | |
gl_Position = newProjectionMatrix * mvPosition; | |
} | |
</script> | |
<script type="x-shader/x-vertex" id="vertexshaderCurrentSlice"> | |
attribute float alpha; | |
varying float vAlpha; | |
// Coloring: https://stackoverflow.com/questions/25740054/three-js-passing-vertex-colors-to-fragment-shader | |
varying vec3 vColor; | |
void main() { | |
vColor = color; | |
vAlpha = alpha; | |
mat4 newViewMatrix = modelViewMatrix; | |
mat4 newProjectionMatrix = projectionMatrix; | |
vec4 mvPosition = newViewMatrix * vec4( position, 1.0 ); | |
gl_PointSize = 7000.0 / length( mvPosition.xyz ); | |
gl_Position = newProjectionMatrix * mvPosition; | |
} | |
</script> | |
<script type="x-shader/x-fragment" id="fragmentshader"> | |
varying float vAlpha; | |
varying vec3 vColor; | |
void main() { | |
gl_FragColor = vec4(vColor.rgb, 1); | |
gl_FragColor.a *= vAlpha; | |
} | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment