Sign in to follow this  

Small Angle Problem in Billboarding & Impostor Rendering on GPU

Recommended Posts

Dear GameDev community, I need to use Billboarding for rendering lots of people in Crowd Simulation. I have accomplished the part of creating quads rotated to the camera, without any problem. However, the code that selects suitable image from the impostor texture has problems on large areas. In other words, something goes wrong due to small angles. The code that I am using for that is very simple: float aoc = degrees(atan(c.y-o.y, length(c.xz-o.xz))); float boa = degrees(atan(c.z-o.z, c.x-o.x)) + 180; float angle = round( (boa/360.0) * 15.0); vec2 texCoord = gl_TexCoord[0].xy / 16.0; if (aoc<0.0) aoc = 0.0; float TV = round( (aoc/90.0) * 3.0) * 0.0625; texCoord = texCoord + vec2(angle * 0.0625,TV); In the code above, "o" is the position of object and "c" is the position of the camera. I am trying to calculate which image to select from the texture. I heard that Quaternions are used for handling such small angles. However, I do not have strong math background and do not know how to use it. Please help me, any support is strongly appreciated! Also, I will be really happy If you give example code with your explanations. Regards, Niklaus

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this