Jump to content
  • Advertisement
Sign in to follow this  
Mathy

[SlimDX] Stroke around a sphere?

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

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 this post


Link to post
Share on other sites
Advertisement
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
Share on other sites
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?

Share this post


Link to post
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.

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!