Java-Gaming.org    
Featured games (91)
games approved by the League of Dukes
Games in Showcase (580)
games submitted by our members
Games in WIP (500)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: 1 [2]
  ignore  |  Print  
  Craftia - The Game of Crafting [Updates_Paused]  (Read 3418 times)
0 Members and 1 Guest are viewing this topic.
Offline rv3392

Senior Member


Medals: 2
Projects: 1


Crafted Games


« Reply #30 - Posted 2013-10-26 05:54:04 »

I show all sides of a chunk (I will be changing that later). My chunks are 16*16*128. I render 484 of those so my map is 22*22*1 chunks.
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #31 - Posted 2013-10-26 05:56:17 »

Damn, I only render 18 chunks and my FPS drops down below 60. I'm using display lists also, so I wonder what the issue is!
Edit: Never mind, I was doing something horribly wrong. Now I'm back to a good FPS! How many chunks do you actively render? I don't imagine all 484.

Offline rv3392

Senior Member


Medals: 2
Projects: 1


Crafted Games


« Reply #32 - Posted 2013-10-26 06:02:20 »

I wouldn't aim for more than 45 fps for a cube engine unless it lags. Because if you have a look at minecraft it's fps is never over 40.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #33 - Posted 2013-10-26 06:05:09 »

Oh I get over 100 FPS while playing minecraft. Just tested my game, I get a perfect 60 FPS with vSync on while rendering over 60 chunks. Awesome.
Edit: Now I'm up to 150 chunks. I'm trying to find the max... this is insane I don't know why its working so well!
Edit 2: Found the limit before the program crashes from heap errors! I can get up to 174 chunks at one time Cheesy

Offline rv3392

Senior Member


Medals: 2
Projects: 1


Crafted Games


« Reply #34 - Posted 2013-10-26 06:06:03 »

Good Job!

Edit: That's fast!
Edit 2: I actively render around 200 but you can't see all of them.
Offline Longor1996
« Reply #35 - Posted 2013-10-26 14:03:17 »

Good Job!

Edit: That's fast!
Edit 2: I actively render around 200 but you can't see all of them.

I can render at max just about 1000 16³-Chunks. :/

How?
- Voxel Face Culling
- View Frustum Culling
- Rendering based on DisplayList's and VAO's.
- Stitched Texturemap
- Cached Voxel Texture UV's.
- Some more small gimmicks...

The last thing to do is to include occlusion culling,
then I practically replicated the Minecraft rendering in my own way.

Edit: Correction here: I WAS able to render that much. I broke my engine while trying to switch over to Multiplayer.

Have a nice day!

- Longor1996

Sorry for my bad English! That's because i am from Germany.
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #36 - Posted 2013-10-26 14:11:09 »

Good Job!

Edit: That's fast!
Edit 2: I actively render around 200 but you can't see all of them.

I can render at max just about 1000 16³-Chunks. :/

How?
- Voxel Face Culling
- View Frustum Culling
- Rendering based on DisplayList's and VAO's.
- Stitched Texturemap
- Cached Voxel Texture UV's.
- Some more small gimmicks...

The last thing to do is to include occlusion culling,
then I practically replicated the Minecraft rendering in my own way.

Have a nice day!

- Longor1996
The only thing I don't do on your list right now is view frustum culling, but that's because I'm to lazy to get into all that math :/ My voxel face culling can also be improved to only render faces, and I still need to check for cubes that are touching in different chunks, but that won't be that difficult I hope. What do you use VAOs for? And what do you mean by cached texture UV's? I just create one instance of the texture coordinates in a spritesheet and then pass them into my renderer. My only issue is that I run out of heap space at about 175 chunks Sad Looks like I need to reduce the amount of geometry by a lot!

Offline Longor1996
« Reply #37 - Posted 2013-10-26 14:33:44 »

Good Job!

Edit: That's fast!
Edit 2: I actively render around 200 but you can't see all of them.

I can render at max just about 1000 16³-Chunks. :/

How?
- Voxel Face Culling
- View Frustum Culling
- Rendering based on DisplayList's and VAO's.
- Stitched Texturemap
- Cached Voxel Texture UV's.
- Some more small gimmicks...

The last thing to do is to include occlusion culling,
then I practically replicated the Minecraft rendering in my own way.

Have a nice day!

- Longor1996
The only thing I don't do on your list right now is view frustum culling, but that's because I'm to lazy to get into all that math :/ My voxel face culling can also be improved to only render faces, and I still need to check for cubes that are touching in different chunks, but that won't be that difficult I hope. What do you use VAOs for? And what do you mean by cached texture UV's? I just create one instance of the texture coordinates in a spritesheet and then pass them into my renderer. My only issue is that I run out of heap space at about 175 chunks Sad Looks like I need to reduce the amount of geometry by a lot!

It is extremely easy to check if a face needs to be rendered, may it be over chunk-borders or inside a single chunk.

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
(pseudocode)
when renderVoxel DEFAULT_VOXEL Voxel{x,y,z,ID} of CHUNK
{
  for_each SIDE of VOXEL
  {
    int3 coord = SIDE.getCoordinatesOfNeighborRelative(VOXEL.x,VOXEL.y,VOXEL.z);
    int neighborData = 0;
   
    if(CHUNK.isCoordInside(coord))
        neighborData = CHUNK.get(coord);
    else
        neighborData.WORLD.get(coord);
   
    Do-Occlusion-Checks-For-Neigbor-And-Stuff (neighborData);
  }
}


This is just about how I go about it, with the exception that I am doing some fancy caching behind the scenes to speed things up.
Notable is that my World consists of chunks and is infinite in all directions.

Also:
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
- Use ByteBuffers for your chunks, not int[] or byte[] or short[] or Voxel[(This-Is-The-Worst)].
- Do as much packing as possible. If needed on a bit-wise level. My voxels each take up 3 bytes, or none.
- Never store more than one istance of a Block.
- Never return Voxels as Objects over 'return'.
- Never create Objects inside the loop that renders the blocks.
- Never try to render voxels in real-time if you want a lot of them.
- Use FACC-Rendering if possible. (FarAwayCompressedChunk-Rendering)
- Face Cull all Voxel-faces that cant be visible.
- Do View Frustum Culling on the chunks.
- Render Chunks based on DisplayLists and VAOs. This is THE fastest way. Nothing is faster. Believe me in that. (Needs a lot of trickery though)
- Use stitched TextureMaps to support an 'infinite' amount of textures on your voxels.
- Cache all the Texture-UVs for the Voxels. Never recalculate them each time you render stuff.
- Cache all the chunks around a chunk to speed up the access when generating the mesh (aka: Rendering the Chunk).
- Z-Sort your Chunks and render them (opaque) Front-To-Back, then (transparenzy) Back-To-Front. This can double your FPS, if done right.
- Do not use glCallList(int) to render your display-lists! Use glCallList(IntBuffer) instead, its a lot faster.

- ...etc.etc.

- ALWAYS USE A DAMN PROFILER! Seriosly... do it!


There are so many things to speed up rendering.
I don't even know how many of them I found out about by just experimenting.

- Longor1996

Sorry for my bad English! That's because i am from Germany.
Offline rv3392

Senior Member


Medals: 2
Projects: 1


Crafted Games


« Reply #38 - Posted 2013-10-27 07:39:38 »

This is actually helping me out.  Grin
Offline StumpyStrust
« Reply #39 - Posted 2013-10-27 22:25:14 »

Interesting talk about performance. I thought my little project for my game class was very slow but I guess not so bad. I can get around 500k cubes (not chunks) at 20+ fps. Not fantastic but I do not use any chunking system or anything fancy.

http://www.java-gaming.org/topics/random-stumpy-projects/30807/msg/284779/view.html

Look at the last post.

All I do is per-compute the culled faces and use a face batcher via GL11 stuff. The cubes are stored in a hashmap with their location as the key. Adding and removing blocks is basically free for recomputing which faces are culled. Because everything is make dynamically every frame, things could get faster with a chunk system, static VBOs, and frustum culling on non-visible chunks. From what I know, frustum culling on each cube is not worth the computational cost. 

Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #40 - Posted 2013-10-27 22:51:26 »

Definitely not worth it. Either cull entire chunks that are completely outside the frustum, or sort your geometry using octrees and maybe cull individual blocks like that. I personally just use display lists for my cubes, and I want to convert it over to VBOs someday, maybe. I haven't seen a huge performance increase when I switch to VBOs, so maybe I wont. Probably the biggest optimizations I have that really truly increased my frame rate were only rendering visible faces, making all my geometry static so I only ever create one instance of each tile type, and using a spritesheet. Those three things alone probably tripled my frame rate. I've heard frustum culling in a voxel game isn't entirely useful, because there really just aren't as many vertices to be rendered as in a non-voxel game, but it still can raise the FPS by a little. Quite honestly, besides occlusion culling (which I have no idea how to do) and frustum culling, those three optimizations are all I currently need to get the game running fast.

Offline theagentd
« Reply #41 - Posted 2013-10-28 00:28:15 »

The reason you should use VBOs is because they're faster to update than immediate mode + display lists. Plus, they're not deprecated. >_>

Myomyomyo.
Offline StumpyStrust
« Reply #42 - Posted 2013-10-28 00:45:06 »

What really helped was pre-computing the faces. When a block is created or removed, check to see if it shares that face with another block, if so, check a Boolean to not render that face. That way it is a single Boolean if check and not a hash look up check to see if a face is rendered. If a block has adjacent blocks on all sides, nothing is rendered. This doubled to tripled fps at 100k+ cubes. Also, going from batching via fixed function vertex arrays instead of display list gave a huge performance boost. I think it is because I did not have a chunking system.

I here people talking of rendering 1k 16x16x16 chunks. That is like 4 million cubes. I can only think that Frustum culling chunks is a huge performance boost. And it is if you tink about it. Completely throwing out chunks of 4k + cubes if they are not in the view is worth the computation. You could drop the 4 million down to 1 million or less. I am not a cube world guy because for some reason I absolutely HATE minecraft for no reason what so ever but once I got the noise terrain generation working I was like "That looks cool".

@theagnetd only reason why I am not doing static VBOs is that the dude teaching the class made a HUGE point that everything MUST BE GL11 because he is convinced that windows only supports GL11. I got him to use LWJGL instead of JOGL (nothing against Julian or w/e his name is) and made him actually tell the class that giving doubles into the GPU may slow things down. *face palm* Also, my laptop does not support opengl 3.0 so a bunch of modern things are thrown out.

Offline HeroesGraveDev

JGO Kernel


Medals: 212
Projects: 11
Exp: 2 years


If it wasn't Awesome, it wasn't me.


« Reply #43 - Posted 2013-10-28 01:21:40 »

Greedy meshing anyone?

I implemented it in my voxel engine and performance improved significantly. I managed to beat Minecraft on short render distance - with drawing enough chunks for Minecraft's far render distance.

This is probably one of the harder optimisations to code, but it makes a lot of sense afterwards, and is definitely worth it.

Article series starts here

Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #44 - Posted 2013-10-28 01:45:58 »

Actually, yeah now that I think about it, you're right. I didn't think about having huge worlds like that. Quite honestly, you really shouldn't be rendering that many cubes anyway. But if you want to, then frustum culling and occlusion culling is a must. For my game, I only render chunks that are within the render distance, so frustum culling is useful, but its not a huge FPS booster.

@theagentd I should just switch to VBOs shouldn't I? Maybe someday... display lists are so easy and its just a learning project for me. Although, VBOs really aren't hard... its just my shear laziness that's preventing me from using them!

Online Longarmx
« Reply #45 - Posted 2013-10-28 02:11:24 »

Quote from: opiop65
@theagentd I should just switch to VBOs shouldn't I? Maybe someday... display lists are so easy and its just a learning project for me. Although, VBOs really aren't hard... its just my shear laziness that's preventing me from using them!

Sorry, I'm on my phone right now.

You should look up thebennybox on YouTube. He creates a 3d engine from scratch using modern OpenGL techniques. In about video 12(?) he discuses and implements vbos and later he incorporates ibos.

Offline opiop65

JGO Kernel


Medals: 124
Projects: 7
Exp: 3 years


Team Alluminum


« Reply #46 - Posted 2013-10-28 02:20:16 »

I've already watched his tuts, I seriously can't stand his voice or his coding style. He just uses terrible variable names and all that... but I did get a lot out of it!

Offline rv3392

Senior Member


Medals: 2
Projects: 1


Crafted Games


« Reply #47 - Posted 2013-10-28 07:58:28 »

Craftia Alpha a0.2.1:

+ Added Better Frustum Culling with less view distance
+ Added Stats

I took a bit of break.
Offline rv3392

Senior Member


Medals: 2
Projects: 1


Crafted Games


« Reply #48 - Posted 2013-10-28 10:16:29 »

Going to put up a playable jar pretty soon but can't get it to work.
Pages: 1 [2]
  ignore  |  Print  
 
 

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

xsi3rr4x (47 views)
2014-04-15 18:08:23

BurntPizza (43 views)
2014-04-15 03:46:01

UprightPath (59 views)
2014-04-14 17:39:50

UprightPath (41 views)
2014-04-14 17:35:47

Porlus (57 views)
2014-04-14 15:48:38

tom_mai78101 (80 views)
2014-04-10 04:04:31

BurntPizza (139 views)
2014-04-08 23:06:04

tom_mai78101 (239 views)
2014-04-05 13:34:39

trollwarrior1 (199 views)
2014-04-04 12:06:45

CJLetsGame (207 views)
2014-04-01 02:16:10
List of Learning Resources
by SHC
2014-04-18 03:17:39

List of Learning Resources
by Longarmx
2014-04-08 03:14:44

Good Examples
by matheus23
2014-04-05 13:51:37

Good Examples
by Grunnt
2014-04-03 15:48:46

Good Examples
by Grunnt
2014-04-03 15:48:37

Good Examples
by matheus23
2014-04-01 18:40:51

Good Examples
by matheus23
2014-04-01 18:40:34

Anonymous/Local/Inner class gotchas
by Roquen
2014-03-11 15:22:30
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!