Marz Tierney

Members
  • Content count

    8
  • Joined

  • Last visited

Community Reputation

125 Neutral

About Marz Tierney

  • Rank
    Newbie
  1. OpenGL Opengl Vbo Errors

    YESS!!! I finished redoing most of my code, and putting only rendering in the main thread. I had a little bit of extra stuff in the rendering thread left, and after removing it it works the same as many other voxel like games i've been trying to make my game as smooth as. Thank you!
  2. OpenGL Opengl Vbo Errors

    Ahh thank you for your advice! It's very spefic to what I needed. Before reading this I already took the initiative to put the rendering just on one single thread, this seemed to improve it alot, ie it crashes less. What do you mean by super-optimizing indices? I put all my chunks into one single vbo, using indexes to the pointer array. Is it necessary to use sectors of vbos rather then just one? Yeah I read that its no use as opengl doesnt work well with threading 'that means that it's pointless to try to parallellize anything in the renderer, and instead focusing on optimizing hard on what the renderer has to do and lift some weight off of it'! I'm curious as too the occlusion, but that would require alot of updates to the vbos, is this what minecraft does? How it says chunk updates in its debug gui? Is it because it uses cpu useage and causes opengl to render less things, thus improving fps... It's just the calls of glBindBuffer are very expensive for time, so implementing these things and getting better fps has been a largely trial and error thing for me.
  3. Hey, I'm working on a minecraft-like voxel engine. I keep my block type information in chunks, before creating vectors, and then sending that information off into the GPU as a vbo. This was working fine, but after generating too many different vbo objects (well the pointer that you bind, with the buffer), the game kept crashing. I ignored this for a while, but i've fixed all my other bugs on my list, and this one needs to be addressed. In order to solve it, I tried running the game without drawing the VBOs, and it didn't crash after alot of time. So from this, I figured having too many vbos was the problem, then I read various things, and people seemed to agree on reducing the calls to bindBuffer, or shoving all your objects(Th into one vbo (ideally) before sending it off. The render information is static, so this shouldn't be too difficult. In order to solve it, I used indexes, and created just one vboPointer, then for every chunk I had, I just generated it in one of the indexes at a time. There can be anywhere from 30 to 1000 chunks loaded depending on the renderDistance. Also deleting the buffers seemed to cause it to crash too. So after some research, I figured this was because it releases the buffer position for any future use. I think I tried generating it again, and had no luck. I would like some clarity on vbo useage,[b] do vbo indexes work for large numbers[/b]? Has uanyone had the bg where multiple vbo objects don't work? What should be the best approach for this? Minecraft [b]uses display lists, but don't vbos give a performance boost[/b]? Also, I heard the calls to bindBuffer will take a fair amount of processing, so [b]is it better to bind these on a thread to completely reduce loading times[/b]? One possible solution is too use not one vbo per chunk (16x16x16 blocks), or one for all of them, but one per X-Z position or something like that. But it's very hard to debug vbo errors when I can't understand the problem. Feels like i'm just trying anything, not making any progress on this. class VboData { int[] quadLength; // Sizes of Arrays int vboIndex = -1; int maxIndex = 0; // Stores the total number of vbos in it int[] vboQuadID; int[] vboColorID; int[] vboNormalID; int[] vboTexID; boolean hasGenVbo = false; VboData() { //maxIndexTotal = maxChunks; quadLength = new int[maxIndexTotal]; } VboData(int maxIndex_) { maxIndex = maxIndex_; //maxIndexTotal = maxChunks; quadLength = new int[maxIndexTotal]; } void dumpMemory() { } int getQuadLength(int index) { if (maxIndexTotal > -1) return quadLength[index]; else return 0; } void genAllVBO() { if (!hasGenVbo) { println("Total: " + maxIndexTotal); vboQuadID = new int[maxIndexTotal]; vboColorID = new int[maxIndexTotal]; vboNormalID = new int[maxIndexTotal]; vboTexID = new int[maxIndexTotal]; gl.glGenBuffers(maxIndexTotal, vboQuadID, 0 ); gl.glGenBuffers(maxIndexTotal, vboNormalID, 0); gl.glGenBuffers(maxIndexTotal, vboTexID, 0); gl.glGenBuffers(maxIndexTotal, vboColorID, 0 ); hasGenVbo = true; } } void clearMemory(int vboIndex_) { /*if (quadLength[vboIndex_] > 0) { gl.glDeleteBuffers(1, vboQuadID, 0 ); gl.glDeleteBuffers(1, vboNormalID, 0); gl.glDeleteBuffers(1, vboTexID, 0); gl.glDeleteBuffers(1, vboColorID, 0 ); }*/ } void genAllVBOs(Vector vboVertex, Vector vboColor, Vector vboNormal, Vector vboTexture, int vboIndex_) { if (vboIndex_ < maxIndexTotal) vboIndex = vboIndex_; quadLength[vboIndex_] = vboVertex.size(); genAllVBO(); genVBO(vboVertex, vboNormal, vboTexture, vboColor); } void genVBO(Vector vboVertex, Vector vboNormal, Vector vboTexture, Vector vboColor) { int quadLength2 = vboVertex.size(); if (quadLength2 > 0 && vboIndex > -1) { int normalLength = vboNormal.size(); int texLength = vboTexture.size(); int colorLength = vboColor.size(); gl.glBindBuffer( GL.GL_ARRAY_BUFFER, vboQuadID[vboIndex] ); gl.glBufferData( GL.GL_ARRAY_BUFFER, quadLength2 * 3 * BufferUtil.SIZEOF_FLOAT, myVertex_to_float_buffer( vboVertex ), GL.GL_DYNAMIC_DRAW ); gl.glBindBuffer( GL.GL_ARRAY_BUFFER, 0); // This resets the gl pointer to the start gl.glBindBuffer( GL.GL_ARRAY_BUFFER, vboNormalID[vboIndex] ); gl.glBufferData( GL.GL_ARRAY_BUFFER, normalLength * 3 * BufferUtil.SIZEOF_FLOAT, myNormal_to_float_buffer( vboNormal ), GL.GL_DYNAMIC_DRAW ); gl.glBindBuffer( GL.GL_ARRAY_BUFFER, 0); gl.glBindBuffer( GL.GL_ARRAY_BUFFER, vboTexID[vboIndex] ); gl.glBufferData( GL.GL_ARRAY_BUFFER, texLength * 2 * BufferUtil.SIZEOF_FLOAT, myTexture_to_float_buffer( vboTexture ), GL.GL_DYNAMIC_DRAW ); gl.glBindBuffer( GL.GL_ARRAY_BUFFER, 0); gl.glBindBuffer( GL.GL_ARRAY_BUFFER, vboColorID[vboIndex] ); gl.glBufferData( GL.GL_ARRAY_BUFFER, colorLength * 4 * BufferUtil.SIZEOF_FLOAT, myColor_to_float_buffer( vboColor ), GL.GL_DYNAMIC_DRAW); gl.glBindBuffer( GL.GL_ARRAY_BUFFER, 0); } } } class RenderData { int vboIndex = 0; // It's position in the vbo array Vector vboVertex; Vector vboColor; Vector vboNormal; Vector vboTexture; RenderData() { vboVertex = new Vector(); vboColor = new Vector(); vboNormal = new Vector(); vboTexture = new Vector(); } void setMax() { //if (vboVertex.size() != 0) //quadLength = vboVertex.size(); } [b]void setIndex(int index) { if (index < maxIndexTotal && index > -1) vboIndex = index; }[/b] void clearMemory() { clearVectors(); /* vboVertex = null; vboNormal = null; vboTexture = null; vboColor = null;*/ } void clearVectors() { vboVertex = new Vector(); vboNormal = new Vector(); vboTexture = new Vector(); vboColor = new Vector(); } } void renderVBO(VboData vbo,Texture tex, int quadLength, int vboIndex) { //if (vbo.quadLength > 0) { //println(render.quadLength); if (isRenderVBO && quadLength > 0 && vboIndex > -1) { tex.enable(); tex.bind(); gl.glPushMatrix(); if (isShader) glsl.startShader(); // Enables opengl to draw vertex points from memory gl.glEnableClientState(GL.GL_VERTEX_ARRAY); gl.glEnableClientState(GL.GL_NORMAL_ARRAY); gl.glEnableClientState(GL.GL_COLOR_ARRAY); gl.glEnableClientState(GL.GL_TEXTURE_COORD_ARRAY); // Points to vertexes in memory [b] gl.glBindBuffer( GL.GL_ARRAY_BUFFER, vbo.vboTexID[vboIndex]);[/b] gl.glTexCoordPointer(2,GL.GL_FLOAT,0,0); [b] gl.glBindBuffer( GL.GL_ARRAY_BUFFER, vbo.vboColorID[vboIndex]);[/b] gl.glColorPointer(4,GL.GL_FLOAT,0,0); [b] gl.glBindBuffer( GL.GL_ARRAY_BUFFER, vbo.vboNormalID[vboIndex]);[/b] gl.glNormalPointer(GL.GL_FLOAT,0,0); [b] gl.glBindBuffer( GL.GL_ARRAY_BUFFER, vbo.vboQuadID[vboIndex]);[/b] gl.glVertexPointer(3,GL.GL_FLOAT,0,0); // Draws the vertexes from memory - hence why needed point gl.glDrawArrays(GL.GL_QUADS, 0, quadLength); // Resets the binded buffer gl.glBindBuffer( GL.GL_ARRAY_BUFFER, 0); // Ends the opengl drawing // Disables the client state gl.glDisableClientState(GL.GL_VERTEX_ARRAY); gl.glDisableClientState(GL.GL_NORMAL_ARRAY); gl.glDisableClientState(GL.GL_COLOR_ARRAY); gl.glDisableClientState(GL.GL_TEXTURE_COORD_ARRAY); if (isShader) glsl.endShader(); gl.glPopMatrix(); tex.disable(); } }
  4. Need Better Physics Engine in Game

    I need rotational collisions for skeleton/body physics, and also it's alot better if the cubes rotate... And yes Olof, i've read alot so far, and I realize there is alot of work that goes into physics engines, but I find if I make my own engine, it is easier for me to debug and modify. I know how versatile they are to use, but I don't think I need to implement all the features they have. The example i've looked at uses points and tests them in a feild, i'm not sure exactly because the dependencies are a little confusing, but im guessing the way to check basically would be to check all the points on a plane go through another plane? This mathematically makes sense, but would take alot more processing power. http://www.openprocessing.org/sketch/39230
  5. Need Better Physics Engine in Game

    Wow great links, they seem like just what I was looking for. I am well in it for the learning experience as well. 2D physics are very similar to 3D, my first 3D physics simulations were based directly off 2D. There is a lot of maths involved with getting the camera to work in opengl, it's possible, just hard haha. I was mostly working on data structures, loading on threads and world generation techniques before, and my physics engine (which I neglected) was based on older version off a 2d version of Daniel shiffman's physics examples I got my hands on in first year uni, something similar too: http://natureofcode.com/book/chapter-2-forces/ Ahh okay, I'll look into steam greenlight for publishing. Atm though I'm mainly interested in having my game on a site, so people could possibly beta test it, have you done this before? I also have a bunch of questions about graphics programming, I'm using VBO's for the cubes, trying to implement a simple light shader, or the reflective water like in Terasology! Well it seems I have a long and interesting road ahead. If I have any more questions I'll post them thanks for all the help!!
  6. Need Better Physics Engine in Game

    My goal does not involve using a physics engine, it involves building one. Game development is a hobby of mine, the features of a physics engine I need are not so far out of my grasp. I will find the answer if I spend more time on it. I'm a uni student after all with much free time. I've got experience in robotics too, so a physics engine also interests me. However I will try out some of the recommended physics engines in the mean time. Regarding your suggestion of getting my game out there, what is the best way to go about this? I'm guessing releasing a playable version online somewhere, have you done this before?
  7. Need Better Physics Engine in Game

    Yeah i've seen some of them libraries before, they look amazing, but i'de prefer to implement my own, for the experience mostly. I guess i'll have to search more for examples or explanations on how to implement a simple version of bullet physics. Im going for something like this: http://www.youtube.com/watch?v=eQMBGLMtdFE I just need to get a better way to do collisions.
  8. Okay, so this is my first Post, so please forgive me as I'm sure I won't be giving out enough information. I've been working on a project for some time now, and I'm trying to create a better physics engine, however physics is not my best subject. My game is similar to minecraft, there are static chunk objects, and physics objects. My main problem is that it seems very laggy, compared to other games, even with high fps. So i'm wondering if I [b]should be putting the physics step on a thread and just using the position data etc for the rendering[/b] in order to get better movement? Another problem is, [b]how do I do rotational collisions[/b]? Here is some of my code for collisions. [attachment=12348:townGen4.png] // This is for when a physics object when it hits the bottom of a block (static position) void collide(PVector loc_, float r_) { ... if (checkTop(loc_,r_,r_,r_)){ vel.y*= -bounce; loc.y = loc_.y + r_+h+teleport; hasCollide = true; } else if (checkBottom(loc_,r_,r_,r_)) { vel.y *= -(bounce); loc.y = loc_.y -r_-h-teleport; hasCollide = true; isOnGround = true; if (vel.y > -0.7 && vel.y < 0.7 && inBlockID == 0) { vel.y = 0; } ... } boolean checkTop(PVector loc_, float w_, float h_, float d_) { // Check Y axis collision if ( loc_.y + h_ > loc.y - h && loc_.y - h_ < loc.y - h && // Y top's edge is between Blocks borders loc.x < loc_.x + w_ && loc.x > loc_.x - w_ && (loc.z < loc_.z + d_ && loc.z > loc_.z - d_) ) return true; else return false; } boolean checkBottom(PVector loc_, float w_, float h_, float d_) { if ( loc_.y - h_ < loc.y + h && loc_.y + h_ > loc.y + h && loc.x < loc_.x + w_ && loc.x > loc_.x - w_ && (loc.z < loc_.z + d_ && loc.z > loc_.z - d_) ) return true; else return false; } Would I have to check all the points along a plane to see if it goes through another plane? as they would not be parralel. (The sides of an object) Also is there a better way to make sure a physics object doesn't clip through the block, besides setting its location outside of it? (loc.y = loc_.y + r_+h+teleport;)