• Advertisement

fahlen

Member
  • Content count

    6
  • Joined

  • Last visited

Community Reputation

122 Neutral

About fahlen

  • Rank
    Newbie
  1. Hi! I was wondering if anyone can spot what I'm doing wrong. When using the code below, I get black color back whenever I do a texture lookup. However, if I generate mipmaps for each face I get the expected image. The texture lookup is performed in GLSL doing textureCube(cubeMap, R).rgb where cubeMap is declared as samplerCube. I have a GeForce 6800GT and Linux graphics driver 1.0-7676 installed. Having the minification filter set to GL_LINEAR should make all texture lookups access only level 0 of the texture, especially as no texture lod bias is given in the textureCube call in the shader. I'd be very grateful for any input regarding what I may be doing wrong. GLuint createCubeMap(const CVector3& eye, unsigned int size) { GLfloat dirUpVecs[6][6] = { { 1.0, 0.0, 0.0, 0.0, -1.0, 0.0 }, { -1.0, 0.0, 0.0, 0.0, -1.0, 0.0 }, { 0.0, 1.0, 0.0, 0.0, 0.0, 1.0 }, { 0.0, -1.0, 0.0, 0.0, 0.0, -1.0 }, { 0.0, 0.0, 1.0, 0.0, -1.0, 0.0 }, { 0.0, 0.0, -1.0, 0.0, -1.0, 0.0 } }; GLuint cubeMap, rb, fb; // Initialize color cube texture ----------------------------------- glGenTextures(1, &cubeMap); glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMap); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MAG_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_CUBE_MAP, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_X, 0, GL_RGBA8, size, size, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_X, 0, GL_RGBA8, size, size, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Y, 0, GL_RGBA8, size, size, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Y, 0, GL_RGBA8, size, size, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_CUBE_MAP_POSITIVE_Z, 0, GL_RGBA8, size, size, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); glTexImage2D(GL_TEXTURE_CUBE_MAP_NEGATIVE_Z, 0, GL_RGBA8, size, size, 0, GL_BGRA, GL_UNSIGNED_BYTE, NULL); // Initialize depth renderbuffer ----------------------------------- glGenRenderbuffersEXT(1, &rb); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT24, size, size); // Assemble framebuffer object ------------------------------------- glGenFramebuffersEXT(1, &fb); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X, cubeMap, 0); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, rb); if (glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT) != GL_FRAMEBUFFER_COMPLETE_EXT) { cerr << "Framebuffer object not complete..." << endl; exit(1); } int viewport[4]; glGetIntegerv(GL_VIEWPORT, viewport); glViewport(0, 0, size, size); glMatrixMode(GL_PROJECTION); glLoadIdentity(); gluPerspective(90.0, 1.0, zNear, zFar); glMatrixMode(GL_MODELVIEW); // Generate maps for all 6 sides for (int i = 0; i < 6; ++i) { glLoadIdentity(); gluLookAt(eye.x, eye.y, eye.z, eye.x + dirUpVecs[i][0], eye.y + dirUpVecs[i][1], eye.z + dirUpVecs[i][2], dirUpVecs[i][3], dirUpVecs[i][4], dirUpVecs[i][5]); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_CUBE_MAP_POSITIVE_X + i, cubeMap, 0); draw(); } glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0); glDeleteRenderbuffersEXT(1, &rb); glDeleteFramebuffersEXT(1, &fb); reshape(viewport[2], viewport[3]); return cubeMap; }
  2. OK :) Thanks! I'll start testing this out. The tough part will be the generation of these cube maps, as I'd like to do this in 3ds max. But maybe it's not that difficult to write a max script that accomplishes this. Another thought I had was to generate a cube environment map for points along the streets, every so many meters, and then blend the results of texture lookups to the two closest such points, using the inverse distances as weights. But then, this would probably just lead to an undistinguishable reflection. The way to go is probably to do as you say, generate a cube map for every entity (building).
  3. Hi, I'm wondering if there's anyone who know's if it's possible to pre-compute reflection maps for window reflections in a city environment. Had it only been one single planar reflection as is the case with water, the extra rendering pass wouldn't matter. But in an urban environment there can be many planar reflective surfaces visible at once, even when all the windows in a single facade are condsidered a single surface. The reflections need not be completely accurate. Does anyone have experience of a similar situation?
  4. FBO & single depth texture

    It does seem one has to attach a color attachment for it to work. The code below gives me no errors: glGenTextures(1, &texture); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_INT, NULL); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glGenRenderbuffersEXT(1, &rb); glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, rb); glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_RGB8, 1024, 1024); glGenFramebuffersEXT(1, &fb); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_RENDERBUFFER_EXT, rb); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texture, 0); glDrawBuffer(GL_NONE); glReadBuffer(GL_NONE); checkFramebufferStatus(); Thanks.
  5. FBO & single depth texture

    Thanks for your reply. I'm not quite sure if I understand your suggestion though. The FBO only has one attachment, which is the texture and is a depth attachment. I've tried to allocate and attach a rendertarget, thinking that maybe a framebuffer object is incomplete having only a depth attachment, but I still get the same error. /Markus
  6. Hi, I'm working with a GeForce 6800 GT card and the installed drivers are Forceware 76.44. I'm having a problem using an FBO with a single depth texture attached. It gives me the error GL_FRAMEBUFFER_UNSUPPORTED_EXT. To initialize the FBO, I use the code below: glGenFramebuffersEXT(1, &fb); glGenTextures(1, &texture); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fb); glBindTexture(GL_TEXTURE_2D, texture); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_INT, NULL); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, texture, 0); checkFramebufferStatus(); Does anyone have any idea as to what I may be doing wrong? Any help would be greatly appreciated. /Markus
  • Advertisement