Created
July 17, 2020 09:19
-
-
Save CedricGuillemet/a47547c9de26c3427878b446fec6d07a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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