[Algorithms] Keeping an object's label on the screen
Brought to you by:
vexxed72
|
From: Monteleone, N. <nat...@lm...> - 2009-04-29 18:29:04
|
I have to draw some billboard text over some shapes we've "painted" onto our terrain via multitexturing. Normally this is easy enough - just plop the label in an auto-rotated billboard and float it above the center of the geometry. But I need to keep the label on screen at all times if any part of the painted geometry is visible. I.e. if I have a square painted on the terrain, but I can only see a small corner of it, I still need to show the whole label. What's a good algorithm to figure out where to draw the label? The idea I had in mind was to do something in screen space... I'd write out an object ID version of the projected texture, apply it, render the terrain geometry into a low-res buffer, then compute min/max screen coords for each object. Then I could just draw my text label in screen space based on that information. Is this a sane approach? Otherwise I'd have to create a geometric representation of our shapes that conforms to the terrain and choose a 3d location for my text based on the view frustum. That seems painful to implement efficiently. Thanks, Nathan |