Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 16

Thread: Interesting cube mapping problem

  1. #1
    Junior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    New Zealand
    Posts
    147

    Interesting cube mapping problem

    Hi all, I am trying out some dynamic cube mapping and I've come to a complete halt.

    I don't know how to descirbe it really, and I don't have a webby site to put a screenshot on, but I'll try..

    If i look straight on to the sphere that is mapped, I can make out all the faces (xpos,zneg etc) and It looks like it is using the same texture for them all (so It kinda looks like a soccer ball with the indents). But when I move around it the image will change - So at any one time it is reflecting the right image, but none of the other faces are right.

    Gah, just gone and confused myself there, I may have to find somewhere to put a screenshot :P.

    Code :
    glViewport(0,0,texDepth,texDepth);
     
    	glMatrixMode(GL_PROJECTION);
        glLoadIdentity();
     
    	GLint base = GL_TEXTURE_CUBE_MAP_POSITIVE_X_ARB;
     
    	// Now set up a new perspective
    	// the fov must be 90
    	float fieldofview, nearclip, farclip;
    	getAspectRatio(fieldofview,nearclip,farclip);
     
    	gluPerspective(90, 1.0, nearclip, farclip);
     
    	glMatrixMode(GL_MODELVIEW);
     
    	for (int i = 0; i < 6; ++i)
    	{
    		//Clear the depth buffer.
    		glClear(GL_DEPTH_BUFFER_BIT);
     
    		//Reset modelview matrix.
    		glLoadIdentity();
     
    		glTranslatef(pos.x,pos.y,pos.z);
     
    	//Rotate 
    	glRotatef(CubeRots[i][0], CubeRots[i][1], CubeRots[i][2], CubeRots[i][3]);
     
     
    		// Now render everything
    		(world)->Update();
     
    		glDisable(GL_TEXTURE_2D);
    		glEnable(GL_TEXTURE_CUBE_MAP_ARB);
    		glBindTexture(GL_TEXTURE_CUBE_MAP_ARB, cubemap);
     
     
    				glCopyTexImage2D(base + i, 0, GL_RGB8, 0, 0, texDepth, texDepth,0);
    		glDisable(GL_TEXTURE_CUBE_MAP_ARB);
     
     
    	}
     
     
     
    	// Reset THe window
    	setViewportPersp();
    Here are my texgens:

    Code :
    	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
    		glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_GENERATE_MIPMAP_SGIS, GL_TRUE);
     
    	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    	glTexParameteri(GL_TEXTURE_CUBE_MAP_ARB, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
     
    	glTexGeni(GL_S, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
    	glTexGeni(GL_T, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
    	glTexGeni(GL_R, GL_TEXTURE_GEN_MODE, GL_REFLECTION_MAP_ARB);
    I know it sounds confusing, but I was just wondering if anyone has had any odd occurances with CM and how they managed to fix it.

    [This message has been edited by robert (edited 01-13-2003).]
    I have no signature, so ill just write random nonsense here......

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Feb 2001
    Location
    Switzerland
    Posts
    1,840

    Re: Interesting cube mapping problem

    you can always upload on http://davepermen.net just click on free, and upload there, then copy the link(s) in here..

    didn't read the post yet, just seen you need webspace
    http://davepermen.net - if i could stay true to my heart, i would feel totally free

  3. #3
    Advanced Member Frequent Contributor
    Join Date
    May 2001
    Location
    Beloit, Wisconsin
    Posts
    562

    Re: Interesting cube mapping problem

    Originally posted by davepermen:
    you can always upload on http://davepermen.net just click on free, and upload there, then copy the link(s) in here..

    didn't read the post yet, just seen you need webspace
    Heh...
    You know what? I always figured you as mid 30's, and an American living in California...

  4. #4
    Senior Member OpenGL Guru
    Join Date
    Mar 2001
    Posts
    2,704

    Re: Interesting cube mapping problem

    I always figured you as mid 30's, and an American living in California...
    No; I've got a lock on that market :-)
    "If you can't afford to do something right,
    you'd better make sure you can afford to do it wrong!"

  5. #5
    Senior Member OpenGL Pro
    Join Date
    Feb 2001
    Location
    Switzerland
    Posts
    1,840

    Re: Interesting cube mapping problem

    hehe.. i'm currently watching futurama, and its 00:20.. and that at the parents home, where i still do live...

    not really what you expected, right?

    anyways, lets try to help the original topic

    one day, you know.. one day i get photos..
    http://davepermen.net - if i could stay true to my heart, i would feel totally free

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Melbourne,Victoria,Australia
    Posts
    767

    Re: Interesting cube mapping problem

    What you've got looks OK.

    Are you sure your values in "CubeRots" are correct?

    Perhaps the problem is not that it's reflecting the same side of the cube but that your textures are not oriented correctly? ie. Your +Z side is joined to your X sides on the -Z side of those faces...

    Try swapping your "+Z" and "-Z" to see if it makes a difference.

    I know I had a heap of trouble aligning the faces on my cubemaps (only to throw away the idea of dynamic cube maps because render-to-texture is toooooooo slooooooooow!

  7. #7
    Junior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    New Zealand
    Posts
    147

    Re: Interesting cube mapping problem

    Hey, thanks for the site

    I have uploaded the two pictures as: www.itstudents.ch/users/dave/free/files/screenshot4.jpg
    and www.itstudents.ch/users/dave/free/files/screenshot5.jpg

    It appears that the cube map is reflecting what the camera sees - fine, I could fix that but I don't understand why it is warping like that...

    [This message has been edited by robert (edited 01-13-2003).]
    I have no signature, so ill just write random nonsense here......

  8. #8
    Junior Member Regular Contributor
    Join Date
    Nov 2000
    Location
    New Zealand
    Posts
    147

    Re: Interesting cube mapping problem

    rgpc, I have tried that, but I might have missed something so I'll try again thanks.

    btw, davepermen nice site! Looks very professional.
    I have no signature, so ill just write random nonsense here......

  9. #9
    Advanced Member Frequent Contributor
    Join Date
    Apr 2000
    Location
    Melbourne,Victoria,Australia
    Posts
    767

    Re: Interesting cube mapping problem

    Looking at your screen shots it is definitely reflecting the same image multiple times...

    Just wondering, how do you draw your skybox? Presumably this is done using the "(world)->Update();" call.

    Can you show us the code that does this?

    It looks like the skybox is not rotated by the rotations in "CubeRots". (So naturally you would get the same image rendered 6 times)

  10. #10
    Senior Member OpenGL Guru knackered's Avatar
    Join Date
    Aug 2001
    Location
    UK
    Posts
    3,032

    Re: Interesting cube mapping problem

    I really like the idea of people being able to drop stuff onto your site like that, davep. Nice browser thing too. An improvement would be to enable people to attach a comment/link to each item they drop there.
    Knackered

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •