Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Is possible to get a block world ?

Author
Message
Delilah
12
Years of Service
User Offline
Joined: 18th Feb 2014
Location:
Posted: 18th Feb 2014 13:47
Hello everybody this is my first post in the forum, I'm watching engines at the moment doing experiments and I have knowledge about how to code in basic. But all the knowledge that I have is coming from the old quick basic in msdos...

Anyway I was playing this morning with the trial of darkbasic to see if it possible to create a block world in this engine. I know that is possible because I did the first array of blocks 100x100 but when I'm moving the camera in my computer I'm having 20 fps. My cpu is amd phenom II X4 965 and I have gtx 650 with 2gb ddr5 so I think my computer can move 1000 blocks more faster so probably my code is wrong. Because I did the code in the way that I know more or less from my old knowledge of basic. I would like to share the code because I can imagine that my way is totally obsolete in this engine.




And this is a screen with the low fps.

I know that I can create one block of 100x100x1 and the engine is going to be perfect but I don't want to loose block entities.
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 18th Feb 2014 20:42
Really you'd need to add some optimisation. Like, only have a cube where the block is visible - so blocks that are behind other blocks don't slow things down. There is a lot more you can do with that, but I don't have a lot of experience. I have done a test engine in DBPro for a mining game, and I'd say it'd definitely possible of making a nice looking engine. Might not be able to get massive draw distances, but you could make up for it in other ways. Personally I'd rather have nice smooth gameplay than really long vistas.

The other thing is you could instance the cube instead of creating it everytime... instanced objects render much quicker than 'fresh' objects. I think the best way is to have a bank of blocks, like every type of block in your game, but hidden. Then when you need a block, you can instance it from the 'parent' block.

The above should be easy enough to implement, and I'm sure it'll make a big difference.

I am the one who knocks...
Derek Darkly
14
Years of Service
User Offline
Joined: 22nd Sep 2011
Location: Whats Our Vector, Victor?
Posted: 18th Feb 2014 21:19 Edited at: 18th Feb 2014 21:19
Another option is Dark Occlusion. I haven't used it myself, but there's a free demo on the product page:
Dark Occlusion

janbo
17
Years of Service
User Offline
Joined: 10th Nov 2008
Location: Germany
Posted: 18th Feb 2014 22:38 Edited at: 18th Feb 2014 22:43
how to increase performance:
1•
1.1•Making the cubes out of 6 planes.
1.2•Only create the planes which have no neighbors.
2•
2.1•Make the world out of one object using vertex manipulation
2.2•Make the world out of chunks wich represents one object and load them in distance.
3•
3.1•Avoid crating things..reuse them once created.
3.2•Only render "planes" which are in view port and pointing to the camera

Of course you can ask me.
I made a game using such a block world..but developing it in AppGameKit now.
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 19th Feb 2014 04:56 Edited at: 19th Feb 2014 05:01
It is very possible. As mentioned above, optimization is the key.
The world should be divided into chunks of objects. Instead of rendering (16 * 128 * 16) objects, just render 1 object that consists of only the visible planes of each cube. You'll need to look into vertex manipulation as stated above. I create a memblock to hold all of the vertices of the triangles that make up the planes that make up the cubes that make up the chunk. And then create a chunk object from the memblock. Then, just repeat for each chunk that should be visible.

I utilize a large 3 dimensional array to hold the world's data: Dim worldData(worldSizeX, 128, worldSizeY) When updating a chunk, find the appropriate location inside the worldData array and check whether a block should be active or not. If it is, check the sides, the top, and the bottom. Make a memblock entry for each visible side of the block. Once you have done this for each block in the chunk, create the object and move onto the next chunk.

You may also want to look into lighting which may correspond with the texturing. It is best for the object to only use one texture instead of several. Several different textures will cause a slow down when rendering. I utilize an object FVF of 530 so that I can have two uv coordinates per object. One 512x256 texture holding both the block type textures, as well as the light. This way, I can store light info per each cube instead of having the huge slow down of needing actual shadows.



Everybody is a genius. But if you judge a fish by its ability to climb a tree, it will live its whole life believing that it is stupid.
Delilah
12
Years of Service
User Offline
Joined: 18th Feb 2014
Location:
Posted: 19th Feb 2014 09:18
Omg zeroslave your work is amazing, I need to start from the beginning I was thinking in the most simple way... and I'm watching that I need to write a full routine to optimize first of all. I'll dig a bit more in darkbasic... to see how to do....Thanks.
tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 19th Feb 2014 14:10
With that sort of idea. Dark occlusion will make a huge difference. The problem with the performance is that by creating a 100 by 100 grid out of blocks that's 10000 blocks. with 6 faces each that's 60000 faces that need to be rendered. What occlusion will do is it will exclude the faces that are hidden from being rendereds thus greatly reducing lag.

Can I ask is it a minecraft type thing you're going for? because preseumably you'll want to add a depth. so 100 * 100 * 100 eg. That's 6000000 faces. I beleive the best practice is having chunks of 15*15*100 and only loading the chunks that are in a certain proximity(distance between) to the player.

It's a daunting task to code but it will be worth it.

Cwatson
tiffer
20
Years of Service
User Offline
Joined: 6th Apr 2006
Location: Scotland
Posted: 19th Feb 2014 14:17 Edited at: 19th Feb 2014 14:19
As a starting point can I reccommend this tutorial?

http://files.thegamecreators.com/developer/dbpro/DBPro_Tutorial_6_Huge_Dungeons.zip

The tutorial shows how to build a dungeon out blocks and load in an optimised way. If nothing else it will give you an insight.

Cwatson

Login to post a reply

Server time is: 2026-07-07 06:24:10
Your offset time is: 2026-07-07 06:24:10