Last active
June 26, 2019 12:51
-
-
Save nicebyte/ce8ece13a31b9e8d7785d184d0c92396 to your computer and use it in GitHub Desktop.
frequently used routines for shadertoy
This file contains 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
vec2 aspectCorrectedCoords(in vec2 fragCoord) { | |
vec2 uv = fragCoord/iResolution.xy; | |
vec2 xy = uv * 2.0 - 1.0; | |
xy.x *= iResolution.x / iResolution.y; | |
return xy; | |
} | |
float nearPlaneDist(in float verticalFovDegrees) { | |
return 1.0 / tan(radians(verticalFovDegrees/2.0)); | |
} | |
vec3 primRayDir(in vec2 xy, in float verticalFovDegrees) { | |
return normalize(vec3(xy, nearPlaneDist(verticalFovDegrees))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment