Jump to content
  • Advertisement
Sign in to follow this  
Steve_Segreto

Estimating rendered model size given dist, radius and projection matrix

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

Hi there, I need help figuring out how to estimate the rendered size of a model. I'll use the bounding sphere surrounding the model as an approximation. It has a 3-d vector for it's center position and a float representing the sphere's radius. I have a 3-d projection matrix computed using the standard FOV matrix computation, and I can compute the distance from the center of the model to the camera using: distToCamera = vector length (model center - camera center) Not sure how to estimate how large in screen space pixels the model will likely be rendered at? I have the z-near and z-far data handy as well. Any help or links to Google would be appreciated. Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Thanks I actually want to estimate the size of the model after the projection so I can cull it if it's too small. I'm using DirectX and could use the alternative D3DXVec3Project() (or probably just vector-matrix multiply the center of the bounding sphere by the world-view-projection matrix myself), but I still don't understand how to figure out how big the transformed object will be?

Share this post


Link to post
Share on other sites
Calculate a scissor rectangle from bounding box points projected to screen... And use width & height to determine what you need.

Okay, I can give you some code tomorrow, its for lights, but will work for models as well.

Share this post


Link to post
Share on other sites
Thanks for the replies guys,

What I'm trying now is projecting the bounding sphere center and a point along the radius to screen space then subtracting the two vectors and taking their length and using that as the estimated screen space radius of the projected model.

EDIT: Worked great, will rate up all who replied thx!

Share this post


Link to post
Share on other sites
Unless the object is particularly elongated (e.g. a needle), you can probably do this based on the radius of the object.

Then, your size (linear, not area) will always be:

k * radius / distance

where k is some constant of proporitionality, which would be a function of the projection. Figuring out the specifics for the constant is a bit more complicated, however.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

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

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!