Raytracing Celestia renderer?

The place to discuss creating, porting and modifying Celestia's source code.
Topic author
tuomast
Posts: 5
Joined: 25.07.2008
With us: 16 years 3 months

Raytracing Celestia renderer?

Post #1by tuomast » 25.07.2008, 00:57

Hi,

I've been spending some time developing an open source raytracing engine, that is especially tailored for rendering planets. I was wondering if Celestia project could potentially have use for this kind of engine as an alternative
renderer?

earthsmall.jpg


Here is a small demo. You can move and zoom by moving the mouse while pressing buttons 1 or 2. Space pauses motion. Escape ends it. It shows a scene where there are some hundred planets like these:

scene.png


Requirements are Windows and OpenGL 2.0 compatible PCI-Express x16 display card.

Highlights:

- Platform independent C++ with SDL.
- Physical direct lighting and soft shadows from spherical light sources blocked by spheres.
- Lot's of high level optimizations: Gives nice fps on a modern dual core CPU and up.
- Adaptive anti-aliasing
- Texturing with bilinear filtering and normal mapping

Moon.jpg


Here is some additional screenshots at 1024x768:

Sun eclipse
North America

And finally development information at a raytracing forum.
Last edited by tuomast on 01.09.2008, 16:24, edited 3 times in total.

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Re: Raytracing Celestia renderer?

Post #2by ElChristou » 25.07.2008, 07:06

Your demo seems to be PC only... :(
What about atmosphere? Any screenshot?
Image

Topic author
tuomast
Posts: 5
Joined: 25.07.2008
With us: 16 years 3 months

Re: Raytracing Celestia renderer?

Post #3by tuomast » 25.07.2008, 17:28

Yeah, I only have a PC and Linux and Windows so only binaries for them from me.

Unfortunately I've not yet added any simulation of atmosphere effects.

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: Raytracing Celestia renderer?

Post #4by chris » 26.07.2008, 17:38

tuomast wrote:Hi,

I've been spending some time developing an open source raytracing engine, that is especially tailored for rendering planets. I was wondering if Celestia project could potentially have use for this kind of engine as an alternative
renderer?

I read the thread on the ray tracing forum, and it looks like you've been doing some nice work. I don't think that there's too much use for a ray tracer as an alternate renderer, however. It would be a great deal of effort to make sure that all features worked with both the ray tracer and the OpenGL renderer. The frame rates with software ray tracing are still quite low even with a high end CPU. And there are a few things that Celestia must draw which would be very difficult for a pure ray tracer. For example, it seems very difficult to ray trace a star field; traditional rasterization works much better for this.

But enough with the negative stuff . . . I do think that ray tracing can be useful in Celestia. It's already used to some degree--atmospheric effects are calculated with simple ray marching. Cloud shadows could be computed with a ray-sphere intersection test. A limited form of ray tracing may be useful for calculating more accurate eclipse shadows (I notice you've done quite a bit of work with sphere-sphere shadowing.) It might also be possible to use ray marching to improve the rendering of galaxies. In all of these cases, the ray calculations would be handled in shaders on the GPU. This is the appropriate place for ray tracing in Celestia. Would you be interested in pursuing any of these projects?

--Chris

earthsmall.jpg


Here is a small demo. You can move and zoom by moving the mouse while pressing buttons 1 or 2. Space pauses motion. Escape ends it. It shows a scene like this:

scene.jpg


This executable doesn't take use of a 3d card at all, but there is support for OpenGL blitting. The executable is compiled with GCC and Core2 target, but I hope it works on other systems too.

Highlights:

- Platform independent C++ with SDL.
- Physical direct lighting and soft shadows from spherical light sources blocked by spheres.
- Lot's of high level optimizations: Gives nice fps on a modern dual core CPU and up.
- Adaptive anti-aliasing
- Texturing with bilinear filtering and normal mapping

Moon.jpg


Here is some additional screenshots at 1024x768:

Sun eclipse
North America

And finally development information at a raytracing forum.[/quote]

Topic author
tuomast
Posts: 5
Joined: 25.07.2008
With us: 16 years 3 months

Re: Raytracing Celestia renderer?

Post #5by tuomast » 27.07.2008, 00:51

chris wrote:I read the thread on the ray tracing forum, and it looks like you've been doing some nice work.

Thanks. I think you have been doing great work with Celestia.

chris wrote:I don't think that there's too much use for a ray tracer as an alternate renderer, however. It would be a great deal of effort to make sure that all features worked with both the ray tracer and the OpenGL renderer. The frame rates with software ray tracing are still quite low even with a high end CPU.

I should have named this thread "CPU Celestia renderer?", for I'm not offering what is considered by an ordinary ray tracer. I understand the skepticism, however I wouldn't be quite so fast to dismiss the possibility. As for speed, I know it is fast enough now let alone in couple of years.

Would two different renderers need to support all the same features? Even if a render could initially just handle solar system level visualization, it would be pretty novel feature IF it enabled people with a modern dual core computers and weak graphics cards to get unprecedented visual quality. The strength of doing software graphics with a language like C++ is the relative ease and power of implementation.

chris wrote:And there are a few things that Celestia must draw which would be very difficult for a pure ray tracer. For example, it seems very difficult to ray trace a star field; traditional rasterization works much better for this.

I completely agree that there is no point in raytracing for example a distant star field. Actually I am using so far a combination of rasterization, raytracing and analytical shading to get best of all worlds. I use ray tracing for drawing perfect anti-aliased mathematical primitives like spheres and discs. That is accelerated by projecting the scene first on a buffer, which says what pixel to intersect with what primitives, which makes it fast. For shading not a single light or shadow ray is cast, it is handled with custom algorithms.

chris wrote:A limited form of ray tracing may be useful for calculating more accurate eclipse shadows (I notice you've done quite a bit of work with sphere-sphere shadowing.)

Yes, the sphere light blocked by sphere shadow support is I think most complete feature I have. It doesn't use or rely on any ray tracing though and I think the algorithm could be used with Celestia's GPU renderer. You need to however know where you are on a surface of object you are shading per pixel.

It works by first checking per object exactly, what spheres occlude other spheres. This scales to several thousands of spheres checked once per frame, so you can just feed all your planets in a solar system to it. Based on that it does per pixel analysis, that is very physically accurate: It's like looking at the sun and moon from a point on earth, making a 2d picture of what you see with sun and moon as circles and then deducing from those circles' position and overlap the amount of sun's area visible to your location behind the moon. Quite simple really and just a couple of lines of dot products and vector operations coupled with the final circle comparisons.

Other things Celestia might have use for is approximate algorithm for Lambertian diffuse lightness from a spherical light source. I assume the current algorithm assumes point light and does a simple dot product?

chris wrote:But enough with the negative stuff . . . I do think that ray tracing can be useful in Celestia. It's already used to some degree--atmospheric effects are calculated with simple ray marching. Cloud shadows could be computed with a ray-sphere intersection test. A limited form of ray tracing may be useful for calculating more accurate eclipse shadows (I notice you've done quite a bit of work with sphere-sphere shadowing.) It might also be possible to use ray marching to improve the rendering of galaxies. In all of these cases, the ray calculations would be handled in shaders on the GPU. This is the appropriate place for ray tracing in Celestia. Would you be interested in pursuing any of these projects?

I will be of help to you, if you want to add the above mentioned shadows in Celestia GPU renderer and perhaps I can offer other algorithms and ideas too, but that is all I can do to improve Celestia currently. Even the renderer I'm talking about will need more features before it would justify the work needed to add support for such a thing.

duds26
Posts: 328
Joined: 05.02.2007
Age: 34
With us: 17 years 9 months
Location: Europe

Re: Raytracing Celestia renderer?

Post #6by duds26 » 28.07.2008, 13:33

So does this mean you will learn about the celengine and opengl and contribute?

With it I mean celestia and it's celengine.
Last edited by duds26 on 15.04.2018, 20:52, edited 2 times in total.

Topic author
tuomast
Posts: 5
Joined: 25.07.2008
With us: 16 years 3 months

Re: Raytracing Celestia renderer?

Post #7by tuomast » 28.07.2008, 22:07

duds26 wrote:So does this mean you will learn about the celengine and opengl and contribute to it?

Unfortunately, no, when it comes to improving the OpenGL code. I can however give code for eg. above mentioned things, which someone who knows how and where to add it can easily do that. For example converting a shader algorithm from convenient C++ level with overloaded vector math operations to GPU ASM shader file is not something I want to spend any time with.

ElChristou
Developer
Posts: 3776
Joined: 04.02.2005
With us: 19 years 9 months

Re: Raytracing Celestia renderer?

Post #8by ElChristou » 29.07.2008, 07:07

What about self shadowing? I've see running some recent 3D games where shadows seems well detailed with a very high FPS... None of the technology used is based on raytrace?
Image

duds26
Posts: 328
Joined: 05.02.2007
Age: 34
With us: 17 years 9 months
Location: Europe

Re: Raytracing Celestia renderer?

Post #9by duds26 » 30.07.2008, 11:54

tuomast wrote:
duds26 wrote:So does this mean you will learn about the celengine and opengl and contribute?

Unfortunately, no, when it comes to improving the OpenGL code. I can however give code for eg. above mentioned things, which someone who knows how and where to add it can easily do that. For example converting a shader algorithm from convenient C++ level with overloaded vector math operations to GPU ASM shader file is not something I want to spend any time with.

Only meant the celengine and writing opengl code for it, not writing code for opengl.
Last edited by duds26 on 15.04.2018, 20:52, edited 2 times in total.

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: Raytracing Celestia renderer?

Post #10by chris » 30.07.2008, 15:56

ElChristou wrote:What about self shadowing? I've see running some recent 3D games where shadows seems well detailed with a very high FPS... None of the technology used is based on raytrace?

No current games use ray tracing for shadows. Most games use various techniques with shadow buffers: the scene is rendered from the point of view of the light sources, and the distance of the closest point to the light source is stored. This distance is then used to determine whether or not a point visible to the viewer can 'see' the light source. There are many embellishments of this basic technique.

Some other games use stencil shadow volumes, but I believe that the popularity of this approach is waning somewhat (though it may see a resurgence now that the algorithm can be performed completely in hardware with new graphics cards; with older graphics chips, it was necessary to do a lot of it in software.)

--Chris

Pirx
Posts: 9
Joined: 29.05.2007
With us: 17 years 5 months

Re: Raytracing Celestia renderer?

Post #11by Pirx » 20.08.2008, 18:26

Even if it's not (yet) possible to raytrace in realtime a raytracer renderer could still be usefull: The creation of movies!

You use Celestia with the normal renderer to record a camera path/scene setup, and afterwards a (standalone) raytracer renders a HDTV movie representing this track/record. I'd love it.

Just my 2 cents...

Regards, Pirx

Topic author
tuomast
Posts: 5
Joined: 25.07.2008
With us: 16 years 3 months

Re: Raytracing Celestia renderer?

Post #12by tuomast » 01.09.2008, 16:02

Hey all! I've updated my demo to run a great deal faster and there is also improved image quality. It is now a reasonable smooth experience at 1024x768 resolution on my E6400 Core 2 Duo CPU. It will work at full speed even with the cheapest GPU, that utilizes PCI-Express x16 bus and supports OpenGL 2.0.

Chris, If you have no objections, I think I might try to pass each frame from Celestia the planet and camera position data to the ray tracer and then just blend that output on GPU with what Celestia outputs without rendering planets. Should work fine, as there is 32-bit alpha channel, except that fonts and GUI will be rendered over.

chris
Site Admin
Posts: 4211
Joined: 28.01.2002
With us: 22 years 9 months
Location: Seattle, Washington, USA

Re: Raytracing Celestia renderer?

Post #13by chris » 04.09.2008, 18:03

tuomast wrote:Hey all! I've updated my demo to run a great deal faster and there is also improved image quality. It is now a reasonable smooth experience at 1024x768 resolution on my E6400 Core 2 Duo CPU. It will work at full speed even with the cheapest GPU, that utilizes PCI-Express x16 bus and supports OpenGL 2.0.

Chris, If you have no objections, I think I might try to pass each frame from Celestia the planet and camera position data to the ray tracer and then just blend that output on GPU with what Celestia outputs without rendering planets. Should work fine, as there is 32-bit alpha channel, except that fonts and GUI will be rendered over.

No objection at all--I'd be very interested to see the results!

--Chris


Return to “Development”