Jump to content
  • Advertisement
Sign in to follow this  
teebee

Spheres with pixel shader?

This topic is 4025 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
Advertisement
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
Although since you mention a GF2, shaders won't be an option since it doesn't support anything other than some simple texture environment settings.

Share this post


Link to post
Share on other sites
You can still do DOT3 texture mapping using the fixed function pipeline, though (if I remember correctly). Using that you can use the imposters approach.

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
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!