HW3: Reflective Bump-Mapped Arch
2010, Dr. Lawlor, CS
481/681, CS, UAF
For this assignment, build an OpenGL program that raytraces a reflective, bump-mapped arch. Your program must:
Note that you can load up a 3D texture containing RGBA noise with:
int sz=32; /* RGBA 32 x 32 x 32 */
float *noise=new float[4*sz*sz*sz];
for (int z=0;z<sz;z++)
for (int y=0;y<sz;y++)
for (int x=0;x<sz;x++)
for (int chan=0;chan<4;chan++) {
float r=(rand()&0xfff)*(1.0/0xfff);
noise[chan+4*(x+sz*(y+sz*z))]=r;
}
gluBuild3DMipmaps(GL_TEXTURE_3D,GL_RGBA8,
sz,sz,sz,
GL_RGBA,GL_FLOAT,noise);
glTexParameteri(GL_TEXTURE_3D,GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_3D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D,GL_TEXTURE_MAX_ANISOTROPY_EXT,8);
delete[] noise;
If your compiler whines about a missing "gluBuild3DMipmaps", a GLU 1.3
function, you can get nearly equivalent results without mipmaps:
glTexImage3D(GL_TEXTURE_3D,0,GL_RGBA8,
sz,sz,sz,0,
GL_RGBA,GL_FLOAT,noise);
glTexParameteri(GL_TEXTURE_3D,GL_TEXTURE_MIN_FILTER,GL_LINEAR);
glTexParameteri(GL_TEXTURE_3D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
My version looks like this. I used a trimmed hyperbolic paraboloid quadric surface for the arch.