Archived

This topic is now archived and is closed to further replies.

bschwagg

reflection

Recommended Posts

its getting late and i had an idea.. draw the scene then save the pixels as a texture, use this as a mirror. Has this been done before? it must''ve... this is what I tried but it didn''t work, how would you go about doing it? i have rgba pixel format, 640x480 unsigned int tex; void * data; glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 640, 480,0, GL_RGBA, GL_INT, data); glGenTextures(1, &tex); glBindTexture(GL_TEXTURE_2D, tex); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_S,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_WRAP_T,GL_REPEAT); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_LINEAR); glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR); gluBuild2DMipmaps(GL_TEXTURE_2D, GL_RGB, 640, 480, GL_RGBA, GL_UNSIGNED_BYTE, data); glBindTexture(GL_TEXTURE_2D, tex); Am i not allocating space for the data, what type is it supposed to be in. anyways, time for sleep

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Yes, that''s a standard reflection technique.

Render your scene from the reflected viewpoint to a texture (or read the framebuffer back, as you did), clear the frambuffer, render your normal scene, and apply your reflection texture on the reflective surface. You can even modulate the reflection with a reflectivity map, or distort it (for water). It looks very nice.- AH

Share this post


Link to post
Share on other sites