Skip to main content
GameDev.net gamedev.net
🔒 Locked

Determining distance before a sphere goes subpixel

Started by Unfadable Sep 22, 2010 at 3:54 PM 1 replies 1.3k views
Original Post
Unfadable
Unfadable
Hi all,

The subject says it all. I'd like to know at what distance a sphere is roughly subpixel.

- First I calculate the screen size in world space:

screenSize = nearPlane * tangent( fieldOfView / 2 );

- Then I determine the size of a pixel in world space:

pixelWorldSize = screenWorld Size / ( screenResolution / 2.0f );

- Then I use the law of similar triangles to solve for distance:

worldDistance = radius * near / pixelSize

It seems to work well in my testing. I'm eyeballing it, plus multiplying transforming a sphere at this distance into screenSpace to check the extents are within a pixel.

Does this all sound reasonable? Also, any tips for testing?

Thanks,
unfadable
eq
eq
I don't find anything wrong in your equations.

However I think it's wrong to call it "pixelWorldSize" since IMO a pixel can't have a "fixed" size (as in a single float) in world coordinates.

It's really the length of a side of the square that results from projecting a pixel onto the viewing plane.

As for coming up with a good name for this I'd leave it to someone with more imagination ;)


Unfadable
Unfadable
Cool, thanks Eq!

Topic Locked

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

Sign in to reply to this topic.