Generates a 3D lookAt matrix in GLSL.
Creates a mat3
matrix you can use to transform coordinates
to look towards a given point, where:
origin
is the position of the camera.target
is the position to look towards.roll
is the roll rotation of the camera.
#pragma glslify: lookAt = require('glsl-look-at')
uniform vec2 iResolution;
void main() {
// Required bootstrap for a Shadertoy-style
// raytracing scene:
vec2 p = (2.0*gl_FragCoord.xy-iResolution.xy)/iResolution.y;
vec2 ro = vec3(3.5*sin(0.0),3.0,3.5*cos(0.0));
vec2 ta = vec3(0.0,0.0,0.0);
// ...
mat3 camMat = lookAt(ro, ta, 0.0);
vec3 rd = normalize(camMat * vec3(p, 2.0));
// ...
}
See stackgl/contributing for details.
MIT. See LICENSE.md for details.