Billboarding restricted to an axis (cylindrical)
Posted
by
user8709
on Game Development
See other posts from Game Development
or by user8709
Published on 2012-10-22T04:10:07Z
Indexed on
2012/10/22
5:17 UTC
Read the original article
Hit count: 404
I have succesfully created a GLSL shader for a billboarding effect. I want to tweak this to restrict the billboarding to an arbitrary axis, i.e. a billboarded quad only rotates itself about the y-axis. I use the y-axis as an example, but essentially I would like this to be an arbitrary axis. Can anyone show me how to modify my existing shader below, or if I need to start from scratch, point me towards some resources that could be helpful?
precision mediump float;
uniform mat4 u_modelViewProjectionMat;
uniform mat4 u_modelMat;
uniform mat4 u_viewTransposeMat;
uniform vec3 u_axis; // <------------ !!! the arbitrary axis to restrict rotation around
attribute vec3 a_position0;
attribute vec2 a_texCoord0;
varying vec2 v_texCoord0;
void main()
{
vec3 pos = (a_position0.x * u_viewTransposeMat[0] + a_position0.y * u_viewTransposeMat[1]).xyz;
vec4 position = vec4(pos, 1.0);
v_texCoord0 = a_texCoord0;
gl_Position = u_modelViewProjectionMat * position;
}
© Game Development or respective owner