Minecraft Clone

Previous topic - Next topic

Schranz0r

hi buddys
Want to write a "simple" Minecraft clone, called "Worldcraft" (working title).
I start a small test to see how fast GLBasic is on 3D without any tweeks in code :D
Just a flat 256x1x256...

if i look on the ground i have 30 FPS if i look far away it drops to 8-9 FPS !
Anyone knows a trick to increse the FPS/ Render FASTER!?

Code see attachment

[attachment deleted by admin]
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Slydog

#1
That's 256 x 256 cubes arranged as a plane!
That's 65,000 cubes * 12 polys is over 780,000 polys!

Does GLBasic have built in frustum culling?

I see you used Front Face culling, which should save you half of the poly renders.

Try moving your X_SETTEXTURE to outside of your loop.
Ideally you will use the same texture image that contains all of your textures, and assigning the UVs manually.

Then if this is still too slow, you may need to get into creating your cubes by hand in code, but combining multiple cubes into one object, say a 4x4x1 cube object and dynamically adding / removing polys as needed.
[Edit]
What I mean is that each 4x4x1 area will be a separate 3d model dynamically created, then only changes need to be done on the edited block of cubes.  You may be able to increase this quite a bit, like up to say 32x32x1.  Don't calculate each block of cubes each frame.

Ideally, you only NEED (256 + 1) vertices by (256 + 1) vertices * 2 to describe what you see, as the other faces are blocked by the sides of the other cubes.  So try finding patterns maybe to dynamically create only the polys needed, but this will get very complicated and may be slow to calculate.

Also, maybe setting a limit on how far you can see could help, using the Far Clip value in X_MAKE3D.

But wow, I can still predict it being slow.  Would love to see how far you can take this!
Is iPhone out of the question? ha!

[Edit]
What's the fastest shader out there?  That meets your minimum requirements that is.  What shader does GLBasic use by default, may be room for improvement.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Scott_AW

Actually I've been working with similar stuff, if you use a ray casting system that might work.

I've only worked with a basic single level ray cast, it scans out a single floor to detect if floor/walls are present.

Heres a lastest demo

Thats made with Evaldraw which has voxel rendering, but the map is composed of tiles.

I've started working on a GLBasic version, the raycasting bit at least.


And have been working on a way of rendering ortho square based voxels but it still needs some work.


Raycaster engine is based off of Ken Silverman's ray casting algorithm, although the tile data storage method I came up with.  Both projects are open source so I can share some code if you need anything.
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/

matchy


Slydog

#4
Hmm, now I think that Scott_AW might be on to something.

Ray casting is fast, but going beyond one level may be very difficult.
Damn, because the concept is relatively easy, and involves no 3D engine at all.

But, check this link, it's Ken Silverman's Voxlap page:
http://www.advsys.net/ken/voxlap.htm

Look at his Cave.exe screenshot, looks very much like Minecraft.
Each pixel would be a cube from Minecraft.
Except, Cave.exe uses solid colours for the pixels, and you would want to texture map those pixels instead.
But, it would be much faster and enable you to draw much larger worlds.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Schranz0r

Minecraft is 3D :D
No raycast or voxel!


It must give a trick to render that bunch of cubes fast...  :'(
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Schranz0r

Quote from: Schranz0r on 2010-Sep-29
Minecraft is 3D :D
No raycast or voxel!


It must give a trick to render that bunch of cubes fast...  :'(

OK a saw a indev video of Minecraft and on the top its says  for example: 7 chunks updatet!
The trick is to reduce the objects into chunks and maybe 56x56x56 if the far enough...
Anyone knows how to make this?!
current i have no idea  ;/
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Slydog

#7
Right, that's what I thought they did, as I suggested in my first post (my first [EDIT]).

So, if your world is 500x500x500, and your chunks are 50x50x50, it would take 10x10x10 chunks to fill your world.
Most chunks would be empty as they would represent the air and ground/cave data that has no exposed sides.
You would dynamically create each chunk (using X_OBJADDVERTEX) by adding faces that are visible on any side, not the entire cube.
So for example if you had a hole in a wall that exposes a face/side of the next chunk, but that face is the only visible face on that chunk, that chunk would only need that one face (2 polys, 4 vertices).

If you had a 50x50x1 wall or floor exposed (completely flat in this example), you would need to create a dynamic 3d model that has 51x51x2 vertices.  You need the sub-vertices (even though they don't extrude/indent) to define the UV index into your texture map for each cube face.

[Edit]
My bad, you would need more vertices because the sub-vertices can't be shared between neighboring cube faces since they refer to different locations in the UV map.  Each cube would need its own 4 vertices (one for each corner), so you would need 100x100x2 I think.

Each chunk in the world is created at the start of the level, and you only have to modify (or recreate) the current chunk that has just been edited.

You still maintain a 500x500x500 array to hold the world cube data, and use this to create your dynamic chunks.
You would calculate the world array locations for each chunk, and loop through the world array looking for exposed faces, then add those faces to your new chunk model. 

Checking for exposed faces should be easy, just check its immediate neighbor in the world array, if it's a solid cube type (not air or transparent), then ignore it.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Slydog

If GLBasic uses frustum culling, then only the chunks in the player's view would be drawn.
If not, you may need to create your own frustum culling algorithm so you only draw the required chunks.
My current project (WIP) :: TwistedMaze <<  [Updated: 2015-11-25]

Leginus

Could you not introduce some 3d fog to limit your viewing distance?

Schranz0r

No, we want to see far!
Fog comes on more then 512? :)
I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Kitty Hello

you can render the 6 viewing sides of such a huge cube to an offscreen sprite, and draw a big cube using that sprite for far-away-objects then.

Schranz0r

hmm... and if i walk around the perspective fails?

Gernot, how can i add a object to a another one?

I <3 DGArray's :D

PC:
AMD Ryzen 7 3800X 16@4.5GHz, 16GB Corsair Vengeance LPX DDR4-3200 RAM, ASUS Dual GeForce RTX™ 3060 OC Edition 12GB GDDR6, Windows 11 Pro 64Bit, MSi Tomahawk B350 Mainboard

Kitty Hello

you can't merge objects.

Scott_AW

What about using openGL commands directly?
Current Project, Orbital Contract Defense
http://gamejolt.com/games/adventure/code-name-ocd/9887/

BlackShadow now open source/resource(requires duke3d)
http://gamejolt.com/games/adventure/black-shadow-3d/9885/