Skip to content

Instantly share code, notes, and snippets.

@CedricGuillemet
Created July 17, 2020 09:19
Show Gist options
  • Select an option

  • Save CedricGuillemet/f4bd93814d100ca7926e32b1998a740a to your computer and use it in GitHub Desktop.

Select an option

Save CedricGuillemet/f4bd93814d100ca7926e32b1998a740a to your computer and use it in GitHub Desktop.
float sphereDistance(vec3 point, vec3 sphereOrigin, float sphereRadius) {
return length(point - sphereOrigin) - sphereRadius;
}
void main(void) {
vec3 rayDir = normalize(vPosition - vEyePosition);
if (sphereDistance(vPosition, vec3(0,1,0), 1.1) > 0.)
discard;
gl_FragColor = vec4(rayDir, 1.0);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment