# 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:
• Include some sort of arch. It can be as ornate as the Arc de Triomphe, or as simple as a Bower Bird nest.
• Include bump-mapped reflections. To bump-map a surface, you move the normal slightly, by a location-dependent normal perturbation. The typical way to do this is to sample a 3D noise texture at the world coordinates location, shift the read-in values from the range 0 ... 1 down to -0.5 ... +0.5, scale the noise down to a reasonable level, and finally add this to your current normal:
```     vec3 perturb=0.1*(vec3(texture3D(noisetex,vec3(hit_point)))-vec3(0.5));
normal=normalize(normal+perturb);```
It looks best if you apply the bump map both to the lighting (especially the specular highlight) and the reflections.
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.