paradoxresolved

03-14-2016, 08:51 AM

I'm working on a simple billboard shader that always faces the camera but maintains pitch. If the camera rotates up around the x axis, the billboard will shrink as if looking down on an actual billboard. I can't seem to get the latter to work.

Here is my vertex shader:

uniform mat4 mProjection;

uniform mat4 mView;

uniform mat4 mModel;

varying vec4 textureCoords;

void main(void)

{

gl_TexCoord[0] = gl_MultiTexCoord0;

mat4 temp = mView*mModel;

temp[0][0] = 1;

temp[0][1] = 0;

temp[0][2] = 0;

temp[1][0] = 0;

temp[1][1] = 1;

temp[1][2] = 0;

temp[2][0] = 0;

temp[2][1] = 0;

temp[2][2] = 1;

gl_Position = mProjection * temp * gl_Vertex;

textureCoords = vec4(gl_Vertex.x + 0.5, gl_Vertex.y + 0.5, 0.0, 0.0);

}

I tried importing the pitch (in radians) as a uniform in an attempt to rotate the object back along the x but could not get it to work.

Anyone have any suggestions?

Here is my vertex shader:

uniform mat4 mProjection;

uniform mat4 mView;

uniform mat4 mModel;

varying vec4 textureCoords;

void main(void)

{

gl_TexCoord[0] = gl_MultiTexCoord0;

mat4 temp = mView*mModel;

temp[0][0] = 1;

temp[0][1] = 0;

temp[0][2] = 0;

temp[1][0] = 0;

temp[1][1] = 1;

temp[1][2] = 0;

temp[2][0] = 0;

temp[2][1] = 0;

temp[2][2] = 1;

gl_Position = mProjection * temp * gl_Vertex;

textureCoords = vec4(gl_Vertex.x + 0.5, gl_Vertex.y + 0.5, 0.0, 0.0);

}

I tried importing the pitch (in radians) as a uniform in an attempt to rotate the object back along the x but could not get it to work.

Anyone have any suggestions?