Sign in to follow this  

Spheres with pixel shader?

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

Hello, Im wondering if any of you could help me with a little problem. I need to create a scene with lots of perfectly round spheres. Target platform is kind of old, so im thinking that polygon approach is out of the question. Could this be done with planes facing the camera and a pixel shader to make planes look like spheres? Could you maybe point me to direction where i can find an algorithm to map lit 3d sphere to 2d surface? And do you think this approach would be fast enough for some GeForce2 cards, when I need to render about 500 - 1000 spheres (taking about 20% of screen surface)? Thanks in advance.

Share this post


Link to post
Share on other sites
Maybe look into 'imposters'. Basically you draw a complex object to a texture and use this cached texture to draw the object in the world. You therefore only need to update the imposter infrequently rather than drawing it every frame. Depending on your lighting setup, you might be able to reuse the same imposter for several spheres in the world.

Share this post


Link to post
Share on other sites
It could be done, you could write a shader that used some parametric equation to draw and light a sphere (given only a quad).

Your best bet would be to draw a bunch of bump textures. A pre calculated normal map of a sphere. Draw a bunch of lit normal mapped quads all over the scene and *wahlah*.

The problem with this is if the spheres interesected they would simply over write each other. Unless you wrote the depth too.

Maybe you should use a hybrid system where spheres up close get drawn with geometry, and in the distance they are drawn with imposters.

Share this post


Link to post
Share on other sites
Sorry, target platform is directx 8.1 compatible, so its comparable to GeForce 4 cards... things move so fast that it's hard to keep up with the card models :)

I'll look more closely to imposters and normal map approach and do some tests. Thank you very much for your time.

Share this post


Link to post
Share on other sites
imposters are probably a good compromise here. The problem is that if quality is your primary concern you could still end up with resolution-dependent results. That is, if the texture mapped to the imposter is low resolution compared to the display it'll look blurry at best.

I doubt you'd get it for PS_1_4 or below, but ray-tracing would be perfectly feasible in later shader models and generate resolution-independent spheres. It's quite a cool trick, but you'll need some serious horsepower behind you [grin]

Jack

Share this post


Link to post
Share on other sites

This topic is 3811 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.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this