• Advertisement
Sign in to follow this  

Unity Please test my terrain engine

This topic is 4339 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I’ve successfully implemented quadtree approach to my terrain engine. I’ve uploaded my engine and request you guys to test it if you like its speed and accuracy and let me know about any weakness in it. There are already certain weaknesses in my code which I would like to mention here: For example my terrain is of 20x20 tiles, my code will create 21 quads i.e. it will divide the terrain into 21 pieces; each piece shall be minimum of 5x5 tiles. The 21 tiles are created as follows: The first (1) quad is holds the whole terrain. The terrain is divided into 4 equal sub-quads (i.e. of 10x10 tiles each) (quad number 2, 3, 4, 5). Then each sub-quad is further divided into 4 equal quads. This process is carried out until comes a quad which holds only 5x5 tiles. This quadtree code has substantially increased my engine’s performance, but there’s a catch... all these quads have to be pre-calculated for the first time, which takes quite a lot of time in loading a 250x250 tile map (I plan to make my game based on 250x250 tile maps). What would be the solution to this problem? I have created a MapSelect.exe file which will allow you to set the minimum number of tiles for a quad and you can also use different types of maps to see which, in your opinion, gives the best results. Please download and test my terrain engine from here: Click Here NOTE: These executables were built on Visual Basic 6 SP6 therefore you must have VB6’s runtime files installed on your system. These files are normally shipped with Windows XP but not with Windows 98SE. Thank you Faraz Azhar

Share this post


Link to post
Share on other sites
Advertisement
Ran fine for me [smile]

It sat around 75fps (if that helps you)
My pc specs are:
WinXP sp2
AMD Sempron 2800+
Geforce 6600gt
512mb ram

Log was as follows:
#===========================================#
#==================STARTUP==================#
City Builder Log file, opened: 17/03/2006 15:39:49
Creating DirectX Devices...
Adapter: NVIDIA GeForce 6600 GT
Acceleration: Hardware Acceleration (HAL)
Mode: 1600x1200 [32 BIT]
Mode Format: 22
Texture Filtering: Anisotropic
Processing: Hardware Vertex Processing
Antialiasing: 4 multisampling
Depth Buffer: 24 bit Depth buffer selected
Backbuffers: 2
Device created successfully!
Setting-up Terrain...
-> Loading Textures...
-> Loading Map...
-> Building Quadtrees...
Restoring Device Objects...
Restoring Device Objects... done!
->All loading complete.
Shutting down app...
#=================SHUTDOWN==================#

It is pretty cool, reminded me of Captain Skyhawk on the nes [grin]
Quote:
This quadtree code has substantially increased my engine’s performance, but there’s a catch... all these quads have to be pre-calculated for the first time, which takes quite a lot of time in loading a 250x250 tile map (I plan to make my game based on 250x250 tile maps). What would be the solution to this problem?

Dump the quadtree into a file (binary/ascii) and load that at startup instead of computing the quadtree everytime you run it [smile]

Regards,
ViLiO

Edit: Whacked the detail right up [grin]

[Edited by - ViLiO on March 17, 2006 9:19:56 AM]

Share this post


Link to post
Share on other sites
I was quite curious to see the source, but the zip file only had binaries :(

anyway, looks great. ran 75fps on my p4 3.2 1gb ram.

here is a copy of the log:
#===========================================#
#==================STARTUP==================#
City Builder Log file, opened: 17/03/2006 9:53:16 AM
Creating DirectX Devices...
Adapter: NVIDIA GeForce PCX 5300
Acceleration: Hardware Acceleration (HAL)
Mode: 1792x1344 [32 BIT]
Mode Format: 22
Texture Filtering: Bilinear
Processing: Hardware Vertex Processing
Depth Buffer: 24 bit Depth buffer selected
Backbuffers: 1
Device created successfully!
Setting-up Terrain...
-> Loading Textures...
-> Loading Map...
-> Building Quadtrees...
Restoring Device Objects...
Restoring Device Objects... done!
->All loading complete.
Shutting down app...
#=================SHUTDOWN==================#

Share this post


Link to post
Share on other sites
Ran well, steady 50 fps on my p4 2.8 with 512 ram

#==================STARTUP==================#
City Builder Log file, opened: 2006-03-16 23:59:56
Creating DirectX Devices...
Adapter: NVIDIA GeForce4 Ti 4200 with AGP8X
Acceleration: Hardware Acceleration (HAL)
Mode: 1280x1024 [32 BIT]
Mode Format: 22
Texture Filtering: Anisotropic
Processing: Hardware Vertex Processing
Antialiasing: 4 multisampling
Depth Buffer: 24 bit Depth buffer selected
Backbuffers: 2
Device created successfully!
Setting-up Terrain...
-> Loading Textures...
-> Loading Map...
-> Building Quadtrees...
Restoring Device Objects...
Restoring Device Objects... done!
->All loading complete.
Shutting down app...
#=================SHUTDOWN==================#

Share this post


Link to post
Share on other sites
Ok, ran fine on my Dell laptop, but when I ran it on my wide screen laptop everything went sideways and I couldn't do anything with it (the mouse also went sideways and it was confusing to try and control). Basically immagine the screen rotated 90 degrees clockwise.

Share this post


Link to post
Share on other sites
Completely fine my end, flat 85fps.
Loved the loading screen, looks very polished !

#==================STARTUP==================#
City Builder Log file, opened: 18/03/2006 2:29:47 AM
Creating DirectX Devices...
Adapter: RADEON 9600XT SERIES
Acceleration: Hardware Acceleration (HAL)
Mode: 1024x768 [32 BIT]
Mode Format: 22
Texture Filtering: Bilinear
Processing: Hardware Vertex Processing
Antialiasing: 2 multisampling
Depth Buffer: 24 bit Depth buffer selected
Backbuffers: 1
Device created successfully!
Setting-up Terrain...
-> Loading Textures...
-> Loading Map...
-> Building Quadtrees...
Restoring Device Objects...
Restoring Device Objects... done!
->All loading complete.
Shutting down app...
#=================SHUTDOWN==================#

Share this post


Link to post
Share on other sites
Quote:
Original post by jdarling
Ok, ran fine on my Dell laptop, but when I ran it on my wide screen laptop everything went sideways and I couldn't do anything with it (the mouse also went sideways and it was confusing to try and control). Basically immagine the screen rotated 90 degrees clockwise.


eh? I wonder why it did that.. ! Anyways thank you very much all of you! There is a little problem that Im having that I forgot to mention it here.

Mouse-tile selection code is incorporated but you may not see any selected tile when you hover over the terrain. Thats because im having some alpha-blending problems. Try pressing 'A' key when moving the mouse over the terrain When A key is pressed I disable alphablending before drawing the selection tile. The problem is that the selection tile isnt appearing nicely on top of other tiles. Do what other alpha blending options I need to set to draw it right?

Also please guide me how to create quadtrees faster. Have you guys tested different map sizes with different minimum tiles in quad. Try to play with it and please let me know what minimum level brings best frame rate performance.

[Edited by - itz_faraz on March 17, 2006 2:38:55 PM]

Share this post


Link to post
Share on other sites
60 fps for me on my AMD FX-57 w/ 7800 gt nvidia.
Am I the only one who tried using the arrow keys to scroll around and got a little pause every couple seconds?
#===========================================#
#==================STARTUP==================#
City Builder Log file, opened: 3/19/2006 2:31:59 AM
Creating DirectX Devices...
Adapter: (Unknown)
Acceleration: Hardware Acceleration (HAL)
Mode: 640x480 [16 BIT]
Mode Format: 23
Texture Filtering: Bilinear
Processing: Hardware Vertex Processing
Depth Buffer: 24 bit Depth buffer selected
Backbuffers: 1
Device created successfully!
Setting-up Terrain...
-> Loading Textures...
-> Loading Map...
-> Building Quadtrees...
Restoring Device Objects...
Restoring Device Objects... done!
->All loading complete.
Shutting down app...
#=================SHUTDOWN==================#

Share this post


Link to post
Share on other sites
Quote:
Original post by valles
60 fps for me on my AMD FX-57 w/ 7800 gt nvidia.
Am I the only one who tried using the arrow keys to scroll around and got a little pause every couple seconds?


Hmm.. why dont you play around with settings in MapSelect.exe. See if the 'minimum number of quads' can fix your problem. If it does, or at least brings better performance, please let me know what settings you used.

Share this post


Link to post
Share on other sites
I tested this on an lower end system
P4 1.66
Windows XP SP2

I got a slow 15 fps :(

#===========================================#
#==================STARTUP==================#
City Builder Log file, opened: 20/03/2006 8:19:10 PM
Creating DirectX Devices...
Adapter: NVIDIA GeForce2 MX/MX 400
Acceleration: Hardware Acceleration (HAL)
Mode: 1280x1024 [32 BIT]
Mode Format: 22
Texture Filtering: Bilinear
Processing: Hardware Vertex Processing
Depth Buffer: 24 bit Depth buffer selected
Backbuffers: 1
Device created successfully!
Setting-up Terrain...
-> Loading Textures...
-> Loading Map...
-> Building Quadtrees...
Restoring Device Objects...
Restoring Device Objects... done!
->All loading complete.
Shutting down app...
#=================SHUTDOWN==================#

Share this post


Link to post
Share on other sites
Quote:
Original post by starfleetrp
I tested this on an lower end system
P4 1.66
Windows XP SP2

I got a slow 15 fps :(

#===========================================#
#==================STARTUP==================#
City Builder Log file, opened: 20/03/2006 8:19:10 PM
Creating DirectX Devices...
Adapter: NVIDIA GeForce2 MX/MX 400
Acceleration: Hardware Acceleration (HAL)
Mode: 1280x1024 [32 BIT]
Mode Format: 22
Texture Filtering: Bilinear
Processing: Hardware Vertex Processing
Depth Buffer: 24 bit Depth buffer selected
Backbuffers: 1
Device created successfully!
Setting-up Terrain...
-> Loading Textures...
-> Loading Map...
-> Building Quadtrees...
Restoring Device Objects...
Restoring Device Objects... done!
->All loading complete.
Shutting down app...
#=================SHUTDOWN==================#



hmm.. youre running on high resolution and on 32 bit too. I havent tested it on that much stressed resolution. Try running on 16 bit. If no improvment then try lowering screen size.

Share this post


Link to post
Share on other sites
On a 256 size map, you'll have:
4^0 256 size block
4^1 128 size blocks
4^2 64 size blocks
4^3 32 size blocks
4^4 16 size blocks
4^5 8 size blocks
4^6 4 size blocks

Total number of blocks: 5461.

In these blocks, do you have a data entry for every cell within the block, or do you just have pointers down to the next level?

If those blocks contain an entry for every cell in their domain, then with a 256x256 size map you'd have 458752 entries for cells. Half a million is a decent sized number, even for a computer.

If, on the other hand, each block just has pointers to it's child blocks, you'd have about 20,000 pointers and 66,000 data entries for the cells.

Share this post


Link to post
Share on other sites
I was unable to start the application.

#==================STARTUP==================#
City Builder Log file, opened: 3/31/2006 12:49:08 PM
Creating DirectX Devices...
Adapter: HIGHTECH RADEON 9600XT
Acceleration: Hardware Acceleration (HAL)
Mode: 3200x1200 [32 BIT]
Mode Format: 22
Texture Filtering: Bilinear
Processing: Hardware Vertex Processing
Depth Buffer: 24 bit Depth buffer selected
Backbuffers: 1
ERROR: Device creation failed, falling back to Software Vertex Processing...
Device creation failure!
->VB Error: Automation error
->DirectX Error: D3DERR_DRIVERINTERNALERROR

#===========================================#

Share this post


Link to post
Share on other sites
Quote:
Original post by NotAYakk
On a 256 size map, you'll have:
4^0 256 size block
4^1 128 size blocks
4^2 64 size blocks
4^3 32 size blocks
4^4 16 size blocks
4^5 8 size blocks
4^6 4 size blocks

Total number of blocks: 5461.

In these blocks, do you have a data entry for every cell within the block, or do you just have pointers down to the next level?

If those blocks contain an entry for every cell in their domain, then with a 256x256 size map you'd have 458752 entries for cells. Half a million is a decent sized number, even for a computer.

If, on the other hand, each block just has pointers to it's child blocks, you'd have about 20,000 pointers and 66,000 data entries for the cells.



I don't really understand what you are advising but I'll try to explain what Im my engine is currently doing:

I have my whole terrain in an array. For example if the map is 256x256 tiles so my map will be stored in an 256x256 array structure which contains the tile number, the texture ID, and the Y adjusting (for raised/uneven tiles), also the mousemap ID and each tiles unique ID (autonumber).

Now these tiles are supplied to a class/module which breaks the supplied data into four equal parts and then creates four new classes/modules and supplies each broken piece of terrain (quad) to each class. At the time of breaking up the data (terrain), the class also calculates the bounding box of the tiles supplied to it (for visibility testing).

So in the end you have pointed it out correctly, the problem is that each class holds all the tile data supplied to it and then it further supplies that same data (broken into four pieces) to four separate quads; it doesnt remove the data within it. So overall theres a mulitplication of data by several times which should cause wastage of memory & cpu. But the game seems to work fine.

The term 'data' that I was mentioning are actually pointers (tile numbers) not complete tile data. The complete tile data was stored back in early stages in the array. The quads only receive the tile numbers which they are going to play with. And when rendering/calculating, these quads lookup that array for those specific tiles through the tile numbers supplied to them.

Im sure what I wrote above is pretty complex and unclear. Hope you understand it anyway!

Just like 'valles' said, my engine ruins its own performance when it is scrolled. It gives a pause after scrolling every few tiles.

Share this post


Link to post
Share on other sites
I have no real clue what the technical stuff is on this and all (the math and coding behind it) but I'd be willing to learn if you could point me in the right direction.

The purpose is just to generate a terrain right?


#===========================================#
#==================STARTUP==================#
City Builder Log file, opened: 4/6/2006 12:12:32 AM
Creating DirectX Devices...
Adapter: (Unknown)
Acceleration: Hardware Acceleration (HAL)
Mode: 640x480 [16 BIT]
Mode Format: 23
Texture Filtering: Bilinear
Processing: Hardware Vertex Processing
Depth Buffer: 24 bit Depth buffer selected
Backbuffers: 1
Device created successfully!
Setting-up Terrain...
-> Loading Textures...
-> Loading Map...
-> Building Quadtrees...
Restoring Device Objects...
Restoring Device Objects... done!
->All loading complete.
Shutting down app...
#=================SHUTDOWN==================#

Share this post


Link to post
Share on other sites
Quote:
Original post by TheKnight
I have no real clue what the technical stuff is on this and all (the math and coding behind it) but I'd be willing to learn if you could point me in the right direction.

The purpose is just to generate a terrain right?


Yes the purpose for the time being is to generate an efficient terrain engine. Later on things will be added and added to make it up as a terrain game.

If you need directions, search this website for articles. I was a newbie like anyone but I learned a LOT from the articles and discussions held here... so can you.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
  • Advertisement
  • Popular Tags

  • Advertisement
  • Popular Now

  • Similar Content

    • By Manuel Berger
      Hello fellow devs!
      Once again I started working on an 2D adventure game and right now I'm doing the character-movement/animation. I'm not a big math guy and I was happy about my solution, but soon I realized that it's flawed.
      My player has 5 walking-animations, mirrored for the left side: up, upright, right, downright, down. With the atan2 function I get the angle between player and destination. To get an index from 0 to 4, I divide PI by 5 and see how many times it goes into the player-destination angle.

      In Pseudo-Code:
      angle = atan2(destination.x - player.x, destination.y - player.y) //swapped y and x to get mirrored angle around the y axis
      index = (int) (angle / (PI / 5));
      PlayAnimation(index); //0 = up, 1 = up_right, 2 = right, 3 = down_right, 4 = down

      Besides the fact that when angle is equal to PI it produces an index of 5, this works like a charm. Or at least I thought so at first. When I tested it, I realized that the up and down animation is playing more often than the others, which is pretty logical, since they have double the angle.

      What I'm trying to achieve is something like this, but with equal angles, so that up and down has the same range as all other directions.

      I can't get my head around it. Any suggestions? Is the whole approach doomed?

      Thank you in advance for any input!
       
    • By Yosef BenSadon
      Hi , I was considering this start up http://adshir.com/, for investment and i would like a little bit of feedback on what the developers community think about the technology.
      So far what they have is a demo that runs in real time on a Tablet at over 60FPS, it runs locally on the  integrated GPU of the i7 . They have a 20 000 triangles  dinosaur that looks impressive,  better than anything i saw on a mobile device, with reflections and shadows looking very close to what they would look in the real world. They achieved this thanks to a  new algorithm of a rendering technique called Path tracing/Ray tracing, that  is very demanding and so far it is done mostly for static images.
      From what i checked around there is no real option for real time ray tracing (60 FPS on consumer devices). There was imagination technologies that were supposed to release a chip that supports real time ray tracing, but i did not found they had a product in the market or even if the technology is finished as their last demo  i found was with a PC.  The other one is OTOY with their brigade engine that is still not released and if i understand well is more a cloud solution than in hardware solution .
      Would there  be a sizable  interest in the developers community in having such a product as a plug-in for existing game engines?  How important  is Ray tracing to the  future of high end real time graphics?
    • By bryandalo
      Good day,

      I just wanted to share our casual game that is available for android.

      Description: Fight your way from the ravenous plant monster for survival through flips. The rules are simple, drag and release your phone screen. Improve your skills and show it to your friends with the games quirky ranks. Select an array of characters using the orb you acquire throughout the game.

      Download: https://play.google.com/store/apps/details?id=com.HellmodeGames.FlipEscape&hl=en
       
      Trailer: 
       
    • By khawk
      Watch the latest from Unity.
       
    • By GytisDev
      Hello,
      without going into any details I am looking for any articles or blogs or advice about city building and RTS games in general. I tried to search for these on my own, but would like to see your input also. I want to make a very simple version of a game like Banished or Kingdoms and Castles,  where I would be able to place like two types of buildings, make farms and cut trees for resources while controlling a single worker. I have some problem understanding how these games works in the back-end: how various data can be stored about the map and objects, how grids works, implementing work system (like a little cube (human) walks to a tree and cuts it) and so on. I am also pretty confident in my programming capabilities for such a game. Sorry if I make any mistakes, English is not my native language.
      Thank you in advance.
  • Advertisement