Jump to content
  • Advertisement


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


Determining "On Screen" Quickly?

This topic is 5862 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

Can anyone tell me if there is a fast way to determine if a mesh/object/point is on screen without screen-resolution n x n raycasting? Right now I''m using really elaborate ways of determining if something is visible and its kind of sloppy. Any ideas on determining if something is in the view?

Share this post

Link to post
Share on other sites
If I were you I would look at frustrum culling. This will tell you fairly quickly whether something is on screen or not. Do a search in the forums for it because I have seen it come up at least twice in the last month.


Share this post

Link to post
Share on other sites

As mentioned above, search the archives here, it''s come up a few times in each of the forums here.

One of the simplest and quickest methods is a "shere in cone" test. It is however less precise, you get more false trivial-accepts.

Basically you calculate a bounding sphere for every object in the scene (i.e a position and a radius).

You then calculate a cone which represents the view frustum (the axis of the cone is the direction the camera is looking, the base and apex are the far/near clipping planes and the sweep angle is the field of view).

Then with a simple bit of maths you can determine whether the sphere is inside or outside of the cone, if it''s outside, then the object is definately not visible on the screen. If the sphere is inside or touches the edge of the cone, then the object is potentially visible on the screen.

In many situations this is enough culling, unless you have *lots* of objects or lots of thin objects which don''t fit in the sphere well. The beauty of using bounding volumes is an object could have 200000 polygons but you only do a single sphere->cone test to determine whether it might be visible.

If the object does have a lot of polys and is determined to be potentially visible by the test, you can then go down to finer grained methods (kd-trees, Octrees, BSP, brute-force etc). The point is you save lots of work when objects are definately not visible.

BTW: when searching, you might want to look for both "frustum" and "frustr um", many people accidentally spell it the second way (it shouldn''t have that last ''r'').

Simon O''Connor
Creative Asylum Ltd

Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!