Ring shadows and programmable shading

General discussion about Celestia that doesn't fit into other forums.
Topic author
chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 23 years 3 months
Location: Seattle, Washington, USA

Ring shadows and programmable shading

Post #1by chris » 03.03.2004, 10:09

After reading the thread about the resolution of the ring shadow textures, I decided to go ahead an try an experiment and use pixel shaders to implement shadows on rings. I don't like the jagged edges apparent when using a low-resolution texture for the shadow. Here's what you get with a 256x256 texture:

Image

As several have pointed out, you can get much better results with a higher resolution texture. For this image, I used a 1024x1024 texture:

Image

It's much better, but the pixelated edge is still very apparent. And, it's wasteful--Celestia's using a megabyte for a texture that's nothing but a black circle. I could use an even bigger texture, but even at the max size of 4096x4096, ugly artifacts at the edge of a sharp shadow would still be apparent.

Newer graphics hardware (GeForce FX and Radeon 9500+) allows you to download small programs called shaders that are run at every pixel. Planet shadow textures are a perfect application for pixel shaders, since a circle (actually a cylinder, since we're dealing with a shadow volume) is so easy to describe procedurally. Here's the result:

Image

This shadow has a resolution that's effectively infinite (limited only by the precision of 32-bit floating point number on NVIDIA hardware, or 24-bit on ATI cards.) No shadow texture at all is required. I added a slight penumbra to the shadow not to hide an ugly shadow edge, but for realism: the sun is an area light source and Saturn's atmosphere scatters light
resulting in a soft edge to the shadow. When using textured shadows, Celestia had to create separate textures for several penumbra widths. There are four different ones for eclipses, depending on the relative apparent diameters of the sun and occluding planet discs. With pixel shaders, the penumbra width is just a pixel shader parameter so Celestia's no longer restricted to a fixed set of shadows. Eclipse shadows can be rendered more accurately and without using a byte of texture memory.

Pixel shaders also make it very easy to add the ambient light that was missing in shadows on rings.

Normal:
Image

Pixel shaders:
Image

It's not impossible to add ambient light with the textured shadows, but it's harder . . . I plan to do a lot more with pixel shaders in Celestia--better shadows are only the beginning.

--Chris

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 23
With us: 23 years 1 month
Location: Hamburg, Germany

Post #2by t00fri » 03.03.2004, 13:44

Brilliant!...and most promising for further applications.

Bye Fridger

JackHiggins
Posts: 1034
Joined: 16.12.2002
With us: 22 years 4 months
Location: People's Republic Of Cork, Ireland

Post #3by JackHiggins » 03.03.2004, 16:08

Truly rocking! :D

(Er.. I don't suppose a Geforce 4 MX could show these, could it?! I'm off to get a new card so...)

Any chance it would be possible to link this together with the improved atmosphere rendering you're planning (I remeber you saying Haze was only a temporary solution etc) so that the edges of these ring shadows could have a coloured tint...? Saturn's penumbra is orange as I remember.. I suppose this would help with recreating eclipses more accurately too! Um.. See a related post about this by me on http://216.231.48.101/forum/viewtopic.p ... highlight= as well..

Great work anyway chris!
- Jack Higgins
Jack's Celestia Add-ons
And visit my Celestia Gallery too!

Rassilon
Posts: 1887
Joined: 29.01.2002
With us: 23 years 3 months
Location: Altair

Post #4by Rassilon » 03.03.2004, 16:56

The same for eclipse shadows :)
I'm trying to teach the cavemen how to play scrabble, its uphill work. The only word they know is Uhh and they dont know how to spell it!

Avatar
t00fri
Developer
Posts: 8772
Joined: 29.03.2002
Age: 23
With us: 23 years 1 month
Location: Hamburg, Germany

Post #5by t00fri » 03.03.2004, 18:07

Chris,

I just compiled your new CVS stuff. The shadows are truly outstanding now!

Please note that 'make install' does not install the new shader routine under Linux! -> Trivial...

Bye Fridger

TERRIER
Posts: 717
Joined: 29.04.2003
With us: 22 years
Location: West Yorkshire, England

Post #6by TERRIER » 04.03.2004, 02:44

Beautiful new shadow rendering Chris, I really do hope as many users as possible will be able to view this.
1.6.0:AMDAth1.2GHz 1GbDDR266:Ge6200 256mbDDR250:WinXP-SP3:1280x1024x32FS:v196.21@AA4x:AF16x:IS=HQ:T.Buff=ON Earth16Kdds@15KkmArctic2000AD:FOV1:SPEC L5dds:NORM L5dxt5:CLOUD L5dds:
NIGHT L5dds:MOON L4dds:GALXY ON:MAG 15.2-SAP:TIME 1000x:RP=OGL2:10.3FPS


Return to “Celestia Users”