SHARE
TWEET
Untitled
a guest
Dec 10th, 2014
171
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- #version 330
- uniform mat4 projectionMatrix;
- uniform float sphereRadius;
- in vec3 fPosition;
- void main()
- {
- vec3 Normal;
- // Get the coordinates of the fragment
- Normal.xy = gl_PointCoord * 2.0 - vec2(1.0);
- // Is the fragment inside the unit circle?
- float r2 = dot(Normal.xy,Normal.xy);
- if(r2 > 1.0) discard;
- // Compute the depth on a unit sphere
- Normal.z = -sqrt(1.0 - r2);
- // View-space depth
- vec4 fPos = vec4(fPosition - sphereRadius*Normal, 1.0);
- vec4 clipPos = projectionMatrix * fPos;
- gl_FragDepth = clipPos.z / clipPos.w;
- //far * near / (far * -ndc.z + far + near * ndc.z)
- }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy.

