Alternative Sky method?

Started by .jayderyu, February 13, 2009, 01:50:00 PM

Previous topic - Next topic

.jayderyu

On my searches through opengl 3d forums land I came across a posting about skyboxs. I was wondering if JPCT could support a similiar method.

The idea is that the skybox/dome wasn't very big. say a 4x4x4 box around the camera. All the other objects would sit in an appropriate places in 3d world. Wich would be outside of the skybox. The trick is that the objects would ignore the sorting and render over the skybox. This way you don't need to set anykind of large size for the skybox.

Now I don't know if this will make much of a difference in the grandscheme of sky boxes/domes, but I thought it would be an interesting experiment.

.jayderyu

So I have been thinking about this.

Currently one form of display would be this
   
buffer.clear(Color.blue);   // erase the previous frame
// render the world onto the buffer:
world.renderScene( buffer );
world.draw( buffer );
buffer.update();
buffer.displayGLOnly();
canvas.repaint();


what if

buffer.clear(Color.blue);   // erase the previous frame
skyWorld.renderScene( buffer );
skyWorld.draw( buffer );
world.renderScene( buffer );
world.draw( buffer );
buffer.update();
buffer.displayGLOnly();
canvas.repaint();


of course this would require 2 cameras. What's the point of all this.

Well i'v never played with skyboxes much. So I was thinking of using a different skybox rendering system to just play with elements like size, texture res relative to box distance.

EgonOlsen

There's no problem with rendering two worlds into one buffer, so that should work. You have to clear the zbuffer between the renders though. I think i remember a problem when using the multi threaded renderer and changing the fov in between, but as long as you don't do this, it should work fine. I did that myself once...maybe in the "advanced example", but i'm not sure....

.jayderyu

Thanks for your help. It works great. I also found a pretty good reason to use this method. Lighting. When I set the ambient light to low you can't see the sky. If it's too high it can be far to inapropriate for other objects, say space ships should be invisble on the dark side.

I'm sure there are other reasons, but it works.

The only hiccup was that I forgot to invert the skybox :P

paulscode

To solve the lighting problem in a one-world setup, you could use:
skyBox.setLighting( Object3D.LIGHTING_NO_LIGHTS );
Then to give the sky it's own "ambient light" setting, you would use:
skyBox.setAdditionalColor( skyBrightnessColor );

On the other hand, an advantage of the two-world setup is not needing to keep moving the sky-box to keep it centered on the camera.  Although you do still need to match the "sky-world" camera's rotation matrix to that of the first world with something like:
skyWorld.getCamera().setBack( otherWorld.getCamera().getBack() );
I suppose you could use:
skyWorld.setCameraTo( otherWorld.getCamera() );
But then you would have to move the sky-box like in the one-world setup.

Have you done any comparisons to see if there are any visual advantages/disadvantages between the two skybox methods?

.jayderyu

nope not yet. I'm still playing around with getting some of the other stuff up once. I get moving working I will start playing with the skybox some more.