glsl-camera-ray
Generates a ray for Shadertoy-style raycasting in GLSL.
Accepts either either a camera origin/target or an arbitrary mat3
matrix.
Usage
vec3 cameraRay(vec3 ro, vec3 ta, vec2 screen, float lens)
vec3 ro
is the position of the camera.vec3 ta
is the position the camera is pointing towards.vec2 screen
is the position of the fragment on the screen, generally between -1 and 1. For non-square frames you'll want to normalize this using something like glsl-square-framelens
is the lens length of the camera. This works similarly to FOV, where0.0
is horribly wide and2.0
is a decent default.
# square = require('glsl-square-frame')# camera = require('glsl-camera-ray')uniform vec2 iResolution;uniform float iGlobalTime;void
vec3 cameraRay(mat3 camera, vec2 screen, float lens)
For more flexibility, you can supply mat3 camera
in place
of vec3 ro, vec3 ta
. This way, you can use your own camera
modules alongside glsl-camera-ray
.
Contributing
See stackgl/contributing for details.
License
MIT. See LICENSE.md for details.