Sign in to follow this  
itz_faraz

Unity Please test my terrain engine

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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

  • Announcements

  • Forum Statistics

    • Total Topics
      628378
    • Total Posts
      2982336
  • Similar Content

    • By sveta_itseez3D
      itSeez3D, a leading developer of mobile 3d scanning software, announced today a new SDK for its automatic 3D avatar generation technology, Avatar SDK for Unity. The Avatar SDK for Unity is a robust plug-n-play toolset which enables developers and creatives to integrate realistic user-generated 3D avatars into their Unity-based applications. SDK users can allow players to create their own avatars in the application or integrate the SDK into their own production processes for character design and animation.
      “Virtual avatars have recently become increasingly popular, especially in sports games and social VR apps. With the advance of VR and AR, the demand to get humans into the digital world is only increasing”, said Victor Erukhimov, itSeez3D CEO. “Our new Avatar SDK for Unity makes it super-easy to bring the avatar technology into any Unity-based game or VR/AR experience. With the Avatar SDK for Unity now every developer can bring face scanning technology into their games and allow players to create their own personalized in-game avatars, making the gameplay much more exciting and immersive.”
      Key features of the Avatar SDK for Unity:
      Automatic generation of a color 3D face model from a single selfie photo in 5-10 seconds (!). Works best with selfies, but can be used with any portrait photo.
      Shape and texture of the head model are unique for each person, synthesized with a deep learning algorithm crafted by computer vision experts
      Head models support runtime blendshape facial animations (45 different expressions)
      Generated 3D heads include eyes, mouth, and teeth
      Algorithms synthesize 3D meshes in mid-poly resolution, ~12k vertices, and ~24k triangles
      Six predefined hairstyles with hair-recoloring feature (many more available on request)
      Avatar generation API can be used in design-time and in run-time, which means you can allow users to create their own avatars in your game
      Cloud version is cross-platform, and offline version currently works on PCs with 64-bit Windows (support for more platforms is coming soon)
      Well-documented samples showcasing the functionality.
       
      Availability
      The Avatar SDK for Unity is offered in two modes - “Cloud” and “Offline”. The “Cloud” version is available at http://avatarsdk.com/ and the “Offline” version is available by request at support@itseez3d.com.
      ###
      About itSeez3D
      At itSeez3D, we are working on the computer vision technology that turns mobile devices into powerful 3D scanners. itSeez3D has developed the world's first mobile 3D scanning application that allows to create high-resolution photorealistic 3D models of people's' faces, bodies and objects. The application is available for iOS and Windows OS mobile devices powered with 3D cameras. In 2016 the company introduced Avatar SDK that creates a realistic 3D model of a face from a single selfie photo. To learn more about itSeez3D scanning software and 3D avatar creation technology, please visit www.itseez3d.com and www.avatarsdk.com.

      View full story
  • Popular Now