Skip to content

Instantly share code, notes, and snippets.

@nicebyte
Last active June 26, 2019 12:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nicebyte/ce8ece13a31b9e8d7785d184d0c92396 to your computer and use it in GitHub Desktop.
Save nicebyte/ce8ece13a31b9e8d7785d184d0c92396 to your computer and use it in GitHub Desktop.
frequently used routines for shadertoy
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