Created
August 16, 2011 00:27
-
-
Save kovrov/1148201 to your computer and use it in GitHub Desktop.
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
varying vec2 screenPos; | |
varying float radius; | |
uniform sampler2D tex; | |
void main() | |
{ | |
float dist_squared = distance(gl_FragCoord.xy, screenPos); | |
// Sphere shaded | |
if (dist_squared > radius) | |
discard; | |
gl_FragData[0] = gl_Color; | |
// gl_FragData[0] = mix(gl_Color, vec4(gl_Color.rgb, 0), | |
// smoothstep(15., 16.0, dist_squared)); | |
} |
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
uniform vec2 windowSize; | |
varying vec2 screenPos; | |
varying float radius; | |
void main() | |
{ | |
gl_Position = gl_ModelViewProjectionMatrix * gl_Vertex; | |
gl_PointSize = 32.0; | |
// Convert position to window coordinates | |
vec2 halfsize = vec2(windowSize.x, windowSize.y) * 0.5; | |
screenPos = halfsize + ((gl_Position.xy / gl_Position.w) * halfsize); | |
// Convert radius to window coordinates | |
radius = gl_PointSize * 0.5; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment