Realtime 3D sky generation (Online Applet)

here is a WIP I am working on (with a trainee) to generate sky appearance in real time that we will soon use in our game.

note that it is still a WIP : some problems still appears in rendering and it is not yet fully optimized.

for each frame the Applet generate the five skybox texture, apply them to a skybox & render the frame

[url=http://demo.dzzd.net/Sky/]

http://demo.dzzd.net/Sky/
[/url]

What you cannot see online :

The current version enable to set a location on earth and a date to generate the sky with the correct sun location ( it should also soon put the correct clouds coverage of the selected area)

It can also generate the sky reflection map texture ( the one you may apply on reflective object : chrome/sea/etc…)

I kept adding more clouds and got:

Exception in thread "AWT-EventQueue-2" java.lang.ArrayIndexOutOfBoundsException: 257
	at SkyFactory.cloud(SkyFactory.java:324)
	at SkyFactory.clouds(SkyFactory.java:293)
	at SkyFactory.color(SkyFactory.java:242)
	at SkyFactory.updateTextureSides(SkyFactory.java:352)
	at SkyFactory.update(SkyFactory.java:539)
	at Sky.updateWorld(Sky.java:128)
	at Sky.keyPressed(Sky.java:268)
	at java.awt.Component.processKeyEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-2" java.lang.ArrayIndexOutOfBoundsException: 260
	at SkyFactory.cloud(SkyFactory.java:324)
	at SkyFactory.clouds(SkyFactory.java:293)
	at SkyFactory.color(SkyFactory.java:242)
	at SkyFactory.updateTextureSides(SkyFactory.java:352)
	at SkyFactory.update(SkyFactory.java:539)
	at Sky.updateWorld(Sky.java:128)
	at Sky.keyPressed(Sky.java:268)
	at java.awt.Component.processKeyEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "AWT-EventQueue-2" java.lang.ArrayIndexOutOfBoundsException: 270
	at SkyFactory.cloud(SkyFactory.java:324)
	at SkyFactory.clouds(SkyFactory.java:293)
	at SkyFactory.color(SkyFactory.java:242)
	at SkyFactory.updateTextureSides(SkyFactory.java:352)
	at SkyFactory.update(SkyFactory.java:539)
	at Sky.updateWorld(Sky.java:128)
	at Sky.keyPressed(Sky.java:268)
	at java.awt.Component.processKeyEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)
Exception in thread "Thread-12" java.lang.ArrayIndexOutOfBoundsException: 270
	at SkyFactory.cloud(SkyFactory.java:324)
	at SkyFactory.clouds(SkyFactory.java:293)
	at SkyFactory.color(SkyFactory.java:242)
	at SkyFactory.updateTextureSides(SkyFactory.java:352)
	at SkyFactory.update(SkyFactory.java:539)
	at Sky.updateWorld(Sky.java:128)
	at Sky.run(Sky.java:157)
	at java.lang.Thread.run(Unknown Source)
Exception in thread "AWT-EventQueue-2" java.lang.ArrayIndexOutOfBoundsException: 259
	at SkyFactory.cloud(SkyFactory.java:324)
	at SkyFactory.clouds(SkyFactory.java:293)
	at SkyFactory.color(SkyFactory.java:242)
	at SkyFactory.updateTextureSides(SkyFactory.java:352)
	at SkyFactory.update(SkyFactory.java:539)
	at Sky.updateWorld(Sky.java:128)
	at Sky.keyPressed(Sky.java:268)
	at java.awt.Component.processKeyEvent(Unknown Source)
	at java.awt.Component.processEvent(Unknown Source)
	at java.awt.Container.processEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.KeyboardFocusManager.redispatchEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.dispatchKeyEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.preDispatchKeyEvent(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.typeAheadAssertions(Unknown Source)
	at java.awt.DefaultKeyboardFocusManager.dispatchEvent(Unknown Source)
	at java.awt.Component.dispatchEventImpl(Unknown Source)
	at java.awt.Container.dispatchEventImpl(Unknown Source)
	at java.awt.Component.dispatchEvent(Unknown Source)
	at java.awt.EventQueue.dispatchEvent(Unknown Source)
	at java.awt.EventDispatchThread.pumpOneEventForFilters(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForFilter(Unknown Source)
	at java.awt.EventDispatchThread.pumpEventsForHierarchy(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.pumpEvents(Unknown Source)
	at java.awt.EventDispatchThread.run(Unknown Source)

this is a bug, something that it is not handled ( heu… do I mention that I was working with a trainee :stuck_out_tongue: ? you may also notice that the applet is continuously requesting focus )

A few glitches in the sky, but still, awesome!

theire are still two visibles bugs :

  • mapping on the skybox is not perfect (you can see skybox edge sometimes)
  • some artefact (strange points) appears on clouds when generating them (I suppose this is because rendering appear while clouds are generated)

Really nicely done (except for the glitch and out of bounds :))

we’ve gone further with this project :

  • moon added with real appearance ( phase & path ) based on location & time
  • sea also added

everything is dynamic : cloud cover, sun, moon, sea wave ( and can be rendered in realtime with 3DzzD in software mode )


http://demo.dzzd.net/Sky/SKYDYN.PNG

(online demo ASAP)