1:1 scale billboard sprites

Started by
2 comments, last by Blue*Omega 20 years, 11 months ago
Okay, this one may be sort of difficult to explain, but bear with me! I''m working on an engine where the landscape/background/maps are 3D, and any players/charecters/actors are 2D sprites (think something like Ragnarok Online) Now, I can get the sprite to render and properly rotate so it''s always facing the camera (read: billboard), but the problem comes in scaling it. Let''s say for example I have a charecter sprite which is 64x128 pixles, and it''s being rendered into the scene as a square polygon that is 1x2 units. The proportions are the same, so there''s no distortion. All good so far! Problem comes in when I render it. Depending on the camera location and screen resolution the Sprite on screen can be quite a bit larger or smaller than the original sprite, causing ugly streaching or compressing of the image. Now, the camera''s distance from hte sprite is going to be staying constant, so is there any way of figuring out either the distance teh camera needs to be or the size the sprite should be rendered to get a 1:1 pixle corralation on the screen? (did that make any sense?)
// Tojiart
Advertisement
There''s a problem with your idea, and that''s with different resolutions. With large resolutions the sprite would be too small.
I realize that. For this particular implmentation I want the sprite to maintain a 1:1 pixel ratio, rather than have it scale up with the resolution.
// Tojiart
Yes, it makes sense. You''ll need to work in screen coordinates for scaling. If you''re doing simple billboards, then point sprites do exactly what you need - check out the point sprite scaling parameters to see how to specify rendering in screen space.

There are a number of other ways to do this, however. Another way is to project the position of your billboarded object youself using a function such as D3DXVec3Project. With the screen space coordinates obtained, you can then draw your quad.

This topic is closed to new replies.

Advertisement