Archived

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

1:1 scale billboard sprites

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?)

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites