Make arbitrary geo face the camera

Started by
2 comments, last by playmesumch00ns 17 years, 5 months ago
I'm trying to do a billboard vertex shader. All the examples I've seen here assume you're just drawing a quad, whereas my geometry is significantly more complex. What I've tried so far is to just reset the upper 3x3 part of the model view matrix to the identity to try and remove the rotations, but without success (my object completely disappears from view!)

void main()
{
        mat4 view = gl_ModelViewMatrix;
	
	view[0][0] = 1;
	view[0][1] = 0;
	view[0][2] = 0;
	view[1][0] = 0;
	view[1][1] = 1;
	view[1][2] = 0;
	view[2][0] = 0;
	view[2][1] = 0;
	view[2][2] = 1;
	
	
	vec4 P = view * gl_Vertex;
	gl_Position = gl_ProjectionMatrix * P;
}

Has anyone succesfully done anything like this before?
Advertisement
Check This thread

[edit]Opps that might not be exactly what your looking for. I didn't read through it completely when I found it[/edit]
receting it the top 3x3 to the identity will remove alot more then just rotation!!!
Well I realise it's going to remove scale as well, but since I know the scale factor to apply to the object I figure I can just put it back in afterwards :) I'm not bothered about having shearing or anything else...

This topic is closed to new replies.

Advertisement