Page 1 of 1

skybox mirrored?

Posted: Sat 18. Aug 2012, 19:48
by ted
Is the skybox in SkyboxAndReflMapExample supposed to appear mirrored? It does. Not just the reflection, but the actual background appears mirrored compared to the original 6 photos.

I tried with TextureUtility.createCubeMap and TextureUtility.createReflectionMap, both give the same reflected result as

Code: Select all

		ImageData[] sides = new ImageData[] {
				 ImageData.load(Input.getInput("face0001.jpg")), // erect2cubic names

Re: skybox mirrored?

Posted: Sun 19. Aug 2012, 13:16
by gunn
If I look at a textured sphere from outside, and compare it to what a I see from inside, the images will appear to be reflected WRT each other. For example, text that is readable when viewed from outside will appear "backwards" when viewed from inside, since this is the same as if I am inside a store, look out the store window, and attempt to read what is written on the store window -- it appears reversed!

Cube maps are constructed in jReality based on the assumption that the images should appear correct when the cube is viewed from outside. If would probably be good if there were a rendering hint to flip this assumption, so that they appear correct for the inside viewer. But such a rendering hint does not currently exist.

The necessary code for the JOGL backend to implement this reversal is given by the following patch:

Code: Select all

Index: src-jogl/de/jreality/jogl/
--- src-jogl/de/jreality/jogl/	(revision 5477)
+++ src-jogl/de/jreality/jogl/	(working copy)
@@ -100,7 +100,7 @@
     gl.glLoadTransposeMatrixd(P3.extractOrientationMatrix(null, w2c, P3.originP3, Pn.EUCLIDEAN), 0);
     double scale = (cam.getNear() + cam.getFar())/2;
-    gl.glMultTransposeMatrixd(P3.makeStretchMatrix(null, scale),0);
+    gl.glMultTransposeMatrixd(P3.makeStretchMatrix(null, new double[]{-scale, scale, scale}),0);
 	for (int i = 0; i<6; ++i)	{
 	    Texture2DLoaderJOGL.render(gl, jogltex);

Re: skybox mirrored?

Posted: Thu 23. Aug 2012, 10:47
by ted
Is this going into the SVN head? There's also the cylinder patch ( ... ?f=7&t=622 )


Re: skybox mirrored?

Posted: Thu 23. Aug 2012, 13:02
by gunn
No, I'm not planning to put this directly into SVN since it would change existing behavior. For the time being that means you'll have to maintain the change in your copy of the code. I'll post again if an option is added to control this behavior.