Jump to content

This possible with LE 2.3


wayneg
 Share

Recommended Posts

Rendering with shadows and everything is pretty heavy for 10.000 boxes.

 

post-45-090740500 1285946817_thumb.png

 

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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?

Link to comment
Share on other sites

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

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

 

post-45-071487500 1285953702_thumb.png

Link to comment
Share on other sites

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Ryzen 9 RX 6800M ■ 16GB XF8 Windows 11 ■
Ultra ■ LE 2.53DWS 5.6  Reaper ■ C/C++ C# ■ Fortran 2008 ■ Story ■
■ Homepage: https://canardia.com ■

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...