Jump to content
  • Advertisement

DamonBlanchette

Member
  • Content Count

    12
  • Joined

  • Last visited

Community Reputation

100 Neutral

About DamonBlanchette

  • Rank
    Member
  1. DamonBlanchette

    depth reconstruction not working

    That's awesome, and you're welcome! I'm so glad I could help.
  2. DamonBlanchette

    depth reconstruction not working

    haha well then! Sorry it's been so long since I've replied, life has been insane for me lately. It looked to me like you needed four textures, one each for position, normal, albedo (not sure what that is), and depth. That would be three drawbuffers, since the depth doesn't need one. Oh but you're saying you are getting positions using the depth texture in the shader. Got it. I guess I do it differently, but what I'm doing works for my application. I just have an extra texture for positions, and then in the shader I throw whatever value gl_Vertex is into that texture. That gives the world-space position, so if you need some other position value it would be different for you. Okay just looked at your comment, you need view-space (or eye-space as some call it) position. I believe for that you do a vec4 position = gl_Vertex * gl_ModelViewMatrix in the vertex shader, pass position to the fragment shader, and put that value into the texture. I'm probably confusing you even more, sorry! That's just how I get vertex positions into a texture.
  3. DamonBlanchette

    depth reconstruction not working

    I do drawBuffers() exactly the same way you do actually. The depth definitely looks like it's working! If you need the positions too, all you should have to do is add that texture back, attach it to the same framebuffer, and change drawBuffers to output three instead of two, like GLenum modes[] = { GL_COLOR_ATTACHMENT0, GL_COLOR_ATTACHMENT1, GL_COLOR_ATTACHMENT2 }; glDrawBuffers(3, modes); and you'll have to change your shader to output position too.
  4. DamonBlanchette

    depth reconstruction not working

    Alright, I hope I'm not confusing you more than helping - I'm usually on here asking the questions instead of the other way around! The following is kind of a pseudo-code version of what I do for a framebuffer with more than one color texture: tex1 = createTexture(GL_RGB32F_ARB); tex2 = createTexture(GL_RGB32F_ARB); depthTex = createTexture(GL_DEPTH_COMPONENT); fbo = createFramebuffer(); fbo.bind(); fbo.attachTexture(tex1, GL_COLOR_ATTACHMENT0); fbo.attachTexture(tex2, GL_COLOR_ATTACHMENT1); fbo.attachTexture(depthTex, GL_DEPTH_ATTACHMENT); fbo.unbind(); That's really it. The textures are created a certain way, with these parameters: glTexParameteri(target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); if (type == GL_DEPTH_COMPONENT) { glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(target, GL_DEPTH_TEXTURE_MODE, GL_LUMINANCE ); } else { glTexParameteri(target, GL_TEXTURE_MIN_FILTER, GL_LINEAR); glTexParameteri(target, GL_TEXTURE_MAG_FILTER, GL_LINEAR); } glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE ); if (target == GL_TEXTURE_2D && type == GL_DEPTH_COMPONENT) { glTexImage2D(GL_TEXTURE_2D, 0, type, 1024, 1024, 0, GL_DEPTH_COMPONENT, GL_FLOAT, 0); } else if (target == GL_TEXTURE_2D && type == GL_RGB32F_ARB) { glTexImage2D(GL_TEXTURE_2D, 0, type, 1024, 1024, 0, GL_RGB, GL_FLOAT, 0); } The textures are attached to the framebuffer like this: glFramebufferTexture2D(GL_FRAMEBUFFER, attachmentType, GL_TEXTURE_2D, texID, 0); Where attachmentType is either GL_COLOR_ATTACHMENT# or GL_DEPTH_ATTACHMENT. Hope that helps! There might be a better way, but it's what works for me at least.
  5. DamonBlanchette

    depth reconstruction not working

    On a quick look, it appears you are still writing to 3 drawbuffers, but you actually removed that position one. I think what you need to do is change the GL_COLOR_ATTACHMENT2 to GL_DEPTH_ATTACHMENT since it's writing depth values. Or, take it out completely and draw to two color buffers instead of three. Then, the shader won't have to output depths at all (depths would automatically be written to the depth component texture outside of the shader). Also, are you checking your framebuffers for completeness after attaching the two textures and depth buffer? It would be something like this, which I got from the opengl.org wiki: status = glCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT); switch(status) { case GL_FRAMEBUFFER_COMPLETE_EXT: cout << "good"; default: HANDLE_THE_ERROR; } If none of this works I'll check my code and put it here so you can see what I'm doing.
  6. DamonBlanchette

    depth reconstruction not working

    I think I see what you're trying to do - it looks like creating a regular texture (with just the R value) and then putting the depth values into it with the shader. Things seem mostly okay. I don't use renderbuffers at all when I do this stuff, so I'm not sure. One thing I'd probably be doing myself is to not have a separate "position" texture for depth. You could just use the depth buffer to get to the depths in the shader. It would be a line for you like under where you create the textures, depth.create(); Then do the texture options like your other textures, but in glTexImage2D() instead of GL_R32F have GL_DEPTH_COMPONENT32 and instead of GL_RGBA have GL_DEPTH_COMPONENT. Then attach_to_frame_buffer would attach it with GL_DEPTH_ATTACHMENT instead of GL_COLOR_ATTACHMENT. Once you render the scene with that framebuffer attached, that depth texture should automatically contain the depths, which you could get to in the shader by having a uniform sampler2D for it. I got help from this page: opengl.org page but you wouldn't set drawbuffer and readbuffer to none since you want colors too. Also, incidentally to make sure, you glEnable(GL_DEPTH_TEST) right?
  7. DamonBlanchette

    Podcasts about graphics and game programming?

    Well then! There appears to be nothing. Perhaps I put this in the wrong forum! Maybe I'll be the one to start it. What would people want in a graphics podcast? Length? Topics? I guess an audio podcast about graphics sounds kind of like an oxymoron, but I would think the audience would be fairly large. I'm really gonna think about this... not that I have a lot of time since I'm finishing a Master's thesis, but I may do it just for the fun.
  8. DamonBlanchette

    depth reconstruction not working

    What's the opengl code you have to create the textures and attach them to the FBOs? For depth, you'll need to create that particular texture as a GL_DEPTH_COMPONENT. I didn't go all the way through that tutorial you linked to, but that could be your problem.
  9. Hi all, does anyone know of any graphics programming podcasts? There are gaming podcasts, comedy podcasts, science podcasts, and podcasts about pretty much everything else. However, I've had problems finding anything about graphics - things like news about graphics and game programming, maybe new algorithms and published papers, stuff like you'd see at SIGGRAPH, etc. Any ideas?
  10. DamonBlanchette

    FBOs: depth but no color

    I'll reply to my own post here to say I figured it out. While creating the textures, I was calling glTexParameteri(target, GL_GENERATE_MIPMAP, GL_TRUE); AFTER the glTexImage2D() function call. When I moved it above glTexImage2D(), everything started working. That caused no problems on the ATI card or drivers, but the nVidia card or drivers didn't like it. Amazing.
  11. Hi all, besides wishing I was at SIGGRAPH right now, I'm working on a project where I'm rendering things to a framebuffer object. Currently I'm getting depths to show up, but not color. Is there anything in particular that might cause this to happen? The color texture is a regular old GL_TEXTURE_2D with type GL_RGB32F_ARB. Of course the depth texture is GL_TEXTURE_2D and type GL_DEPTH_COMPONENT. I'm attaching both of them to the framebuffer with: glFramebufferTexture(GL_FRAMEBUFFER, attachmentType, texObj->getTexID(), 0); Where attachmentType is GL_COLOR_ATTACHMENT0 for the color texture and GL_DEPTH_ATTACHMENT for the depth texture. When I put those textures on a quad to view them, the color texture is always just black and the depth texture always shows up perfectly. I get no OpenGL errors. I've tried adding and removing the "EXT" from the end of the functions and constants, but that doesn't help. I've tried other texture types such as GL_RGBA8, GL_RGB32F, and GL_RGB16F_ARB. I'm running Windows 7, OpenGL 3.3, GLSL 3.3, and a nVidia GeForce 8600M GT video card. This exact same code worked just fine on a newer ATI card, but not on this slightly older (but only by a couple years) nVidia card.
  12. Hello! This is my first post to gamedev.net, though I've used it many, many times to figure out problems I've had (people here are awesome!). I hope someone can help with this one! I'm attempting to implement Chris Wyman's Adaptive Caustic Maps (ACM) algorithm for a larger project. The algorithm can be found on his site, about a third of the way down: http://www.cs.uiowa....wyman/pubs.html I'm currently having a few problems, and I hope I can explain enough here for someone to understand what's happening (so this may be a long post, sorry!). The biggest and weirdest is a thing where random pixels *outside* of my program's running window are turning random colors that appear and disappear while the program runs to go along with things that are happening, such as the text in this window showing up as I type. Some pixels inside the program window are doing the same thing too. When I quit the program the random pixels stay until I refresh the window where they reside (including the desktop itself). The exact line of code where this happens is a transform feedback query function call: glGetQueryObjectiv( queryID, GL_QUERY_RESULT_AVAILABLE, &yesorno); yesorno holds the result of a check for whether the query result I want is available in the first place. It's inside a loop that runs until said result is available. If I comment out this loop and just get the query result whether it's available or not with this line: glGetQueryObjectiv( queryID, GL_QUERY_RESULT, &primCount ); I still get the random pixels everywhere. primCount is supposed to hold the number of points drawn with this code that is just a few lines above the getQueryObject function: glBeginQuery(GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN, queryID); glBeginTransformFeedback(GL_POINTS); // Go ahead and draw glDrawArrays( GL_POINTS, 0, inputPrims ); glEndTransformFeedback(); glEndQuery( GL_TRANSFORM_FEEDBACK_PRIMITIVES_WRITTEN ); inputPrims is a VBO containing random vertex positions with x and y values between 0 and 1. It's created as part of the ACM algorithm with this code: glGenBuffers(1, &genericTraversalStartBuffer); int resolution = 64; float *causticStartPoints = (float *)malloc( resolution * resolution * 4 * sizeof( float ) ); for (int i = 0; i < resolution * resolution; i++) { int x = (i % resolution); int y = (i / resolution); causticStartPoints[4*i+0] = x/(float)resolution; causticStartPoints[4*i+1] = y/(float)resolution; causticStartPoints[4*i+2] = causticStartPoints[4*i+3] = 0; } glBindBuffer( GL_ARRAY_BUFFER, genericTraversalStartBuffer); glBufferData( GL_ARRAY_BUFFER, resolution*resolution*4*sizeof( float ), causticStartPoints, GL_STATIC_DRAW ); glBindBuffer( GL_ARRAY_BUFFER, 0 ); The inputPrims ID is set equal to the genericTraversalStartBuffer ID before drawArray() is called. That buffer generation code was straight copied from the Wyman's ACM code download. These vertices are fired using a geometry shader at a texture containing a refractive object's front and back-facing normals in a texture array. What "hits" the refractive object is supposed to be written out, and what doesn't hit gets thrown away. Regardless of the random pixels, I can see that the number of primitives written (i.e. what "hits" the refractive object) is always 100% of what's drawn, which points to the possibility that the texture containing the refractive object's normals is incorrect. However, I can look at it, and it looks just fine. Also however, as I said, it's in a texture array with one layer holding the front-facing normals and another layer holding the back-facing normals. Another of my problems is that when I look at the actual texture array, only one layer has data, and it looks like both sets of normals are on that one layer instead of separated out. This makes it seem like the texture is not being created correctly, but the shaders I'm using to create it are also straight from the ACM download code. Before anyone asks why I'm not using the ACM download code straight out as it is completely, there are a few reasons: the ACM part of the download on Wyman's site is combined with two other caustic mapping code bases (one for simple old-school caustic maps, which I did get working nicely about a month ago, and another with hierarchical caustic mapping code, which is a precursor to ACMs). Also, Wyman's code is completely built in with his own normal OpenGL code, classes, and functions. Also again he uses NV-specific transform feedback code, and I have an ATI video card, so I have to use the more generic OpenGL transform feedback functions. I know for sure my video card supports EXT_transform_feedback. Some info about my rig (a nearly brand-new 17 inch MacBook Pro) if it will help: OS: Windows 7 Video Card: AMD Radeon HD 6750M OpenGL version according to glGetString(GL_VERSION): 4.1.10428 Compatibility Profile Context GLSL version found with the same method: 4.10 Dev Environment: Visual C++ 2005 Express Windowing is done with SDL Hey now that I think about it, maybe SDL doesn't like transform feedback... anyone know anything about SDL and query objects/transform feedback? My apologies for the extremely long first post and thank you for any help!
  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!