#### Archived

This topic is now archived and is closed to further replies.

## Recommended Posts

Currently, I use a dynamic VB wich I update every frame to transform each of my billboard. But this technique is costly when i have n > 1500 billboards. So is it faster using a vertex shader to transform them on the gpu? I dont really know how to implement them. Thanx for ur help

##### Share on other sites
You can do it on the GPU exactly the same way as you would on the CPU. The only difference is that for each vertex you must store an extra value indicating which corner of the billboard quad the vertex lies in.

##### Share on other sites
quote:
I dont really know how to implement them.

For each billboard, store 4 vertices of the same position (the center of the billboard) and with each vertex, store a value that defines which corner of the billboard it should be (i.e. top-left, top-right, bottom-left, bottom-right).

Store the camera's up and right vectors, as well as the billboard width and height in the shader's constant table.
For each vertex (pseudo):
if top-left    pos += -camRight * billboardWidth + camUp * billboardHeightelseif top-right    pos += camRight * billboardWidth + camUp * billboardHeightelseif bottom-left    pos += -camRight * billboardWidth - camUp * billboardHeightelseif bottom-right    pos += camRight * billboardWidth - camUp * billboardHeightend

Cheers,

edit: fixed pseudo code

[edited by - Coder on May 4, 2003 12:00:28 AM]

• ### Forum Statistics

• Total Topics
628402
• Total Posts
2982471

• 9
• 10
• 9
• 19
• 24