Why are my billboarded quads being rendered this way?

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
Post Reply
User avatar
kicknbritt
Citizen
Posts: 98
Joined: Sat May 30, 2015 2:15 am
Location: Chicago, IL/Anchorage,AK

Why are my billboarded quads being rendered this way?

Post by kicknbritt »

So I am instancing a quad a bunch of times in an area in love, which seems to be going fine, but when I add some shader code to billboard them they render at an odd spot and look like they are all pivoting around (0, 0, 0) (the position of the mesh I am instancing many times).
They also rotate with the camera as well.
Do I maybe have to make a new matrix for each instance to get them all to face the camera from their position, or I am doing something else wrong?

Here is the vertex shader code for the regular, non-billboard version:

Code: Select all

mat4 ModelView = viewMatrix*modelMatrix;
            
relativeWorldPosition = projectionMatrix * ModelView * (vertexPosition + vec4(instancePositions[love_InstanceID].xyz, 0));          
            
return relativeWorldPosition;
Here is the vertex shader code for the billboard version:

Code: Select all

mat4 ModelView = viewMatrix*modelMatrix;
            
ModelView[0][0] = 1;
ModelView[0][1] = 0;
ModelView[0][2] = 0;

            // Column 1:
ModelView[1][0] = 0;
ModelView[1][1] = 1;
ModelView[1][2] = 0;

            // Column 2:
ModelView[2][0] = 0;
ModelView[2][1] = 0;
ModelView[2][2] = 1;

relativeWorldPosition = projectionMatrix * ModelView * (vertexPosition + vec4(instancePositions[love_InstanceID].xyz, 0));
            
            
return relativeWorldPosition;
Attachments
billboard version
billboard version
glsl 2.PNG (496.45 KiB) Viewed 101756 times
non-billboard version
non-billboard version
glsl 1.PNG (640.83 KiB) Viewed 101756 times
"I AM THE ARBITER!!!" *Pulls out Energy sword and kills everything*
Post Reply

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot], Google [Bot] and 11 guests