Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Call this function to generate a fake sphere from a point sprite
- vec3 point_normal(in vec2 uv)
- {
- vec3 n;
- n.xy = uv * 2.0 - 1.0;
- float rr = dot(n.xy, n.xy);
- if (rr > 1.0) discard;
- n.z = sqrt(1.0 - rr);
- return n;
- }
- // ...
- // Then later, use the normal returned by `point_normal` to calculate the new frag depth
- // ...
- float radius = point_sprite_size * 0.5;
- vec4 pixel_position = vec4(fs_in.camera_space_position + normal * radius, 1.0);
- vec4 clip_space_position = projectionMatrix * pixel_position;
- clip_space_position.z /= clip_space_position.w;
- gl_FragDepth = clip_space_position.z;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement