Skip to content

Instantly share code, notes, and snippets.

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

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

Select an option

Save CedricGuillemet/a47547c9de26c3427878b446fec6d07a to your computer and use it in GitHub Desktop.
void main(void) {
vec3 rayDir = normalize(vPosition - vEyePosition);
float distanceFromSurface = 0.0;
for (int i = 0; i < 100; i++) {
vec3 currentPosition = vPosition + distanceFromSurface * rayDir;
if (sphereDistance(currentPosition, vec3(0,1,0), 1.0) < 0.){
gl_FragColor = vec4(rayDir, 1.0);
return;
}
distanceFromSurface += 0.03;
}
discard;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment