Java-Gaming.org Hi !
Featured games (83)
games approved by the League of Dukes
Games in Showcase (541)
Games in Android Showcase (133)
games submitted by our members
Games in WIP (604)
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  
  Yet another voxel engine  (Read 8175 times)
0 Members and 1 Guest are viewing this topic.
Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Posted 2014-06-22 17:23:48 »

Not sure as to where this should belong. Was thinking of posting it in the WIP board, but it'd not really a game:P

I've been working on a voxel terrain generation thing for a while - and here is the result.
https://www.dropbox.com/s/7colq1ex3lpe1pv/ChunkGen.zip
I'm curious as to how this runs on other people's computers; I'm unaware as to whether mine is above or below par.
Use WASD to move the camera, and hold the right and left mouse buttons simultaneously to rotate the camera.
Mouse wheel zooms.

Thanks for looking:)

Offline Spacebeans
« Reply #1 - Posted 2014-06-22 17:38:10 »

I'm curious as to how this runs on other people's computers; I'm unaware as to whether mine is above or below par.

CPU: AMD 8320 8 core 3.5ghz (Black edition)
GPU: GTX 650 Ti 2GB GDDR5 (Overclocked to 1024mhz)
Running at a solid, 60 fps. Send me a link without vSync or a limiter if you want me to test it in full frames.

Also, I have a few questions,

1. Does it use Immediate mode rendering?
2. What type of noise are you using?
3. Are you planning on making this into a game?
 - If so, please implement a ton of blocks, I wouldn't mind helping with a few textures!
Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #2 - Posted 2014-06-22 17:42:25 »

Okay, that's a great deal faster than mine i would imagine, just look at all those big numbers:D

1:Not too sure what immediate mode rendering is
2:Simplex noise. I didn't implement it - it was based on example code by Stefan Gustavson, and optimised by Peter Eastman.
3:Yes, think a less deep but easier to control dwarf fortress but with RTS controls:P
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Spacebeans
« Reply #3 - Posted 2014-06-22 17:46:24 »

1:Not too sure what immediate mode rendering is

Its the depreciated glBegins, glEnds and such. The good old fixed function pipeline. More... Modern OpenGL uses shaders to compute matrices, vectors, and pixel colors. If you were getting serious about performance, I would recommend Interleaved VBOs (The vertices are saved into VRAM on your GPU rather than send per-frame in real time), and GLSL theory and implementation. Its a TON faster. Also, look into the 'Programmable pipeline'. Its really interesting.
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 301
Exp: 6 years



« Reply #4 - Posted 2014-06-22 17:46:40 »

Runs smooth on a Phenom II 955 + HD 4670. ~5% CPU usage, not sure about GPU.
Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #5 - Posted 2014-06-22 17:49:29 »

@Spacebeans
Ohhhhhhh right yeah this uses interleaved VBOs already:P

@BurntPizza
Great, thanks for testing it:P

I'm glad it runs fine, I spent a lot of time trying to get it faster:P Guess I'll start building the game then.
Offline Longarmx
« Reply #6 - Posted 2014-06-22 17:57:43 »

Running a solid 60fps for me. (Had to open up Fraps to get a counter)

CPU: Intel i7 3770 4 core 3.9 GHz
GPU: Asus GTX 660 Overclocked to 1084 MHz

Although you should really be measuring delta, without a cap.

What kind of performance techniques are you using? (face culling, greedy meshing, etc...)

Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #7 - Posted 2014-06-22 18:00:04 »

I don't understand the difference between measuring delta and capping it? All I do currently is use Display.sync(60), I've no idea what that does under the covers, I just kind of take it for granted:s

Just face culling and greedy meshing currently.Smiley

I'll add an FPS count, sorry, I overlooked that.
Offline Longarmx
« Reply #8 - Posted 2014-06-22 18:10:03 »

Measuring delta is linear, while FPS is not. There was a great post by cas (I believe) a while back explaining the whole thing. There is some math involved that I can't quite remember correctly.  Smiley

If you keep a cap on, a lot of people are going to be reporting 60fps. Some of them might have gotten hundreds of fps, while others might barely be holding onto 60. You can just measure the performance on different systems better.

Offline BurntPizza

« JGO Bitwise Duke »


Medals: 301
Exp: 6 years



« Reply #9 - Posted 2014-06-22 18:17:59 »

"It's now 5 FPS faster" means nothing without context:

1000 FPS to 1005 FPS: 1 ms/frame vs. .995 ms/frame, 1.005x faster

1 FPS to 6 FPS: 1000 ms/frame vs. 166.7 ms/frame, 6 times faster.

A somewhat contrived example, but no less important.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline OpenGLShaders

Junior Devvie


Medals: 4
Exp: 2 years



« Reply #10 - Posted 2014-06-22 18:20:38 »

I doubt this is intended. Pointing
http://i.imgur.com/cPxFcId.png?1

I bet it is something to do with your VBO's, I have had issues like that in the past.

Mac OSX 10.7.5
GPU, Geforce 7300GT
CPU, 2.16 Intel Core 2 Duo
Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #11 - Posted 2014-06-22 18:23:23 »

^asldkserjfsd waht
I've no ideaD: I bet it's something to do with Mac, that's the only difference I can think of:(
Offline OpenGLShaders

Junior Devvie


Medals: 4
Exp: 2 years



« Reply #12 - Posted 2014-06-22 18:30:51 »

You might want to check the size of your VBO, I seem to remember that if it was oversized, it did random shenanigans like that. Also, do you mind pastebin'ing your VBO code? 
Offline Gibbo3771
« Reply #13 - Posted 2014-06-22 18:34:28 »

CPU: Intel i5 4200U @1.6/2.55Ghz
GPU: GT745m 850mhz (Not sure if memory or core?) or Intel 4500

Solid 60FPS. Both chipsets.

"This code works flawlessly first time and exactly how I wanted it"
Said no programmer ever
Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #14 - Posted 2014-06-22 18:46:39 »

But my VBO code is so messy :'D

Okay, here it is
http://pastebin.java-gaming.org/0c322778a92

I end up negating a lot of positions and adding some weird offsets just to get it to work right.
The 1st function (updateChunk()) culls the faces. It then passes these face to the next function - 'meshCrossSection' which is the greedy meshing part. It's in this function  that everything is bound to the VBO.

each chunk is 16x16 blocks, and between 16 and 32 in height depending on the noise.
Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #15 - Posted 2014-06-22 19:05:42 »

I added a more accurate FPS counter.

However, I had to very quickly find a way to display text in LWJGL - previously, I'd only done it in 2D. So you all have the privilege of witnessing what could possible be THE MOST ugly display of text in anything ever.

To emphasise my point, you'll have to move the camera around a bit to find the number. It should be floating in the sky on a giant billboard. Good luck:P
Offline OpenGLShaders

Junior Devvie


Medals: 4
Exp: 2 years



« Reply #16 - Posted 2014-06-22 19:17:53 »

I didn't see any rendering code, but if you do something like:
1  
glDrawArrays(GL_TRIANGLES, 0, buffer.capacity());

rather than:
1  
glDrawArrays(GL_TRIANGLES, 0, buffer.capacity() / 7);

that could cause it to explode.

Just for curiosity, can you try that first snippet? I'm interested as to what will happen on windows Wink
Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #17 - Posted 2014-06-22 19:21:26 »

Oh, the rendering code is much smaller

http://pastebin.java-gaming.org/c32278a8293

vertexCount, contrary to its name, is the amount of faces there are to render in the buffer.
Why would not dividing it by 7 cause it to explode? 0.0 In case you can't already tell, I'm a COMPLETE newbie to the whole 3D thing:P
Offline OpenGLShaders

Junior Devvie


Medals: 4
Exp: 2 years



« Reply #18 - Posted 2014-06-22 19:31:37 »

Can't see anything wrong with that, unless the vertexCount is wrong. I'd still be interested to know what happens if you multiply vertexCount by 6, instead of 4.
Anyways, here's a minor optimization for you.
1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
public void renderChunk()
   {
      //remember, the format is
      //x1,y1,z1,r1,g1,b1,a1
     
      //Draw the vertexes first -
      //Size is 3
      //Stride is 28
      //Offset is 0
      GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
      GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
      GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOID);
      GL11.glVertexPointer(3,GL11.GL_FLOAT, 28, 0);
      GL11.glColorPointer(4,GL11.GL_FLOAT,28,12);
      GL11.glDrawArrays(GL11.GL_QUADS, 0, vertexCount*4);
   }
Offline Screem
« Reply #19 - Posted 2014-06-22 19:58:37 »

Intel Core i5 1.7 GHz
Intel HD Graphics 4000
4GB RAM
Windows 8

Solid 2000 FPS. Really surprised it's that fast. Shocked
Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #20 - Posted 2014-06-22 20:03:33 »

Oh sweet, thanks. I'll put that in^^

@Screem
Yeah I got quite a high numbeer too. I'm dubious  of the method I used to calculate it.

I can explain it here:
Because I cap the framerate to 60 every loop, I needed a way to calculate the framerate you would have if you didn't cap it.
Each frame, I get the amount of nanoseconds/1000 it takes to perform all the calculations (without the bit where I cap the framerate). I add this to a value.
Every 60 frames, I take that value and divide by 60 to give the average nanoseconds/1000 it takes to do all the calculations. Then I divide 1000000 by this value, to get the amount of frames that can elapse in 1 second. Then I update the count.

I've been over this and it seems fine - but I was incredibly surprised with the result I got too:s
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 301
Exp: 6 years



« Reply #21 - Posted 2014-06-22 20:05:58 »

Yeah, sitting still it's 2500, moving about 2100.

I am getting the weird glitching at the start position though:

Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #22 - Posted 2014-06-22 20:08:54 »

A rather stupid mistake was that I didn't include the Display.update() function in the FPS calculations. I've updated the link to do that - it still stays at a steady 2.5k fps for me though.

Are you on mac?
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 301
Exp: 6 years



« Reply #23 - Posted 2014-06-22 20:12:41 »

Windows 7.

It only occurs at the corner you start at, perhaps some division by zero error in the vertex generation?
Offline BurntPizza

« JGO Bitwise Duke »


Medals: 301
Exp: 6 years



« Reply #24 - Posted 2014-06-22 20:20:46 »

Just tried it on my new laptop, no glitches but about half the FPS (odd)

It's a Win8.1 i7 4200 + GT 755


I'm guessing that you're doing something old drivers/OGL don't like. That card in my desktop is from 2009 (!).
Offline OpenGLShaders

Junior Devvie


Medals: 4
Exp: 2 years



« Reply #25 - Posted 2014-06-22 20:22:05 »

I tried the original again, I can just barely see the voxels if I move around, I initially assumed it was totally broken because it doesn't grab the mouse. I can't run the new version because I don't have OpenGL 3 Emo
Offline Riven
« League of Dukes »

« JGO Overlord »


Medals: 849
Projects: 4
Exp: 16 years


Hand over your head.


« Reply #26 - Posted 2014-06-22 21:01:07 »

There is only one way to measure FPS reliably:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
int fpsCounter = 0;
long lastSec = System.currentTimeMillis();
while(...) {

   ...

-  Display.sync(60);
   Display.update();

   fpsCounter++;
   if(System.currentTimeMillis() - lastSec > 1000) {
      lastSec += 1000;
      fps = fpsCounter;
      fpsCounter = 0;
   }
}


Given how asynchronous OpenGL drivers are, measuring it any other way is extremely misleading, as you're otherwise basically measuring how fast you can fill up the driver's command-queue. So drop your 'calculations', they will never be accurate. Just run the game loop flat out, and measure the actual frames that are rendered per second.

Hi, appreciate more people! Σ ♥ = ¾
Learn how to award medals... and work your way up the social
Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #27 - Posted 2014-06-22 21:21:31 »

Mm, thanks riven, I'll pop that in when I get chance - I wondered why the results I was getting were incredibly high.

And sorry, I was playing about with the text rendering and I think I added an unecessary GL30 method. I'll remove it later, but I'm a little busy currently:P
Offline Favorlock

Junior Newbie


Exp: 2 years



« Reply #28 - Posted 2014-06-24 10:57:03 »

A wopping 7650 fps for me Cheesy

Offline ipe369

Junior Devvie


Medals: 3
Exp: 3 years



« Reply #29 - Posted 2014-06-24 12:40:07 »

Pretty darn sure that fps count is broken;)
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.

Mr.CodeIt (13 views)
2014-12-27 04:03:04

TheDudeFromCI (17 views)
2014-12-27 02:14:49

Mr.CodeIt (25 views)
2014-12-23 03:34:11

rwatson462 (56 views)
2014-12-15 09:26:44

Mr.CodeIt (46 views)
2014-12-14 19:50:38

BurntPizza (92 views)
2014-12-09 22:41:13

BurntPizza (113 views)
2014-12-08 04:46:31

JscottyBieshaar (86 views)
2014-12-05 12:39:02

SHC (97 views)
2014-12-03 16:27:13

CopyableCougar4 (102 views)
2014-11-29 21:32:03
How do I start Java Game Development?
by gouessej
2014-12-27 19:41:21

Resources for WIP games
by kpars
2014-12-18 10:26:14

Understanding relations between setOrigin, setScale and setPosition in libGdx
by mbabuskov
2014-10-09 22:35:00

Definite guide to supporting multiple device resolutions on Android (2014)
by mbabuskov
2014-10-02 22:36:02

List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50
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!