Sunday, April 5, 2009

Sunlight package for WorldWind Java

Here is the very first iteration of a sun light package for NASA WorldWind Java. It includes a custom tessellator for terrain shading, an atmospheric scattering based sky layer, a sun position calculator and a lens flare effect. Some of the code has been contributed by WWJ Forum member Michael de Hoog aka Omega.

Sun shading in WorldWind JavaTerrain shading

Download the sunlight package (Zip 33K). Unzip in the SDK examples package and run the sunlight.SunShading.java demo application.

Lens flare and atmospheric scattering in WorldWind JavaLens flare and atmospheric scattering

The demo application code will show you how to use the different components. Although this initial version works rather well, you may notice a couple issues. Dark or bright bands may show across the terrain in some places. The atmospheric scattering code is not optimal. It fails to produce a blue sky at ground level and the sky underlying geometry is too coarse to produce nice and smooth sunsets. The sun calculator reported position does not seem right either.

Lens flare and atmospheric scattering in WorldWind JavaSun occlusion


Enjoy!

9 comments:

Anonymous said...

Looks nice. Is this being added to the night builds any time soon?

Patrick Murris said...

It may be integrated into the SDK at some point but i can't tell if and when. Right now, we are more worried about sorting out the core components from what can be considered as extensions.

Anonymous said...

well, integrating the shading in an application was easier than I though, just change the default tessellator.

Shading [of course] slows down thing quite some.

But it would be great if the shader tesselator was as fast as the regular one when the light parameters are set to null; I noticed some slow down in comparison with the normal one.

Any clues?

Patrick Murris said...

I haven't noticed much of a slow down, but that does not mean there isn't.

The tessellator is doing extra work to compute the normals needed for shading - whether light is enabled or not. But it does that only once when creating a new terrain geometry tile. After that the normals are cached and passed to the GPU at draw time. However, if light is not enabled, the GPU will not do extra work on lighting.

Normal computation could be postponed until light is on and they are needed though.

Gopinath4uALL said...

how to place Lunar Crater names on moon image using java?
Which classes i need use to find that placenames(craternames) of particular LatLon on moon?
Please help me in this regard

Thanking You
Gopinath Avuku

Patrick Murris said...

Please post World Wind Java general questions to the World Wind Forum. You are more likely to get answers and others will benefit from the discussion.

bhealy said...

Hi there - a bit late to the party I know...but from what I can figure - this never made it to the general build...any way to get this code working on the latest version of the SDK ?

Patrick Murris said...

The SDK has evolved a lot since this code was written and it will probably need some ajustements to fit into the current release. Most of it is based on the 'regular' tesselator with the only addition of normal computation so it may not be that much work to port the old code.

My best suggestion is to ask on the World Wind forum. Maybe someone has done it already.

bhealy said...

Thanks Patrick will do that.