Skip to content

Instantly share code, notes, and snippets.

@kovrov
Created August 16, 2011 00:27
Show Gist options
  • Save kovrov/1148201 to your computer and use it in GitHub Desktop.
Save kovrov/1148201 to your computer and use it in GitHub Desktop.
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));
}
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