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 / Any hope of a fix?

Author
Message
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 12th May 2012 03:14
Hi,
I've been reading the forum, and have seen posts that confirm what I've suspected for a while now, which is that DarkBASIC Pro is pretty fast when handling a few high polygon objects, but struggles when it comes to lots of low-poly objects. For example, it might run really fast when displaying 1 object with 10000 polygons. But displaying 5000 objects each with 2 polygons, it's likely to slow down a great deal. I'm wondering if this will ever be fixed? I'm hopeful, since it's really hindering the development of my game, a Minecraft clone. If you've ever played Minecraft, you'll know why this problem hinders my development... The cubes are very low-poly, but they're everwhere!
I have a feeling that a fix of this would probably require a pretty large rewrite of Darkbasic's internal engine, so isn't likely to happen. Is this right? Is there likely to be improvement?
Thanks for answers
Samkm
Neuro Fuzzy
19
Years of Service
User Offline
Joined: 11th Jun 2007
Location:
Posted: 12th May 2012 04:35
Quote: "The cubes are very low-poly, but they're everwhere!"

Yes but at the same time, it doesn't just create a ton of cubes. (6 quads per cube, 16*16*256 blocks per chunk, lets say 5*5 chunks loaded at once. That would be 9,830,400 quads!)

I've never written code like this myself, but what programs usually do in cases like this is only render (or try to only render) blocks that are currently in view. Sometimes you can skip the rendering of a whole chunk.

Also, you could try using instancing, that's a lot faster. If you don't need a voxel engine, use BlitzTerrain.

MrValentine
AGK Backer
15
Years of Service
User Offline
Joined: 5th Dec 2010
Playing: FFVII
Posted: 12th May 2012 07:01
zeroSlave
17
Years of Service
User Offline
Joined: 13th Jun 2009
Location: Springfield
Posted: 12th May 2012 08:03
I also think Minecraft utilizes voxels for the data, and then renders to polygons. The way the data is stored is much different than how typical objects are stored in memory.

I would also assume, as mentioned above, not all cubes are rendered, and in fact I would seriously doubt that even all the faces of each visible cube is rendered.

I would also, also assume that large chunks of cubes are considered individual objects instead of a chunk consisting of multiple objects.

Quote: "I have a feeling that a fix of this would probably require a pretty large rewrite of Darkbasic's internal engine, so isn't likely to happen. Is this right? Is there likely to be improvement?"

I doubt that Darkbasic will see this type of enhancement.

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.
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 12th May 2012 11:17 Edited at: 12th May 2012 11:31
Minecraft should be a sinch to make in DBPro. You only need an array of X/Y/Z, and you don't even need collision, because the cubes can be made to fit exactly in the array, so the array does the collision for you. If anything, Minecraft is probably one of the fastest games to make. It's a lot like a 3D breakout clone with the bricks.

Then by checking the array you don't even need to position blocks inside a built up object.

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 12th May 2012 15:44
And what if it is not Minecraft, but a Tropico-style game?

«It's the Shader, shader me this, shader me that»
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 12th May 2012 20:21
Never played Tropico. It looks pre-rendered 2D on plains. Probably 4 angles to choose from. So that would be arrays again.

SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 13th May 2012 00:36
Thanks for the responses guys!
(Long response coming, sorry)
I've already purchased Dark Occlusions, but I'm not using it at the moment, because as it currently is it seems to hinder more than help, since it hugely increases loading time (I do use the beginloading and finishloading commands).
It's odd, I consider myself a fairly advanced DbPro programmer who's been going for 3.5 years now, but I sometimes feel I've become stuck in a rut as far as coding knowledge has concerned, and I often use ineffiecient code, because I don't know any better. I can pretty much grasp the concept of your Array-based system Pincho, but honestly haven't the faintest clue where I should start, especially since data management/arrays are one of the things I don't know as much as I should about)
If you have some time, I'd really appreciate it if you could give me a snippet of code that shows me what you mean, and how to do it
I've tried instancing the object, because I know it's faster. However, I can't seem to retexture each object individually, so unfortunately means I can't use it.
Thanks for responses!
Samkm
Matty H
17
Years of Service
User Offline
Joined: 7th Oct 2008
Location: England
Posted: 13th May 2012 01:56 Edited at: 13th May 2012 02:06
Quote: "Hi,
I've been reading the forum, and have seen posts that confirm what I've suspected for a while now, which is that DarkBASIC Pro is pretty fast when handling a few high polygon objects, but struggles when it comes to lots of low-poly objects. For example, it might run really fast when displaying 1 object with 10000 polygons. But displaying 5000 objects each with 2 polygons, it's likely to slow down a great deal. I'm wondering if this will ever be fixed? I'm hopeful, since it's really hindering the development of my game, a Minecraft clone. If you've ever played Minecraft, you'll know why this problem hinders my development... The cubes are very low-poly, but they're everwhere!
I have a feeling that a fix of this would probably require a pretty large rewrite of Darkbasic's internal engine, so isn't likely to happen. Is this right? Is there likely to be improvement?
Thanks for answers
Samkm"


This is not a limit of DBPro, this will happen with any engine. One huge object with one texture will be tons faster than lots of separate objects.

What you want is to have all cubes that have the same texture be part of the same object and add/remove vertices when needed. Packing as many cube textures into one will also help, then your whole level could be one object. This is obviously harder to implement and you need to strike a balance with culling too, I don't use DBPro much but I'm pretty sure IanM's plug-ins might allow you to quickly manipulate objects in this way, can't say for sure though.

EDIT: If there is no way to add/remove vertices on the fly then you could create an object with 100 cubes with all vertices at 0,0,0 so you don't see them, when a new cube is added then just place the next eight vertices in the correct position. When you run out of cubes clone another(100 cube object) and repeat.

You could even create the objects needed in a modelling program and just manipulate the vertices, that would not be too hard.

Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 13th May 2012 03:08 Edited at: 13th May 2012 03:44
Quote: "If you have some time, I'd really appreciate it if you could give me a snippet of code that shows me what you mean, and how to do it. "


The idea is to divide the screen up into single units, and each unit represents a cube. If you make the cube size 1 then each space is part of the array. If x = 1 to 100 then that is 100 cubes in a line, just put a 1 in each array for x, and that is your collision. Positioning the cubes is the easy part. It is checking the player position as they move that is the important part. As the player moves you must translate their move coordinates into your grid system. If it takes the player 8 walk cycles to cross a box, then you only update the array every 8 walk cycles. But you must keep an eye on X/Y/ and Z all at the same time. You can use a single box collision routine in the players position located at the centre of the box that you are standing on, just to check where the player is in relation to the next box to make it easier. So when the player walks out of the box collision, you need to make a new array test. If the player is positioned at y10 then he is 10 cubes up. If the next space is 0 he can move, if it is 1 then there is a cube there. If Y9 is a zero the player drops down. The other important part gives you more speed is that the cubes are like dice, so have 6 sides, and the array can be checked so that if all six sides are 1, then you don't need to put a box there, it is hidden. You can only ever see 3 sides of a cube as well, so you could be really tight on speed by making boxes with just 3 sides on them.. I wouldn't bother, because your game will be fast enough with full boxes.

I don't have box code. I have 2D code (which is coded a bit differently to what you need), and I am working on something similar to this, and uses Icosahedron. It's so different to cubes that you wouldn't be able to use it.

mr Handy
18
Years of Service
User Offline
Joined: 7th Sep 2007
Location: out of TGC
Posted: 13th May 2012 11:26
Quote: "Never played Tropico. It looks pre-rendered 2D on plains."


I forgot to add 4: Tropico 4 is 3d island with lots of different buildings, people, plants and roads as 3d objects.

«It's the Shader, shader me this, shader me that»
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 13th May 2012 14:07
Ok, thank you Pincho and Matty.
This is a little scary... I feel very much out of my depth here, but I'm doing my best to make sense of this. After reading your posts about 3 times, they do make some sense to me. I'll play around with your ideas, and see what I can get to work. I suppose I could also use instancing as well if I created one architypal cube for each block texture, and used instancing on them.
Jimpo
21
Years of Service
User Offline
Joined: 9th Apr 2005
Location:
Posted: 14th May 2012 19:55
This old thread of mine might help you out:
http://forum.thegamecreators.com/?m=forum_view&t=187219&b=1

It's a fully working example of a minecraft engine with the source code included. It runs incredibly fast by just using a single object to represent the world, but you can just look at the code for more detail.

SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 15th May 2012 16:21
Thank you so much Jimpo! I've been contemplating this 'using one object as all the blocks' thing, and haven't been able to figure out how it could work... For a start, my game uses 'Pick Object' to determine which block the player is selecting. If the blocks were all part of the same object, how could you tell which block is selected? Thanks for posting this, now I'll find out
SamKM
17
Years of Service
User Offline
Joined: 25th May 2009
Location:
Posted: 15th May 2012 16:37
I probably should know, but what are these commands 'find free object' 'find free ticker' and others? My DarkBASIC Pro isn't highlighting them, and tells me 'couldn't not determine parameter type' when I try to compile.
Also, there are some commands 'move' and 'getblock' that are highlighted! I'm pretty sure they didn't exist before, so what's going on?
Pincho Paxton
23
Years of Service
User Offline
Joined: 8th Dec 2002
Location:
Posted: 15th May 2012 16:41
Jane Doe
19
Years of Service
User Offline
Joined: 29th Jun 2007
Location:
Posted: 16th May 2012 07:58
Quote: "I've been contemplating this 'using one object as all the blocks' thing, and haven't been able to figure out how it could work... "


This code shows how to make one object that seems to be comprised of many separate boxes. Using this method should speed up your game, as there will only be one draw call for the scene.

No media is required. All you’ll need to do is to change the display mode settings in line 1.



Jane -

Login to post a reply

Server time is: 2026-07-22 00:35:32
Your offset time is: 2026-07-22 00:35:32