Author Topic: Alternative Sky method?  (Read 5893 times)

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Alternative Sky method?
« on: February 13, 2009, 01:50:00 pm »
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.

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: Alternative Sky method?
« Reply #1 on: February 14, 2009, 04:21:45 am »
So I have been thinking about this.

Currently one form of display would be this
Code: [Select]
   
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
Code: [Select]
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.

Offline EgonOlsen

  • Administrator
  • quad
  • *****
  • Posts: 12295
    • View Profile
    • http://www.jpct.net
Re: Alternative Sky method?
« Reply #2 on: February 14, 2009, 04:38:57 pm »
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....

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: Alternative Sky method?
« Reply #3 on: February 21, 2009, 05:52:17 am »
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

Offline paulscode

  • double
  • *****
  • Posts: 863
    • View Profile
    • PaulsCode.Com
Re: Alternative Sky method?
« Reply #4 on: February 21, 2009, 02:14:17 pm »
To solve the lighting problem in a one-world setup, you could use:
Code: [Select]
skyBox.setLighting( Object3D.LIGHTING_NO_LIGHTS );Then to give the sky it's own "ambient light" setting, you would use:
Code: [Select]
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:
Code: [Select]
skyWorld.getCamera().setBack( otherWorld.getCamera().getBack() );I suppose you could use:
Code: [Select]
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?

Offline .jayderyu

  • long
  • ***
  • Posts: 116
    • View Profile
Re: Alternative Sky method?
« Reply #5 on: February 21, 2009, 08:27:14 pm »
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.