• Advertisement

Frongo

Member
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

126 Neutral

About Frongo

  • Rank
    Newbie
  1. Ahh, I was hoping to avoid that quartic but I guess this is the only way to do it. Unfortunately that would be too expensive to implement in our particular project so I've come up with another (less math intensive) solution for the greater problem. I now know where to come for my math questions/problems. Thanks
  2. Hey guys, My problem is somewhat unique and I'm not really sure how to solve it in a non-iterative fashion: 1 - Given a starting point, ending point, and one control point for a bezier curve in 2D space, I need to find a point on the curve that is exactly at a given distance from the starting point of the curve. 2 - If there are multiple candidates (I believe there can be 2 at the most), I need to figure out which one comes first when walking through the path. [attachment=5914:bezier distance.jpg]
  3. I just switched my rendering to one render call with a texture buffer to hold the matrices and 1 interleaved VBO. I went from 9 fps to 11 fps. @rewolfer Good point. However I just changed it so that the VBO is set up only once but for some reason I didn't get any fps increase out of it. I just tried sending a single matrix to my shader instead of the texture buffer and drawing all 1600 models with that single matrix which brought me up to 15 fps. I also tried switching back to my original rendering method I used in 2.0 (send 1 matrix to shader, render model once, repeat 1600 times) with the same results (15fps). It seems that using buffers has a lot of overhead. I noticed that when I use them my desktop performance slows down a lot (graphical interface is just as laggy as my game). Switching to straight vertexattribarrays doesn't have the slowing effect on my desktop but the fps is way worse (1-2fps). I miss display lists...
  4. I'm using a GTX 285 on windows 7 64 bit. My rendering loop is as follows: float matArray[16 * 40]; test->SetModel(); for(int i = -20; i < 20; i++) { for(int p = -20; p < 20; p++) { tmp.Translation(i * 0.5f, 0.0f, p * 0.5f); matArray[((p + 20) * 16)] = tmp.members[0]; matArray[((p + 20) * 16) + 1] = tmp.members[1]; matArray[((p + 20) * 16) + 2] = tmp.members[2]; matArray[((p + 20) * 16) + 3] = tmp.members[3]; matArray[((p + 20) * 16) + 4] = tmp.members[4]; matArray[((p + 20) * 16) + 5] = tmp.members[5]; matArray[((p + 20) * 16) + 6] = tmp.members[6]; matArray[((p + 20) * 16) + 7] = tmp.members[7]; matArray[((p + 20) * 16) + 8] = tmp.members[8]; matArray[((p + 20) * 16) + 9] = tmp.members[9]; matArray[((p + 20) * 16) + 10] = tmp.members[10]; matArray[((p + 20) * 16) + 11] = tmp.members[11]; matArray[((p + 20) * 16) + 12] = tmp.members[12]; matArray[((p + 20) * 16) + 13] = tmp.members[13]; matArray[((p + 20) * 16) + 14] = tmp.members[14]; matArray[((p + 20) * 16) + 15] = tmp.members[15]; } uniformPos = glGetUniformLocation(ShaderManager::instance()->ProgramObject, "matArray"); glUniformMatrix4fv(uniformPos, 40, 0, matArray); test->RenderInstanced(40); } The functions used in the render loop are: GLvoid Model::SetModel() { glBindBuffer(GL_ARRAY_BUFFER, mpModelBuffers[0]); glBufferData(GL_ARRAY_BUFFER, nTriangles * 9 * sizeof(GLfloat), mpVertexArray, GL_STATIC_DRAW); glVertexAttribPointer((GLuint)0, 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(0); glBindBuffer(GL_ARRAY_BUFFER, mpModelBuffers[1]); glBufferData(GL_ARRAY_BUFFER, nTriangles * 9 * sizeof(GLfloat), mpNormalArray, GL_STATIC_DRAW); glVertexAttribPointer((GLuint)2, 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(2); glBindBuffer(GL_ARRAY_BUFFER, mpModelBuffers[2]); glBufferData(GL_ARRAY_BUFFER, nTriangles * 6 * sizeof(GLfloat), mpTexCoordArray, GL_STATIC_DRAW); glVertexAttribPointer((GLuint)8, 2, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(8); /*glBindBuffer(GL_ARRAY_BUFFER, mpModelBuffers[3]); glBufferData(GL_ARRAY_BUFFER, nTriangles * 9 * sizeof(GLfloat), mpTangentArray, GL_STATIC_DRAW); glVertexAttribPointer((GLuint)6, 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(6); glBindBuffer(GL_ARRAY_BUFFER, mpModelBuffers[4]); glBufferData(GL_ARRAY_BUFFER, nTriangles * 9 * sizeof(GLfloat), mpBitangentArray, GL_STATIC_DRAW); glVertexAttribPointer((GLuint)7, 3, GL_FLOAT, GL_FALSE, 0, 0); glEnableVertexAttribArray(7);*/ } GLvoid Model::RenderInstanced(int count) { ModelTable::instance()->triangleCount += nTriangles * count; glDrawArraysInstanced(GL_TRIANGLES, 0, nTriangles * VERTPERTRI, count); } @Danny02 I just tried to reduce the draw calls as you suggested by drawing 250 instances 6 times. The fps is the same. I'll start working on the approach you suggested now and report my results back here.
  5. I'm playing around with a small engine I built which I have recently converted from OpenGL 2.0 and GLSL 1.0 to 3.3 and GLSL 1.5. I was testing to see how many polygons I could render on the screen by rendering a 6008 triangle model 1600 times (9,612,800 triangles). With 2.0 I was using interleaved array inside a display list to draw. The rendering loop involved a for loop where I would create a matrix, send it to the shader, call display list, repeat 1600 times. The shader has nothing more than simple ambient diffuse and specular lighting. When I converted to 3.3, I couldn't use display lists or interleaved arrays anymore so I switched to using 3 VBOs and rendering using glDrawArraysInstanced. The loop consists of setting up 40 matrices, sending them to the shader, rendering 40 models, repeat 40 times. Before entering the loop, I set my buffers one time only. For some reason the 2.0 approach gets about 36 fps while the 3.3 approach only gets about 9 fps. Do these results make sense? Or is there something wrong with my engine?
  6. The problem is fixed, sort of... I'm guessing there is a bug in nvidia's display driver as my code works fine on driver version 257.17 and older. My setup is an EVGA GTX 285 on windows 7 x64. It would be interesting to see if anyone can recreate this freeze. All I have to do is put about 100 glutBitmapCharacter in a for loop to create this freeze in any program. I tried downloading nehe's bitmapcharacter sample and the same problem existed.
  7. Calculating Tangent and Bitangent

    I'm not sure calculating the tangent and bitangent per frame is really necessary. If you have your tangent and bitangent calculated on your model in its default pose, you should be able to multiply the default pose tangent and bitangent by your bone matrices the same way it is done with normals. I'm not sure what kind of artifacts this would produce, perhaps there is some more research to be done there. After you have your tangent and bitangent multiplied with your bone matrices, you could sample your tangent space normal map and convert it into a world space normal, then pass it to your post renderer. This approach would fit in nicely with your values you're already sending to your post renderer, and would avoid calculating your tangent and bitangent per frame.
  8. Hi guys, I'm having a very strange problem when using glutBitmapCharacter. When I use it, sometimes it will cause my game to lock up indefinitely. The lockup happens after displaying about 30 frames of the text. I found that the frequency of the lockups is somewhat dependent on how many characters I output. I have been able to make my game freeze by outputting as little as 14 characters, nothing below that though. The characters I output do not matter, I have tried just putting '3' as the character 15 times, resulting in a freeze. When my game freezes, I do a break all in visual studio. After doing a break all and continue 2 or 3 times, it does a soft break or something like that and stops inside my PeekMessage function. For some reason it gets stuck inside the actual PeekMessage function forever. My PeekMessage function looks like this: if(InSendMessage())// prevents deadlocks from not replying to threads outside of this one ReplyMessage(TRUE); while (PeekMessage (&msg, NULL, 0, 0, PM_NOREMOVE)) { if (!GetMessage (&msg, NULL, 0, 0)) { gExiting = true; break; } TranslateMessage (&msg); DispatchMessage (&msg); } The reason why I have the InSendMessage block is because I've heard it can fix this problem when messages sent from other threads don't get a return. Any suggestions?
  • Advertisement