# Billboarding particles + VBO issue

This topic is 1747 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hey guys,

I'm working on a simple particle system, but I'm having an issue.

I am not that unfamiliar with the concept of using an VBO and I successfully use it for rendering my meshes and such. When I started with my particle system, I plugged in all the relevant data and the particles render how I expect them to be and on the right positions.

However, because I use one VBO for all the particles, the entire VBO will be rendered as a billboard instead of them being separate particles, this is normal behaviour if you think about it, but not the kind of behaviour I want.

I simply want to put all my positions/uvs and whatnot in a single VBO and render them like they are individual particles, but I am not sure how to do this in a proper way.

I'm using a shader to billboard the object. This is what I have:

void Liqua::ParticleSystem::Render(glm::mat4 a_Projection, glm::mat4 a_View)
{
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, m_Tex);

glm::mat4 ModelView = a_View * m_ModelMatrix;

glEnableVertexAttribArray(0); // 0 for vertex positions
glBindBuffer(GL_ARRAY_BUFFER, m_BufferIndex);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, (void*)0);

glEnableVertexAttribArray(1);
glBindBuffer(GL_ARRAY_BUFFER, m_UVBufferIndex);
glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, 0, (void*)0);

glDrawArrays(GL_TRIANGLES, 0, m_VertexBuffer.size());
glDisableVertexAttribArray(0);
glDisableVertexAttribArray(1);

glBindTexture(GL_TEXTURE_2D, 0);
}


And the vertex shader that performs the billboarding:

layout (location = 0) in vec3 Position;
layout (location = 1) in vec2 TexCoord;
layout (location = 2) in vec3 Normal;

uniform mat4 ProjectionMatrix;
uniform mat4 ModelViewMatrix;

out vec2 TexCoord0;
out vec3 Normal0;
out vec3 WPos0;

void main(void)
{
gl_Position = ProjectionMatrix * (vec4(Position.x, Position.y, Position.z, 1) + vec4(ModelViewMatrix[3].xyz, 0));
TexCoord0 = TexCoord;
Normal0 = (ModelViewMatrix * vec4(Normal, 0.0)).xyz;
WPos0 = (ModelViewMatrix * vec4(Position, 1.0));
}


I do not want to create a VBO for every particle for obvious reasons. Perhaps this is not the best way to do billboarding and instead make them face the camera in C++ instead of in the shader. Or perhaps I'm just missing the obvious here.

I'm free for any suggestion, as long as it's not making use of the fixed function pipeline.

##### Share on other sites

As I posted this, I decided to try out my own suggestion and simply billboard in my C++ code. It's working fine now :)