Skip to main content
gamedev.net
🔒 Locked

Occlusion problem

Started by budipro 2 replies 500+ views
Original Post
budipro
budipro
Hi all, I have rendered a 3D globe (sphere), and put textures (earth map) on it. Now I must put some symbols and labels for cities or other spots. I had tried to use a textured quad for the symbols and rendered them straight into screen coordinates. I have to use screen coordinates and orthogonal projection, because if I use world coordinates and perspective projection, if I zoom in and out, the symbols will be changing in size, too. I need the symbols to stay fixed in size(just like in 2D). If I rotate the globe, the symbols and labels are also rotating, which means they should not be visible if they are on the other side of the globe. My problem is: Because I already render them into screen coordinates, they are still got rendered. Is there any way to handle this fast? I also would like to know if there are any faster way to draw the symbols. Cause I think if I have to transform each symbol into screen coordinates before draw them to screen, it''s kind of slow. Thanks a lot.
treething
treething
How are you calculating the z-values for the sprites screen coordinates? If youre using the zbuffer and those calculations are correct then the sprites should be occluded properly.
psykr
psykr
His problem isn''t just the occlusion, his zooming in/out changes the size of the labels. (Assuming budipro is a he.)

Drawing textured quads is pretty much the fastest possible way to draw 2D images on modern hardware. I''m afraid I don''t know any elegant solutions to your problem though. You could scale the size of the quad according to its distance from the camera..
budipro
budipro
Thanks for your replies, guys.

I calculate screen coordinates using Direct3D Vector3.Project function. It will generate screen coordinate in form of Vector3. But I just render them using Z value = 0. Am I wrong? Cause I don''t see any difference if I render them using the generated Z value from Vector3.Project function.

Currently I just try to calculate the dot product between my camera direction vector and the symbol coordinate. If the result is smaller than 0.0, then the symbol should be on the other side of the globe (not rendered). FYI, my camera is always looking at the center of the globe, which is (0, 0, 0).

But, the result is not quite like what I expected. Some symbols are still rendered even they are at the back. If I raise up the threshold (smaller than 0.3), the result is correct. I wonder why.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.