• Advertisement


  • Content count

  • Joined

  • Last visited

Community Reputation

202 Neutral

About d0nuts

  • Rank
  1. I was able to re-run this on a different computer which gave me an error during linking:   So the problem was that my work group size of 64x64x1 was larger than the value of GL_MAX_COMPUTE_WORK_GROUP_INVOCATIONS which was 1536.    Still strange that it links successfully on the first computer with a GL_OUT_OF_MEMORY error during validation...
  2. I think the stats on http://store.steampowered.com/hwsurvey/ should help get you started on what the average person has.
  3. Hi opengl experts, I am trying out a compute shader for the first time to generate some terrain but I am getting GL_OUT_OF_MEMORY (error 1285) when trying to validate the shader. std::string compute_source = R"(         #version 430 core         layout(local_size_x = 64, local_size_y = 64) in;         struct TerrainPatch {             vec2 pos;             vec2 dim;         };         layout (std430, binding = 0) buffer InputBuffer {             TerrainPatch patches[];         };         struct TerrainVertex {             vec4 pos;             vec4 nor;         };         layout (std430, binding = 1) buffer OutputBuffer {             TerrainVertex vertexes[];         };         void main() {             vertexes[0].pos = vec4(patches[0].pos, 0.0f, 0.0f);         }     )";     const char* compute_source_chars = compute_source.c_str();     GLuint shader = glCreateShader(GL_COMPUTE_SHADER);     glShaderSource(shader, 1, &compute_source_chars, NULL);     glCompileShader(shader);     GLint shader_status = GL_FALSE;     glGetShaderiv(shader, GL_COMPILE_STATUS, &shader_status);     assert(shader_status != GL_FALSE);     GLuint program = glCreateProgram();     glAttachShader(program, shader);     glLinkProgram(program);     GLint link_status = GL_FALSE;     glGetProgramiv(program, GL_LINK_STATUS, &link_status);     assert(link_status != GL_FALSE);     {         GLenum error = GL_NO_ERROR;         while ((error = glGetError()) != GL_NO_ERROR) { // <-- this doesn't have an error             printf("OpenGL ERROR: %s\n", gluErrorString(error));             assert(false);         }     }     glValidateProgram(program);     {         GLenum error = GL_NO_ERROR;         while ((error = glGetError()) != GL_NO_ERROR) { // <-- this is giving error 1285             printf("OpenGL ERROR: %s\n", gluErrorString(error));             assert(false);         }     }   Am I missing something obvious?    
  4. Or can anyone help me understand the wording from this gpugems article:  
  5. Hey gamedev experts!   I am trying to figure out how to generate smooth normals from a heightmap using b-spline interpolation. I currently have smooth vertex heights working based on the code from this paper [see attached picture :D]. Is my understanding correct that in order to compute the gradient at a point, I need to recalculate the weights using the derivative of each of the weights on page 5 (so w0 = -0.5 * (1 - alpha)^2, etc), recalculate the offsets and weights (g0, g1, h0, h1 variables) in the exact same manner, do three more texture lookups at the newly calculate offsets (so fetch tex00, tex01, tex10), and then compute the partials by weighting across each individual dimension (float dydx = lerp(tex10, tex00, g0.y); and float dydz = lerp(tex01, tex00, g0.x) ?   Sorry for any confusion on my part and thanks for any help!    
  6. So the problem was using all of the EXT functions and variables instead of the normal ones (ex. glBindFramebufferEXT() instead of glBindFramebuffer() ).
  7. Hey everyone! I am working on rendering to textures and am running into some trouble with unbinding the framebuffer object.   Currently, I am generating a framebuffer object, creating two textures (one RGB and one DEPTH_COMPONENT24), attaching the two textures, checking the status which is okay, and then drawing while the framebuffer is bound. Inside of gDEBugger I can see that everything is being drawn to the textures just fine.   However, when I try to bind back to default buffer ( glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0) ) the textures get cleared to zero and everything that was drawn to the textures ends up back in the static buffers. Also, I have also tried binding two more empty textures to the framebuffer and everything gets moved to the new textures.   Any ideas why all that data would just jump ship?   I attached a before and after pictures for when I bind the textures to the framebuffer.
  8. OpenGL Sampling depth texture

    Awesome! Thank you!
  9. OpenGL Sampling depth texture

    Found it! Apparently there is something called cgEnableTextureParameter(). I don't understand why you would set a texture parameter but not have it enabled :/ But my question about the projection still stands!
  10. OpenGL Sampling depth texture

    Sorry for the confusion. Let me try rewording it. With the simplest shader just outputing a color, it fills the screen. But when I project the points by multiplying by the modelviewproj and check if they are within the bounds of the screen, only the top corner projects into this range. Am I misunderstanding something about projection?   And I tried this fragment shader with just pass-through texture coordinates and am still getting all black.   ShadowVisualDataPixelOutput ret; float depth = tex2D(depthTex, pdi.texture).x; if (depth == 0.0f) { ret.color = float4(0,0,0,0); return ret; } else { ret.color = float4(depth, depth, depth, 1); return ret; }
  11. OpenGL Sampling depth texture

    Thanks for the response!         I am rendering a single quad that should cover up the whole screen exactly. If I use a fragment shader that just outputs a single color, it fills the screen completely. But when I multiply the vertex coordinates by model view projection matrix, store them, and then check in the fragment shader if they are exactly the screen (0 < x < 720 and 0 < y < 480) only the top right half projects into this. I am misunderstanding something about the projection?     (0.5f, 0.5f) and (1.0f, 1.0f) also return 0. Maybe I am setting something up wrong:   // Creation glGenTextures(1, &depthTexture); glBindTexture(GL_TEXTURE_2D, depthTexture); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE); glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE); glTexImage2D(GL_TEXTURE_2D, 0, GL_DEPTH_COMPONENT24, width, height, 0, GL_DEPTH_COMPONENT, GL_FLOAT , 0); glBindTexture(GL_TEXTURE_2D, 0); ... // Attach to fbo glGenFramebuffersEXT(1, &depthFramebuffer); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, depthFramebuffer); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT, GL_TEXTURE_2D, depthTexture, 0); glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, colorTexture, 0);   checkStatus() <-- returns complete okay! // Bind to fbo, render scene once, then switch back to default   glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, depthFramebuffer); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderHWLoop(); glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0);   ... //switch to visualizing programs //eventually these get called   fragmentDepthText = cgGetNamedParameter(fragmentProgram, "depthTex"); cgGLSetTextureParameter(fragmentDepthText, depthTexture);  
  12. Opengl novice here so sorry ahead of time! Just hoping to get some questions answered about sampling textures. I was messing around with rendering a scene to textures so that they could be used later. I then wanted to make a shader to view a depth texture by linearizing the depth values and then just bliting it on screen using a single quad. I can see that everything is being drawn into the texture correctly through gDEBugger (debugger.png) but am having some trouble sampling it .   First, to render the texture I output a single quad covering the screen. Then in vertex shader I multiply by modelviewproj matrix and save the xy value. My understanding is this should perfectly match the screen coordinates but when I check these values I am only getting the top right corner (output.png).    Second, I always seem to get values of 0 when sampling my texture. I can see in the debugger data view that (0,0) has a value of like ~.9997. However I sample it, I always seem to get 0s. It is a floating point texture with GL_DEPTH_ATTACHMENT.   Here's the fragment and vertex shader code (my graphics card doesn't have geometry shader):     ShadowVisualDataOutput ShadowVisualVertexMain(ShadowVisualDataInput vdi, uniform float4x4 modelViewProj) { ShadowVisualDataOutput ret; ret.projv = mul(modelViewProj, vdi.vertex); ret.saved = mul(modelViewProj, vdi.vertex).xy; return ret; } ShadowVisualDataPixelOutput ShadowVisualFragmentMain( ShadowVisualDataOutput pdi, uniform sampler2D depthTex, uniform float camNear, uniform float camFar) { ShadowVisualDataPixelOutput ret; if (pdi.saved.x < 0 || pdi.saved.x > 720) { ret.color = float4(0,0,1,1); return ret; } if (pdi.saved.y < 0 || pdi.saved.y > 480) { ret.color = float4(0,0,1,1); return ret; } float2 lookup = float2(0, 0); float depth = tex2D(depthTex, lookup).x; if (depth == 0.0f) { ret.color = float4(0,0,0,0); return ret; } ret.color = float4(1,1,1,1); return ret; }     Thanks for any help ahead of time
  • Advertisement