AggrorJorn Posted October 1, 2010 Share Posted October 1, 2010 Rendering with shadows and everything is pretty heavy for 10.000 boxes. RegisterAbstractPath("") Graphics(800,600) fw = CreateFramework() camera =fw.main.camera camera:SetPosition(Vec3(0,20,-20)) light = CreateDirectionalLight() light:SetRotation(Vec3(45,45,0)) camRotation=Vec3(0,0,0) MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2) HideMouse(1) prevPos = Vec3(0) cube = {} cube1 = {} cube2 = {} --main function while KeyHit(KEY_ESCAPE)==0 do if KeyHit (KEY_SPACE)==1 then for a = 0, 50, 1 do for b = 0, 100, 1 do cube[b] = CreateCube() cube[b]:SetPosition(Vec3(prevPos.x + 1,prevPos.y + 1,prevPos.z)) prevPos = cube[b]:GetPosition() end prevPos = Vec3(0,0,prevPos.z + 2) end prevPos = Vec3(0) for a = 0, 50, 1 do for b = 0, 100, 1 do cube[b] = CreateCube() cube[b]:SetPosition(Vec3(prevPos.x - 1,prevPos.y + 1,prevPos.z)) prevPos = cube[b]:GetPosition() end prevPos = Vec3(0,0,prevPos.z + 2) end end --Camera look gx=Curve(MouseX()- GraphicsWidth()/2,gx,10) gy=Curve(MouseY()- GraphicsHeight()/2,gy,10) MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2) camRotation.x = camRotation.x+gy /10 camRotation.y = camRotation.y-gx /10 camera:SetRotation(camRotation,1) --keys move = Curve(KeyDown(KEY_W)-KeyDown(KEY_S),move,10) strafe = Curve(KeyDown(KEY_D)-KeyDown(KEY_A),strafe,10) camera:Move(Vec3(strafe ,0,move)) fw:Update() fw:Render() Flip(0) end Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 1, 2010 Share Posted October 1, 2010 Use CopyEntity instead of CreateCube, it should be 1000 times faster. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
DaveLee Posted October 1, 2010 Share Posted October 1, 2010 Aren't they calling it "Minecrack" now due to it sucking time out of people's lives? I know better than to buy it! Quote Link to comment Share on other sites More sharing options...
Rick Posted October 1, 2010 Share Posted October 1, 2010 Does that say 10fps? I can hardly read it. That's from Lua also, so slight overhead. I would be shocked if CopyEntity really made it much faster. Aren't they calling it "Minecrack" now due to it sucking time out of people's lives? I know better than to buy it! Isn't that the goal of every game? Also, since the boxes are all the same size you could most likely manipulate 1 giant cube via adding/removing verts dynamically to simulate the shape of boxes from within one cube mesh.That would get better performance, but be more code to get it to work. Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 1, 2010 Share Posted October 1, 2010 There is no overhead in rendering with Lua, it's actually faster than C# because it does unwanted GC all the time for no apparent reason. With 10000 CreateCubes you have to render 10000 times more stuff than with CopyEntity, but since there is some overhead in the instancing on the GPU, it's only 1000 times faster. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted October 1, 2010 Share Posted October 1, 2010 Lua will be slower than C++. I didn't compare it to C#. Wouldn't you be rendering the same amount of triangles no matter how you create them? CopyEntity() would save memory but the drawing of all those cubes still has to be done. You move the instance to position z, draw it, then move it to position y, draw it. Same thing if you create new cubes right? It's just that the mesh data isn't shared, but has it's own memory storage. You still have to draw all the triangles. Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 1, 2010 Share Posted October 1, 2010 I think GPU instancing means that they use the VBO of the GPU, so it's handled completely different by the GPU than a big amount of polys. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 1, 2010 Share Posted October 1, 2010 I say lets test it out to see if this is really faster. But shouldn't either of these work? cube[b]= cube:CopyEntity(1) cube[b]= CopyEntity(cube,1) yes the fps is 10 on a 800 x 600 resolution. Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 1, 2010 Share Posted October 1, 2010 I just tested it, and I get 10 FPS with the CreateCube version, and 62 FPS with the CopyEntity version. Here's the CopyEntity version: require "scripts/constants/engine_const.lua" RegisterAbstractPath(".") Graphics(800,600) fw = CreateFramework() camera =fw.main.camera camera:SetPosition(Vec3(0,20,-20)) light = CreateDirectionalLight() light:SetRotation(Vec3(45,45,0)) camRotation=Vec3(0,0,0) MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2) HideMouse(1) prevPos = Vec3(0) cube = {} cube1 = {} cube2 = {} --main function gx=0 gy=0 cub=CreateCube() while KeyHit(KEY_ESCAPE)==0 do if KeyHit (KEY_SPACE)==1 then for a = 0, 50, 1 do for b = 0, 100, 1 do cube[b] = CopyEntity(cub) cube[b]:SetPosition(Vec3(prevPos.x + 1,prevPos.y + 1,prevPos.z)) prevPos = cube[b]:GetPosition() end prevPos = Vec3(0,0,prevPos.z + 2) end prevPos = Vec3(0) for a = 0, 50, 1 do for b = 0, 100, 1 do cube[b] = CopyEntity(cub) cube[b]:SetPosition(Vec3(prevPos.x - 1,prevPos.y + 1,prevPos.z)) prevPos = cube[b]:GetPosition() end prevPos = Vec3(0,0,prevPos.z + 2) end end --Camera look gx=Curve(MouseX()- GraphicsWidth()/2,gx,10) gy=Curve(MouseY()- GraphicsHeight()/2,gy,10) MoveMouse(GraphicsWidth()/2,GraphicsHeight()/2) camRotation.x = camRotation.x+gy /10 camRotation.y = camRotation.y-gx /10 camera:SetRotation(camRotation,1) --keys move = Curve(KeyDown(KEY_W)-KeyDown(KEY_S),move,10) strafe = Curve(KeyDown(KEY_D)-KeyDown(KEY_A),strafe,10) camera:Move(Vec3(strafe ,0,move)) fw:Update() fw:Render() Flip(0) end Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted October 1, 2010 Share Posted October 1, 2010 I just tested it, and I get 10 FPS with the CreateCube version, and 62 FPS with the CopyEntity version. Very interesting. Still doesn't seem like it helps all that much. 62 FPS with 10k cubes still isn't good. Once you start factoring in all the other gameplay stuff, characters, physics I think using cubes isn't viable to make the game. Taking shadows out I assume would help. Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 1, 2010 Share Posted October 1, 2010 62 FPS is only the starting camera position. When you move around you get FPS like 100, 400, 700, etc... So it's rather a classic level design issue, that the artist has to block polygons from the view (for example by putting a big wall in the scene) if there are too many polygons in one view angle. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted October 1, 2010 Share Posted October 1, 2010 In that case it seems valid then. Most of the cubes seem to be on top of other cubes that aren't visible anyway. Although I wouldn't put it past you to consider that 700+ fps only looking at a handful of cubes Aggro, when you move around even with CreateCube() and not CopyEntity() what kind of FPS do you get? Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 1, 2010 Share Posted October 1, 2010 More stats: CreateCube version: initial pos: 10 FPS moving backwards until most cubes are culled away due to view distance: 150 FPS moving backwards until all cubes are culled away due to view distance: 700 FPS CopyEntity version: initial pos: 62 FPS moving backwards until most cubes are culled away due to view distance: 550 FPS moving backwards until all cubes are culled away due to view distance: 700 FPS Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted October 1, 2010 Share Posted October 1, 2010 Would be interesting to see if there is any difference if that was in C++. I would assume there would be. Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 1, 2010 Share Posted October 1, 2010 No, the Lua main loop doesn't even take 1 FPS (1 FPS = 15ms) time. But I can try it to be sure. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 1, 2010 Share Posted October 1, 2010 CopyEntity has an amazing affect on the performance. The same scene renders with a camera range of 10.000 range around 120 fps in 800 x 600. Here is another image at 1400 x 900 with a lot more cubes. The camera range is 100.000 here so that should be more then enough. FPS is low but there must be enough boxes out there I think. The loop copies to 500.000 cubes in just about 2-3 seconds. With CreateCube the programm crashes when creating around 100.000 cubes. Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 1, 2010 Share Posted October 1, 2010 When you start to get moire-effects with cubes, you know you have quite a lot of cubes Next, if you want to make a minecraft for LE game, you should also use physics. Newton can handle around 1000 cubes with decent FPS. Bullet can handle about 4000. PhysX can handle about 8000. Havok can handle probably more than PhysX, but I haven't tested that yet (I have tested all the other physics engines though). It's not too hard to use another physics engine with LE, as you can just leave the newton world empty, since you need to call UpdateWorld or UpdateFramework anyway (due to memory eating issues (they might be caused by newton though)). And so you only need to write your own UpdateWorld function which positions all cubes according to the cube position, scale and rotation of Bullet/PhysX/Havok. You don't need anything else than cubes, so it's quite easy. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
AggrorJorn Posted October 1, 2010 Share Posted October 1, 2010 Have you implemented these physics systems with Leadwerks or are this other engines/third party apps? Quote Link to comment Share on other sites More sharing options...
Canardia Posted October 1, 2010 Share Posted October 1, 2010 I have tested them with the native demos which come with each physics engine, and looking at the code it seems very simple to get the rigid cube data to be used for mesh positioning. Each physics demo uses somekind of simple OpenGL rendering "engine" (basically just raw OpenGL commands) also, which is then not needed with LE. Quote ■ Ryzen 9 ■ RX 6800M ■ 16GB ■ XF8 ■ Windows 11 ■ ■ Ultra ■ LE 2.5 ■ 3DWS 5.6 ■ Reaper ■ C/C++ ■ C# ■ Fortran 2008 ■ Story ■ ■ Homepage: https://canardia.com ■ Link to comment Share on other sites More sharing options...
Rick Posted October 1, 2010 Share Posted October 1, 2010 I feel like you'd be better off manipulating the verts in code. If the blocks are all the same size I would think this wouldn't be an issue. Quote Link to comment Share on other sites More sharing options...
wayneg Posted October 2, 2010 Author Share Posted October 2, 2010 awesome, thanks for the response guys I appreciate it. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.