# [SlimDX] Stroke around a sphere?

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

## Recommended Posts

How do I make a stroke (a line around) a sphere that I have the mesh of, and have already drawn onto the device? [Edited by - Mathy on March 15, 2010 9:04:46 AM]

##### Share on other sites
Are you looking for billboarding (decal/overlay/2D) or for texturing (3D)?

##### Share on other sites
You could rotate a transparent(apart from the Stroke) square around the sphere (with a common centre) and make the pixel shader draw non transparently where the distance from the centre = the radius of the sphere.

P.S. As an optimisation Square the radius and compare the squared distance.

##### Share on other sites
Another way, since a sphere is convex, you can draw all the edges where one neighboring face is facing the camera, and the other isn't. This will give you exactly the silhouette of the sphere.

##### Share on other sites
How do I do that? (In regards to all of you). I am a beginner ;)

##### Share on other sites
What API do you use, and how do you draw the sphere?
How do you want the result to look?

##### Share on other sites
I am using Managed DirectX, and I am drawing the sphere by placing the mesh of the sphere through the DrawSubset function.

##### Share on other sites
Here is a slightly modified quote from "The Orange Book":
A technique for drawing silhouette edges for simple objects requires drawing the geometry twice. First, we draw just the front-facing polygons using filled polygons and the depth comparison mode set to LESS. Then, we draw the back-facing polygons as lines with the depth comparison mode set to LESS OR EQUAL. This has the effect of drawing lines such that a front-facing polygon shares an edge with a back-facing polygon

##### Share on other sites
Quote:
 Original post by DecibitHere is a slightly modified quote from "The Orange Book":A technique for drawing silhouette edges for simple objects requires drawing the geometry twice. First, we draw just the front-facing polygons using filled polygons and the depth comparison mode set to LESS. Then, we draw the back-facing polygons as lines with the depth comparison mode set to LESS OR EQUAL. This has the effect of drawing lines such that a front-facing polygon shares an edge with a back-facing polygon

This is extremely interesting. I'm using SlimDX.

Are there any code examples? Could you show me how, somehow?

##### Share on other sites
Moving to graphics programming.

The technique you're looking for is often called "silhouette rendering". There are a lot of example techniques out there -- but do note that you're generally not going to be able to just lift somebody else's shader code and have it work in your own projects. You'll have to read about the technique and understand how it works. The same is true of your other query about glow shaders.

1. 1
2. 2
Rutin
20
3. 3
khawk
18
4. 4
A4L
14
5. 5

• 12
• 16
• 26
• 10
• 44
• ### Forum Statistics

• Total Topics
633760
• Total Posts
3013723
×