opengl_enquirer

10-08-2003, 06:37 PM

just curious if anyone knows of a simple method for rendering the silhouette of a ~perfect perspective projected sphere as a single pixel line (no shading tricks).

michael

michael

View Full Version : know a simple method for rendering the silhouette of a perspective sphere? 2d>3d GUI

opengl_enquirer

10-08-2003, 06:37 PM

just curious if anyone knows of a simple method for rendering the silhouette of a ~perfect perspective projected sphere as a single pixel line (no shading tricks).

michael

michael

Cyranose

10-08-2003, 07:04 PM

Originally posted by opengl_enquirer:

just curious if anyone knows of a simple method for rendering the silhouette of a ~perfect perspective projected sphere as a single pixel line (no shading tricks).

michael

Do you mean as simple as drawing a N-element line strip formed into a circle and superimposed on your sphere?

It was a while ago, but I recall doing a simple trick where I took a 2D unit-circle and transformed it with some combination of the object's and the camera's matrices (one was inverted, can't remember which), accounting for the fact that the perspective silhouette is generally closer/smaller than the hemispheric midpoint. It worked for arbitrarily rotated ellipsoids too, surprisingly enough.

There was another way to compute the size of the circle as a function of the radius and distance that can probably be found in the arcball code if nothing else. Email me if you go that way and get stuck. I'll try to remember the details.

Avi

[This message has been edited by Cyranose (edited 10-08-2003).]

just curious if anyone knows of a simple method for rendering the silhouette of a ~perfect perspective projected sphere as a single pixel line (no shading tricks).

michael

Do you mean as simple as drawing a N-element line strip formed into a circle and superimposed on your sphere?

It was a while ago, but I recall doing a simple trick where I took a 2D unit-circle and transformed it with some combination of the object's and the camera's matrices (one was inverted, can't remember which), accounting for the fact that the perspective silhouette is generally closer/smaller than the hemispheric midpoint. It worked for arbitrarily rotated ellipsoids too, surprisingly enough.

There was another way to compute the size of the circle as a function of the radius and distance that can probably be found in the arcball code if nothing else. Email me if you go that way and get stuck. I'll try to remember the details.

Avi

[This message has been edited by Cyranose (edited 10-08-2003).]

dorbie

10-08-2003, 08:41 PM

That would be a circle. Point billboard it towards the eye (in 3D) and adjust the radius to match the radius at the surface tangent with the view vector (trivial trig to compute).

P.S. you just need the distance to the sphere for your trig and compute the tangent radius in 2D, using *only* the sphere radius and the distance to the sphere as inputs.

[This message has been edited by dorbie (edited 10-08-2003).]

P.S. you just need the distance to the sphere for your trig and compute the tangent radius in 2D, using *only* the sphere radius and the distance to the sphere as inputs.

[This message has been edited by dorbie (edited 10-08-2003).]

opengl_enquirer

10-08-2003, 10:40 PM

"That would be a circle. Point billboard it towards the eye (in 3D) and adjust the radius to match the radius at the surface tangent with the view vector (trivial trig to compute)."

you would think so but i'm not sure that the offset of the sphere from the center of the screen doesn't purturb the sphere slightly in a squashing fashion.

and yes in response to the first responder the actual silhouette is closer than the actual mid slice as sectioned by the z plane. i thought about just trying to fudge this and scale it relative to the projected radius but i though perhaps this behavior might not be uniform with respect to the distance. then doing the scaling in object space might be more apropriate. then their is still the issue of squashing which seems to exist.

so all in all i thought rather than doing a lot of fudgie expirimenting that might endup with no more than fudgie results, i might as well see whether or not this road has been traveled before.

oh before i go, i was thinking about trying a billboard technique, but thought i might ask first. still i would feel better if someone has actually done this sucessfully with a billboard. its worth adding that the interface includes a hand full of sections rendererd in object space that are not perpindicular to the view vector, so it would be very obvious if any of these sections escape the bounding section.

in any case i will think about it in the morning. i apreciate the response.

michael

you would think so but i'm not sure that the offset of the sphere from the center of the screen doesn't purturb the sphere slightly in a squashing fashion.

and yes in response to the first responder the actual silhouette is closer than the actual mid slice as sectioned by the z plane. i thought about just trying to fudge this and scale it relative to the projected radius but i though perhaps this behavior might not be uniform with respect to the distance. then doing the scaling in object space might be more apropriate. then their is still the issue of squashing which seems to exist.

so all in all i thought rather than doing a lot of fudgie expirimenting that might endup with no more than fudgie results, i might as well see whether or not this road has been traveled before.

oh before i go, i was thinking about trying a billboard technique, but thought i might ask first. still i would feel better if someone has actually done this sucessfully with a billboard. its worth adding that the interface includes a hand full of sections rendererd in object space that are not perpindicular to the view vector, so it would be very obvious if any of these sections escape the bounding section.

in any case i will think about it in the morning. i apreciate the response.

michael

opengl_enquirer

10-09-2003, 09:33 AM

this morning i decided to try a "billboard" with some scaling. i thought it might work well as the billboard should probably negotiate any squashing. i thought a regular offset along the view vector would do the trick. but it didn't. i still don't really understand why. so i changed it to offseting the distance from the eye to the center of the sphere by a constant value. and set the offset accoding to the inverse square of that distance. this works good until the sphere is about as tall as the screen. at that point the system becomes unstable. i'm not sure if that is the point that the eye enters the sphere. maybe testing for that and inverting some value would fix it if so. in any case it would never be the case i think that this would be necesarry, so i may just make the sphere a collision object so that the camera will be unable to travel through it.

in any case if any one has a better idea i'm all ears.

michael

so i added

in any case if any one has a better idea i'm all ears.

michael

so i added

dorbie

10-09-2003, 10:46 AM

The circle is a *3D* circle billboarded. That is why I described it as such in my post.

It is not a 2D circle in screen space.

The first works, the second doesn't due to projection effects on the sphere.

It's really simple. Use a circle of the correct radius at the sphere location billboarded and scaled down slightly (**and translated a small way towards the eye so it rests on the surface if you are depth buffering**). Basically the circle rests on sphere surface where the view vectors to the sphere are tangential to the sphere surface. In other words the circle describes the base of a cone that the sphere forms when projected to the eyepoint.

[This message has been edited by dorbie (edited 10-09-2003).]

It is not a 2D circle in screen space.

The first works, the second doesn't due to projection effects on the sphere.

It's really simple. Use a circle of the correct radius at the sphere location billboarded and scaled down slightly (**and translated a small way towards the eye so it rests on the surface if you are depth buffering**). Basically the circle rests on sphere surface where the view vectors to the sphere are tangential to the sphere surface. In other words the circle describes the base of a cone that the sphere forms when projected to the eyepoint.

[This message has been edited by dorbie (edited 10-09-2003).]

opengl_enquirer

10-09-2003, 06:59 PM

yeah, that is essentially what i did. i don't know if you inferred that i misunderstood you. as for scaling you want to scale it up, not down. i presume the first replier typoed there.

though it basically falls apart if you get too close. i imagine that is just the nature of "billboarding". i just don't render it if you get too close.

was it you dorbie i recall in the past? if so i think you might benifit everyone including yourself if you read posts more thoroughly. nothing personal just an observation.

well i'm finished with that subproject. it turned out very well i might add. some of the math was horrendous. but it should cut down modeling time significantly, especially because i am on scuedule to reparameterize a significant portion of the entire system

though it basically falls apart if you get too close. i imagine that is just the nature of "billboarding". i just don't render it if you get too close.

was it you dorbie i recall in the past? if so i think you might benifit everyone including yourself if you read posts more thoroughly. nothing personal just an observation.

well i'm finished with that subproject. it turned out very well i might add. some of the math was horrendous. but it should cut down modeling time significantly, especially because i am on scuedule to reparameterize a significant portion of the entire system

Cyranose

10-09-2003, 07:19 PM

Originally posted by opengl_enquirer:

yeah, that is essentially what i did. i don't know if you inferred that i misunderstood you. as for scaling you want to scale it up, not down. i presume the first replier typoed there.

Hmm. The first replier thought about it again and I'm sure what I wrote isn't very clear, but that's actually what I meant and it's actually correct in my case. FWIW, I agree that in image space terms, the billboard might be larger. But that particular algorithm I half-described involved an interesting matrix math trick -- I transformed a 2D unit circle into an sphere's local object space but also transformed it by the perspective matrix. The result was a line-strip circle that sat on the surface of the sphere in 3D such that the camera saw that linestrip as a perfect silhouette. It was indeed smaller/closer (to the camera) than the circumference, as seen from a 2nd test camera, for example.

Anyway, I hope the billboard is working for you. Given your initial requirement about it being one pixel wide, that didn't seem like the right approach to me. When I've done something similar in the past, the billboard needed to be a conic section, a "tilted ring," not a sprite, to function correctly for all cases.

Avi

yeah, that is essentially what i did. i don't know if you inferred that i misunderstood you. as for scaling you want to scale it up, not down. i presume the first replier typoed there.

Hmm. The first replier thought about it again and I'm sure what I wrote isn't very clear, but that's actually what I meant and it's actually correct in my case. FWIW, I agree that in image space terms, the billboard might be larger. But that particular algorithm I half-described involved an interesting matrix math trick -- I transformed a 2D unit circle into an sphere's local object space but also transformed it by the perspective matrix. The result was a line-strip circle that sat on the surface of the sphere in 3D such that the camera saw that linestrip as a perfect silhouette. It was indeed smaller/closer (to the camera) than the circumference, as seen from a 2nd test camera, for example.

Anyway, I hope the billboard is working for you. Given your initial requirement about it being one pixel wide, that didn't seem like the right approach to me. When I've done something similar in the past, the billboard needed to be a conic section, a "tilted ring," not a sprite, to function correctly for all cases.

Avi

opengl_enquirer

10-09-2003, 08:43 PM

your right it is closer and smaller in reality, but as seen projected it is actully larger than its actual size. in other words if you simply project the hemispheric midpoint as you say then it will be smaller than what is seen, which is counter intuitive.

i would be interested in your suggestion if it halds true even at close range. if you can manage it i would prefer some source code to a verbal explanation.

before you go you mentioned a sprite... i didn't use any type of sprite. i don't really use the terminology of a billboard so i'm not aware of the baggage that follows it. but for what its worth i just think of it as a flat object transformed so that its z axis lies along the view vector.

like i said though i wiould apreciate some source code. i will check this thread a couple more times. but such a matter i cannot allow to become a large concern. besides the method i'm using suits my needs fine.

sincerely,

michael

i would be interested in your suggestion if it halds true even at close range. if you can manage it i would prefer some source code to a verbal explanation.

before you go you mentioned a sprite... i didn't use any type of sprite. i don't really use the terminology of a billboard so i'm not aware of the baggage that follows it. but for what its worth i just think of it as a flat object transformed so that its z axis lies along the view vector.

like i said though i wiould apreciate some source code. i will check this thread a couple more times. but such a matter i cannot allow to become a large concern. besides the method i'm using suits my needs fine.

sincerely,

michael

Cyranose

10-10-2003, 11:26 AM

Originally posted by opengl_enquirer:

i would be interested in your suggestion if it halds true even at close range. if you can manage it i would prefer some source code to a verbal explanation.

...

before you go you mentioned a sprite... i didn't use any type of sprite.

In 3D terms, "sprite" generally equals "billboard." Billboards sometimes have different axes, but they're mostly the same idea. Sorry for the confusion of terms.

On source code, this was work for a client (I do OpenGL consulting for a living). I can share the high-level knowledge and help people along but I don't own the code. If or when I get to finishing my own engine, I'm happy to write articles and post code. http://www.opengl.org/discussion_boards/ubb/smile.gif

Avi

i would be interested in your suggestion if it halds true even at close range. if you can manage it i would prefer some source code to a verbal explanation.

...

before you go you mentioned a sprite... i didn't use any type of sprite.

In 3D terms, "sprite" generally equals "billboard." Billboards sometimes have different axes, but they're mostly the same idea. Sorry for the confusion of terms.

On source code, this was work for a client (I do OpenGL consulting for a living). I can share the high-level knowledge and help people along but I don't own the code. If or when I get to finishing my own engine, I'm happy to write articles and post code. http://www.opengl.org/discussion_boards/ubb/smile.gif

Avi

Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.