Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length

 
Advanced search

1075929 Posts in 44152 Topics- by 36119 Members - Latest Member: Royalhandstudios

December 29, 2014, 04:03:20 PM
TIGSource ForumsDeveloperTechnical (Moderators: Glaiel-Gamer, ThemsAllTook)Rendering on top of scene, like Minecraft player names
Pages: [1]
Print
Author Topic: Rendering on top of scene, like Minecraft player names  (Read 731 times)
Orz
Level 1
*


"When nothing is done, nothing is left undone."


View Profile WWW Email
« on: October 12, 2013, 07:46:33 AM »

In Minecraft MP servers, you can see other players' names even when they're underground.  The text is rendered at the same scale and location it would be if the view were unobstructed.  Does anyone know how this effect is achieved?
Logged
Eigen
Level 10
*****


Jebus backups.


View Profile WWW
« Reply #1 on: October 12, 2013, 08:02:18 AM »

By mapping/projecting a 3d coordinate to screen space.

Something like this but there are numereous other code snippets out there as well.
Logged

Thomas Hiatt
Level 0
**



View Profile Email
« Reply #2 on: October 12, 2013, 08:13:22 AM »

Couldn't you also just render them with depth testing disabled and after all the other stuff?
Logged
Orz
Level 1
*


"When nothing is done, nothing is left undone."


View Profile WWW Email
« Reply #3 on: October 12, 2013, 12:10:59 PM »

Couldn't you also just render them with depth testing disabled and after all the other stuff?

Yeah, that was it.  I figured they would have used the laziest solution Smiley.  Thanks!
Logged
soryy708
Level 3
***


Where is my tea?


View Profile Email
« Reply #4 on: October 12, 2013, 12:11:43 PM »

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// render scene
glClear(GL_DEPTH_BUFFER_BIT);
// render names
Logged

Portfolio:
  • Cacto Loco! - 'Additional Tunes' (Composer)
  • To be continued...
Polly
Level 4
****


View Profile
« Reply #5 on: October 12, 2013, 12:36:27 PM »

@soryy708 - Although that works .. i'd recommend the approach Thomas suggested instead Wink

Code:
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glEnable(GL_DEPTH_TEST);
// render scene
glDisable(GL_DEPTH_TEST);
// render names
Logged
powly
Level 3
***



View Profile WWW
« Reply #6 on: October 13, 2013, 11:23:32 AM »

The method suggested by soryy has the benefit of correctly rendering names that occlude each other - otherwise they're equivalent (well, an additional clear might cost you some marginal time but your problems lie elsewere if you hit performance problems with it)
Logged
Polly
Level 4
****


View Profile
« Reply #7 on: October 13, 2013, 11:50:32 AM »

The method suggested by soryy has the benefit of correctly rendering names that occlude each other

For a monotone pixel-font ( as used in Minecraft ) this doesn't matter .. and for "modern" fonts that use transparency you need to depth-sort instead. But in principle you're right of course Wink
Logged
Pages: [1]
Print
Jump to:  

Theme orange-lt created by panic