Archived

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

valid screen-space metric?

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

Recommended Posts

Hi, As part of an LOD system to be used in a terrain engine, I thought up the following calculation to get an approximation to the screen space contribution of a given chunk of geometry... Take the center point for the geometry sector, and then find the most extreme point (effectively finding a form of bounding sphere)... and then, at render-time, project these two points onto the screen plane (world*view*proj*viewport*vector i think ) and calculate the standard 2D distance between. Use this value as a scalar (bigger=more contribution). Does that appear mathematically sound? I don''t know of a name for this sort of thing, so didn''t bother searching for any existing stuff If I am correct along these lines, would the ratio of any intermediary results be the same? or would I always have to transform 3D->2D? Obviously, the less calculations the better - and the 4 matrix multiplications aren''t very performance-friendly when a large scene is used. cheers, Jack DirectX 4 VB: All you need for multimedia programming in Visual Basic Formula 1 Championship Manager, My Game Project.

Share on other sites
You wouldn't need to project the points onto the 2D screen space, you can calculate it directly...

say P is the center point, C is the position of the camera and r is the radius of your sphere. you can get the angle between the line to the center of the sphere and the edge of the sphere like so:

float fDist = GetLength(P-C);float fAngle = asinf(r/fDist);

this angle will give you an idea of how much space on the screen it takes up, the greater the angle the more space it takes up... if you want to know exactly what fraction of the screen its taking up do this:

float fFraction = fAngle / fFOV;

where fFOV is your field of view (if the horizontal field of view is given then you get the horizontal fraction, likewise for vertical fov).

that should be pretty fast.

EDIT: Note also you'll need to make sure the value you are taking asinf of is not greater than 1 or smaller than -1 or you will run into trouble. just a simple if (value > 1) value = 1 else if (value < -1) value = -1 will do the trick.

[edited by - SpaceDude on May 19, 2004 2:57:55 PM]

1. 1
Rutin
26
2. 2
3. 3
JoeJ
20
4. 4
5. 5

• 10
• 9
• 9
• 46
• 41
• Forum Statistics

• Total Topics
631750
• Total Posts
3002067
×