Skip to content

Instantly share code, notes, and snippets.

@supahfunk
Forked from yiwenl/align.glsl
Created January 14, 2020 17:46
Show Gist options
  • Save supahfunk/b9bb7d95355867a3fe6dcbf347c136ec to your computer and use it in GitHub Desktop.
Save supahfunk/b9bb7d95355867a3fe6dcbf347c136ec to your computer and use it in GitHub Desktop.
vec3 align(vec3 pos, vec3 dir) {
vec3 initDir = vec3(1.0, 0.0, 0.0);
vec3 axis = cross(dir, initDir);
float angle = acos(dot(dir, initDir));
return rotate(pos, axis, angle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment