PDA

View Full Version : more on cubemapping...



gunslinger
12-16-2003, 04:40 AM
ok i am a pain,
no doubt on that, but since i am stuck, i'll bother u once more. I have to make a nice app, consisting in radiosity and env maps. I am focusing on env maps, as for now.
I am not really advanced yet, but still i have that task to do... I am getting a bit confused on the cubemapping and texturing stuff.
Ok i have a nice skybox all around... now i make the cubemap: i take the 6 shots of the scene with 6 separate renders (no optimization for now, i just want to get the basics).
Now where the hell i store the rendered images? I kinda figure out that i need to convert them in a texture (somehow) and then sick the same texture on my reflective objects.
Now I have 6 different shots of the env, but i need to melt them in just one texture (spherical?).
I am completely lost. Here is the code that i am using:

void DynamycCubeMap()
{
glViewport(0,0,128,128);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();

gluPerspective(90,1.0,1,5000);

glMatrixMode(GL_MATRIX_MODE);

for (int k;k<6;k++)
{
glClear(GL_DEPTH_BUFFER_BIT);

glLoadIdentity();

glRotatef(CubeMapRots[k][0], CubeMapRots[k][1], CubeMapRots[k][2], CubeMapRots[k][3]);
RenderSkyBox();

glEnable(GL_TEXTURE_CUBE_MAP_ARB);

>now, i am using this global texture. I know
>that this way it doesn't work, still
>since i had no clue about how to make it
>correct, i left it as u can see.
>global-texID was dfined with a simple
>glTexGen(GL_TEXTURE_CUBE_MAP_ARB,global-texID);

glBindTexture(GL_TEXTURE_CUBE_MAP_ARB,
global.texID);

glCopyTexImage2D(GL_TEXTURE_CUBE_MAP_ARB,0,GL_RGB, 0,0,128,128,0);
glDisable(GL_TEXTURE_CUBE_MAP_ARB);

}

Reshape(global_width,global_height);


}

void Display ()
{
glPushMatrix();
DynamycCubeMap();
glPopMatrix();
glClear(GL_DEPTH_BUFFER_BIT);

glEnable(GL_TEXTURE_2D);

glPushMatrix();
glColor3f(1.0,1.0,1.0);
RenderSkyBox();
glPopMatrix();


glEnable(GL_TEXTURE_CUBE_MAP_ARB);

glPushMatrix();

//Enable cube mapping
glEnable(GL_TEXTURE_GEN_S);
glEnable(GL_TEXTURE_GEN_T);
glEnable(GL_TEXTURE_GEN_R);


glMatrixMode(GL_TEXTURE);

glBindTexture(GL_TEXTURE_CUBE_MAP_ARB,global.texID );
//BISOGNA CARICARE LA TEXTURE!!!!
glPushMatrix();


//Render the main sphere!
gluSphere(sphere, 6.0f, 64, 64);

glPopMatrix();

glMatrixMode(GL_MODELVIEW);
glPopMatrix();


glDisable(GL_TEXTURE_GEN_S);
glDisable(GL_TEXTURE_GEN_T);
glDisable(GL_TEXTURE_GEN_R);

glPushMatrix();

RenderSphere();

glPopMatrix();

glutSwapBuffers();
glutPostRedisplay();
}

this chunk was taken from the http://opengl.nutty.org
dynamic cubemapping demo.
I didn't use the full code
cause:
a) i am not working under win
b) actually i wanna UNDERSTAND
how this stuff works.

thank you everyone for the help...
just one more thing:
if u wanna help me, keep it simple i am (still) *really* lame http://www.opengl.org/discussion_boards/ubb/confused.gif

AdrianD
12-16-2003, 04:54 AM
it is already melted into a cubemap. you really need to understand cubemapping first. (if you would, you wouldn't ask this question)
google for cubemaps, cubemapping and ARB_texture_cubemap.

the NVIDIA developer site is also a good place to look for infos about it.(look at the older papers, it's an old feature)

Jan
12-16-2003, 05:50 AM
http://opengl.nutty.org/extensions/index.html

Check out the 4th program.

Jan.

Antorian
12-16-2003, 06:10 AM
May be:
http://developer.nvidia.com/object/Cube_Mapping_Paper.html

There is also a demo with source (ok it's running on Windows, but it could help)

Regards.

gunslinger
12-16-2003, 06:49 AM
thank you all
for the help!

following a bunch of google links i came across
this page:
http://developer.nvidia.com/object/IO_20010830_4778.html

it looks lame enough to be understood EVEN by me http://www.opengl.org/discussion_boards/ubb/wink.gif
if anyone of you has my same troubles, i suggest to give that a look...
Thanks again, my clock says 15,48: it is time to pack things and go home http://www.opengl.org/discussion_boards/ubb/cool.gif
regards all The Gunslinger

ps as usual all the folks who helped me just have to feel free to stop by and have a beer with me http://www.opengl.org/discussion_boards/ubb/wink.gif