[SlimDX] Stroke around a sphere?

Started by
11 comments, last by Decibit 14 years, 1 month ago
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]
Advertisement
Are you looking for billboarding (decal/overlay/2D) or for texturing (3D)?
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.
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.
How do I do that? (In regards to all of you). I am a beginner ;)
What API do you use, and how do you draw the sphere?
Do you use shaders?
How do you want the result to look?
I am using Managed DirectX, and I am drawing the sphere by placing the mesh of the sphere through the DrawSubset function.
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
Quote:Original post by Decibit
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


This is extremely interesting. I'm using SlimDX.

Are there any code examples? Could you show me how, somehow?
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.

This topic is closed to new replies.

Advertisement