skybox mirrored?

Found a bug? Post here.
Post Reply
ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

skybox mirrored?

Post by ted » Sat 18. Aug 2012, 19:48

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
				 ImageData.load(Input.getInput("face0003.jpg")),
				 ImageData.load(Input.getInput("face0004.jpg")),
				 ImageData.load(Input.getInput("face0005.jpg")),
				 ImageData.load(Input.getInput("face0000.jpg")), 
				 ImageData.load(Input.getInput("face0002.jpg")),
		};

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: skybox mirrored?

Post by gunn » Sun 19. Aug 2012, 13:16

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/JOGLSkyBox.java
===================================================================
--- src-jogl/de/jreality/jogl/JOGLSkyBox.java	(revision 5477)
+++ src-jogl/de/jreality/jogl/JOGLSkyBox.java	(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)	{
 		jogltex.setImage(imgs[i]);
 	    Texture2DLoaderJOGL.render(gl, jogltex);

jReality core developer

ted
Posts: 57
Joined: Wed 25. Jul 2012, 22:53

Re: skybox mirrored?

Post by ted » Thu 23. Aug 2012, 10:47

Is this going into the SVN head? There's also the cylinder patch ( http://www3.math.tu-berlin.de/jreality/ ... ?f=7&t=622 )

Thanks

User avatar
gunn
Posts: 323
Joined: Thu 14. Dec 2006, 09:56
Location: TU Berlin
Contact:

Re: skybox mirrored?

Post by gunn » Thu 23. Aug 2012, 13:02

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.
jReality core developer

Post Reply