Sky generation

Hi, I’ve been monitoring this forum for quite some time and has proven very educative. The demos and examples are a great source to start hacking with Xith3D.

What I have not found is a example on how to create a Sky box. I’m talking about a realistic sky, not backgound color. Does anyone has a small example on this? A pointer to a javadoc or tutorial would be enough.

Thanks

Just create a cube (or, for the more experienced, a sphere sectional) with a sky-ish texture applied to it. Try searching on google for skybox tutorial and you’ll see how it works in other APIs. The same methods would apply in Xith (they would just be easier to implement ;D).

A great writeup of it exists over at GamaSutra. Get an account on http://www.gamasutra.com then go to this article:
http://www.gamasutra.com/features/19981023/bell_01.htm

You might also want to use a Background node for this, I know endolf has an example…

Kev

/me has an excellent FPS camera class that would make a hell of a skybox demo ;D

Thanks a lot, I thought it had to be that way (using a huge box or sphere) - just wanted to know if Xith3D (or JOGL for this matter) had an artifact for sky rendering.

Well someone spent few minutes and made you something
Simple SkyBox:

http://www.users.xith.org/JavaCoolDude//JWS/Xith3D/SkyBox/SkyBoxicon.jpg

Keys: A,S,D,Q,W,E or left, right, up, down, page up, page down to control camera location.
Mouse to change viewing direction.
Source

Where are the textures from?

I found them somewhere on the web, you can get them at the .jnlp base directory though :slight_smile:

Already got them :slight_smile:

BTW, this is the same way FlyingGuns created it’s skybox. Creating textures for that is not that simple! Anybody has a good tool?

One small thing: the edges are clearly visible. I thinks this is due to filtering artifacts. This vanishes if you sacrifice 1 texel at each textures border:


      float offset = 1f / 512f;
      float tmin = offset;
      float tmax = 1f - offset;
    TexCoord2f     texCoords[] = new TexCoord2f[]{ new TexCoord2f(tmin, tmax),  //upLeft      0
                                                   new TexCoord2f(tmax, tmax),  //upRight     1
                                                   new TexCoord2f(tmin, tmin),  //bottomLeft  2
                                                   new TexCoord2f(tmax, tmin)}; //bottomRight 3

A second thing: the code does not compile due to a missing Class display.DisplayOptions. I tweaked it a bit.


      //    int parameters[]    =        new int[7];
        //screenWidth   =     parameters[0];
        //screenHeight  =     parameters[1];
        //canvasWidth   =     parameters[2];
        //canvasHeight  =     parameters[3];
        //refreshRate   =     parameters[4];
        //bitDepth      =     parameters[5];
        //fullScreen    = parameters[6]== 1;

      int                
      screenWidth        =                     0,
      screenHeight       =                     0,
      canvasWidth        =                   800,
      canvasHeight       =                   800,
      bitDepth           =                    32,
      refreshRate        =                     0,
      fps                =                     0;


    int parameters[]    =        new int[] {
        screenWidth,
        screenHeight,
        canvasWidth,
        canvasHeight,
        refreshRate,
        bitDepth,
        fullScreen ? 1 : 0
      };


//    DisplayOptions.showSettingsSelector("Select Screen Mode",
//                                        DisplayOptions.USE_XITH3D_ENGINE,
//                                        parameters);

A quick look at the .jnlp source code reveals the location of the missing displayOptions jar file
Here ;D
Nice catch on the edge artifacts thing though :wink:

Ok, just looked at the source.

Meanwhile I recognized that is NOT the way the skybox is made in FlyingGuns!

The problem with this box is, that it has to be HUGE (e.g. as big as the clip distance) in order not to occlude the other, non-skybox geometry.
And I’m sure, when having fog switched on, the skybox is fogged away?

There need to be some interaction with a thing like the Java3Ds Background node. Render the box first, don’t touch the Z-Buffer and such.

Hm hm … my first look into xith3d code now …

Lets assume that background geometry is defined within a unit sphere…


class CanvasPeerImpl
{
....

private void setViewForBackground(View view) {

        setProjection(view);

        gl.glMatrixMode(GL.GL_PROJECTION);
        view.getBackgroundTransform().get(trans);
        gl.glMultMatrixf(trans);
        gl.glMatrixMode(GL.GL_MODELVIEW);
        gl.glLoadIdentity();

    }

Switch Z-buffer off, farClip =1.0, nearClip=0.1 or so?

wow - and again wow - JCD & co. - you’re anticipating my needs
thanks for the code.

rmdire ::slight_smile:

Experts please comment: is a change in the xith3d backgroundhandling feasable/necessary/useful?

Make it compatible with/similar to Java3D?

Just imagine a skybox in the presence of fog.

I put together another demo that combines skybox + heightmap + FPS camera, here’s a recent screenshot

http://www.users.xith.org/JavaCoolDude/Pictures/terrain.jpg

I’ll be adding noise + lighting to it :slight_smile:

That’s great JCD!!

Thanks a lot

I updated my textured terrian demo to include a skybox. The texture sort of blows, but it employs the basic concept of skyboxing. Also keep in mind that skyboxes look much better on LARGE worlds.

Web Start
Source
Full Jar

http://users.xith.org/mike/Xith3DTerrainTest/ttd_screenshot.jpg

Looks nice, but you’ve got the texture seams visible along the edges of the skybox - does Xith have a CLAMP_TO_EDGE texture mode yet…?

[quote]Looks nice, but you’ve got the texture seams visible along the edges of the skybox - does Xith have a CLAMP_TO_EDGE texture mode yet…?
[/quote]
The answer is yes, but the idiot who wrote the demo forgot to put it in there. That guy should be strung up :wink:

Anyway, it’s fixed now. Download is still in the same place.


http://users.xith.org/mike/Xith3DTerrainTest/ttd_screenshot2.jpg

I’d love to try this… but it seems JOGL and webstart aren’t getting along.

java.lang.UnsatisfiedLinkError: /Users/scottpalmer/Library/Caches/Java Web Start/cache/http/Dusers.xith.org/P80/DMmike/DMXith3DTerrainTest/DMlib/DMjogl/DMmacos/RNjogl-macos.jar/libjogl.jnilib:
at java.lang.ClassLoader$NativeLibrary.load(Native Method)
at java.lang.ClassLoader.loadLibrary0(ClassLoader.java:1560)
at java.lang.ClassLoader.loadLibrary(ClassLoader.java:1469)
at java.lang.Runtime.loadLibrary0(Runtime.java:788)
at java.lang.System.loadLibrary(System.java:834)
at net.java.games.jogl.impl.NativeLibLoader$1.run(NativeLibLoader.java:60)
at java.security.AccessController.doPrivileged(Native Method)
at net.java.games.jogl.impl.NativeLibLoader.(NativeLibLoader.java:46)
at net.java.games.jogl.impl.GLContext.(GLContext.java:51)
at net.java.games.jogl.impl.macosx.MacOSXGLContextFactory.createGLContext(MacOSXGLContextFactory.java:52)
at net.java.games.jogl.GLCanvas.(GLCanvas.java:68)
at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:117)
at net.java.games.jogl.GLDrawableFactory.createGLCanvas(GLDrawableFactory.java:80)
at com.xith3d.render.jogl.CanvasPeerImpl.(CanvasPeerImpl.java:113)
at com.xith3d.render.jogl.RenderPeerImpl.makeCanvas(RenderPeerImpl.java:124)
at com.xith3d.render.jogl.RenderPeerImpl.makeCanvas(RenderPeerImpl.java:104)
at com.janusresearch.concept.Xith3DTerrainTest.init(Unknown Source)
at com.janusresearch.concept.Xith3DTerrainTest.main(Unknown Source)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:324)
at com.sun.javaws.Launcher.executeApplication(Launcher.java:844)
at com.sun.javaws.Launcher.executeMainClass(Launcher.java:804)
at com.sun.javaws.Launcher.continueLaunch(Launcher.java:682)
at com.sun.javaws.Launcher.handleApplicationDesc(Launcher.java:397)
at com.sun.javaws.Launcher.handleLaunchFile(Launcher.java:199)
at com.sun.javaws.Launcher.run(Launcher.java:167)
at java.lang.Thread.run(Thread.java:552)