View Full Version : ARGH!!!! Cube Envirnoment Mapping
04-03-2001, 12:09 PM
OK, my code is like this:
glTexGenf(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
glTexGenf(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
glTexGenf(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_NV);
update modelview with camera position
glBindTexture GL_TEXTURE_CUBE_MAP_EXT, texID);
Why do I keep seing the same thing in the model? I believe I have to do something to the texture matrix, right? what? and where in the code should I do that? Do I have to draw the model with normals or what?
04-03-2001, 12:42 PM
From Nvidia's site
"In theory, cube maps are view independent"
OpenGL's texture matrix is also very useful for manipulating cube map texture coordinates. The texture matrix can be used to rotate an (s,t,r) vector from one space to another. For example, if your cube map texture is oriented in world coordinate space, and M is the matrix transform that moves from world coordinates to eye coordinates, you can load the inverse of the affine portion of M into the texture matrix to rotate the eye-space reflection or normal vectors generated by GL_REFLECTION_MAP_EXT or GL_NORMAL_MAP_EXT back into world space.
I believe, you need to use the texture matrix to take account of the changing eye position. For simple demo's whereby the eye and object do note move, this is not necessary.
I haven't actually tried moving round an object to see if cube map appears correct or not.. (hmmm future example code there me thinks)
Hope this helps.
What exactly do you mean by the image not chnaging? Does it look right if you rotate the object?
04-03-2001, 03:58 PM
Check out my Cubic Environment mapping demo on my site, DelphiGL (http://delphigl.cfxweb.net).
I managed to figure this out using the texture matrix, check out the code in the glDraw function.
04-04-2001, 04:25 AM
I've almost a finished a C version, with viewpoint corrected dynamic cube mapping.
Really odd points.
1) It seems to crash rotating the Y component of the texture matrix.
2) Why do I have to render my environment upside down in order for the cube maps to be reflected correctly??
Should be sorted and uploaded to my website tonight at some point.
Looks quite good.
04-04-2001, 05:03 AM
All working well... except for one problem.
I'm using Win2k, Geforce 256, and Detonator 11.01
I get a crash on the following code.
//Put viewpoint correction here.
glRotatef(-yangle, 0.0f, 1.0f, 0.0f);
glRotatef(-xangle, 1.0f, 0.0f, 0.0f);
It crashes in glCallList when yangle is anything except 0.0f. The display list just has glNormal3f's and glVertex3f's in.
Anyone got any ideas?!?!
04-04-2001, 07:06 AM
Seems like I'm having a conversation with myself here. http://www.opengl.org/discussion_boards/ubb/smile.gif oh well..
I've found that it doesn't crash if I replace the display list call with a function that has the EXACT same code as was used to build the display list, but renders it in immediate mode.
WTF is up with that?? Why the hell would a display list care about me rotating the texture matrix in the Y? Very odd...
I can only think it's a driver bug.
P.S. How can I speedup glCopyTexSubImage2D? Will it go faster if I use bgr8 format for the cubemap instead of rgb8?
I'm using the SGIS auto mipmap thingy too..
04-04-2001, 12:44 PM
Are you using glEnableClient state when you create a display list? IF you are, it doesn't work in display lists.
That's all I could think of.
04-04-2001, 11:55 PM
No, I'm not doing that.. if it was a problem with the display list it wouldn't work at all. But it does. I can rotate the texture matrix in the X and it works. Only crashes when I rotate texture matrix in the Y.
Though it all works perfectly without display lists.
I'm not doing the rotate in display lists either. Just normal and vertex functions only.
04-05-2001, 12:31 AM
I've mentioned this to KRONOS before but go to :-
Here is some code that does it for you, even if you don't use C it is easy to adapt.
Basically, it takes the MODELVIEW MATRIX finds the inverse and applies it to the TEXTURE MATRIX, so the the texture matrix is always aligned with major axes, no matter where you are looking.
I adjusted the code so you need just two calls, one to align the cube map, then render the objects and one to clear up afterwards.
The only other thing I had to do was replace the cofactor function, to get detM.
The referring page :-
has a lot on environment mapping
04-05-2001, 01:37 AM
Cheers. It works fine now, as long as I avoid display lists.
I just 2 do rotations on the texture matrix, with negative values of the camera rotation values. Works fine.
No matrix messin' at all.
I'll be uploading my demo tonight to www.nutty.org (http://www.nutty.org)
source included of course.
04-06-2001, 11:56 AM
Very nice demo Nutty, are the floating cubes cubemapped as well?
For that display list problem, have you tried something like this?
DelphiGL( http://delphigl.cfxweb.net )
04-06-2001, 01:32 PM
Yes I tried swapping back to the modelview matrix prior to glCallList. No joy.
The cubes are just sphere mapped at the mo..
Thinking of changing them to statically mapped transparent cubes.. might make it more interesting... reflecting trasparent objects that is.. might see the picies of Jordan better too! http://www.opengl.org/discussion_boards/ubb/smile.gif http://www.opengl.org/discussion_boards/ubb/smile.gif
There'll be a new version up soon. I have to do it all at work though, cos I aint got my geforce 3 yet, and I only have a crappy intel 740 adapter at home! http://www.opengl.org/discussion_boards/ubb/frown.gif
P.S. Matt, Cass, any idea why modifying the texture matrix can cause a glCallList to crash in the driver? I can reproduce it everytime if you're interested.??
[This message has been edited by Nutty (edited 04-06-2001).]
04-07-2001, 07:49 AM
Hmm... In my cubic environment mapping demo I mess with the texture matrix and I call glCallList (for some of the shapes in the demo) and it doesn't crash on me.
Try and run it on your computer and let me know if it works when you have the supertoroid and superellipsoid shapes selected (mousewheel changes current one).
Man, a i740...thats oooold, better hope your GeForce3 gets there soon http://www.opengl.org/discussion_boards/ubb/wink.gif
DelphiGL ( http://delphigl.cfxweb.net )
[This message has been edited by jra101 (edited 04-07-2001).]
04-07-2001, 09:13 AM
I have a good guess as to why it is crashing. Please email me the app.
04-07-2001, 11:08 AM
Will do Matt.
This I740 thing is right poor, it wont even do sphere mapping properly. One of my demos that does 2 passes, 2nd with a sphere map, just has a static 2nd pass on this adapter. Very odd!!
Had no OpenGL support under 2K too, so I had to revert back to 98... bah http://www.opengl.org/discussion_boards/ubb/frown.gif
04-09-2001, 08:44 AM
sorry matt, I can't seem to make it crash anymore.
I took all the display list generation code out, and I dont have it anymore. I've tried putting a similar display list in, and it no longer crashes.
Powered by vBulletin® Version 4.2.2 Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.