Page 1 of 3

OpenGL map viewer : an experiment [DEMO AVAILABLE]

Posted: Sun Feb 17, 2013 4:33 am
by melchips
Hello,

! Downloadable demo available at the end of the post !

I am working on a simple OpenGL viewer for Ace Of Spades .vxl maps (in C language).
I made it to learn OpenGL and to see if Minecraft lighting would suit AoS.

Comparison shots between Ace of Spades and the OpenGL viewer :
Image

Image

Image

Image

Image

Image

Video of mesa.vxl in the map viewer:
The light is propagated just like in Minecraft.
There is also lighting interpolation across block faces.

Below a screenshot without color information (to have a better look on the shades) next to a full render :
Image

The tool is a command line program with the following switches :
Code: Select all
   ___|         |             ___|  |     
  |      |   |  __ \    _ \  |      |     
  |      |   |  |   |   __/  |   |  |     
 \____| \__,_| _.__/  \___| \____| _____|  v0.4a


Usage : ./cubegl [OPTIONS] <mapfile>

options :
	-f : enable full screen
	-w [value] : window width
	-h [value] : window height
	-z [value] : window depth (bits per pixel)
	-v : verbose output
	-d : debug
	-p : display debug graphs (plots)
	-b : discard block's color information (white blocks)
	-a [0,1] : advanced OpenGL enabled or not (VBO)
	-c [0,1] : draw clouds or not
	-t [0,1] : draw textures on blocks or not
	-m [0-15] : minimum lighting value (0 for dark, 15 for light, default = 2)
	            for 0, dark areas will be pitch black
	            for 15, there will be no dark areas
	-s RRGGBB : color of the sky in hex values (e.g. FF0000 for red)
	            sample values :
	            9BD2F1 : blue sky for day (default value)
	            001F36 : dark blue for night (you may want to lower gamma to have a better effect)
	            E3A857 : for a sunset color (you may want to lower gamma to have a better effect)
	-q [0,2,4,6,8,16] : antialias quality
	-g [value] : gamma value (default 1.0) 
	-r [value] : render distance (default 24)

example :
	./cubegl -w 1024 -h 768 -z 16 -p -v -a 0 -b -c 1 -t 0 -m 2 -f -s 001F36 -g 0.5 ./mesa.vxl
If it's not working straight away, you could try the lowest settings as indicated below :
Code: Select all
cubegl -q 0 -t 0 -c 0 -w 800 -h 600 -z 16 -a 0 map.vxl
On GNU/Linux, if you have a missing library error, try launching the program like this to use the included libs :
Code: Select all
LD_LIBRARY_PATH=./libs ./cubegl map.vxl
Controls are WASD / ZQSD to move, shift to go down, space to go up. Esc to exit.

Links to version 0.4a download :
GNU/Linux 32 bits (2 MB)
GNU/Linux 64 bits (2 MB)
Windows (2 MB)

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Sun Feb 17, 2013 4:38 am
by TheGeekZeke101
That is beautiful. Looks very promising. Can't wait for this to be released.

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Sun Feb 17, 2013 2:58 pm
by CraftDinur
If only we could get lighting like this implemented into the full game Green_Crying

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Sun Feb 17, 2013 3:08 pm
by rakiru
Nice work. ^-^
What are you planning to do with this? Release a map-viewer? Release a library for others to use?

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Sun Feb 17, 2013 7:38 pm
by Yourself
Very nice! Are you only using ambient occlusion for shading? It looks to me like there are no other sources of light or any sort of shadows. Are you using screen space ambient occlusion?

I started a thread on CPU based AO here: http://www.volumesoffun.com/phpBB3/view ... f=14&t=481

The idea is that hopefully AO can be used on computers with older graphics cards.

I'm working on an engine for a new game atm. Using polyvox and Irrlicht. Screenshot: http://i.imgur.com/5RxnXfD.png

Edit: also I think you might get better results if you implement directional lighting and turn down the AO slightly.

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Sun Feb 17, 2013 9:08 pm
by HoboHob
Do us all a favor, download the Iceball source and implement this nao.

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Sun Feb 17, 2013 10:38 pm
by melchips
Thanks everyone for your comments.

@Yourself The algorithm used is directly the one used by Minecraft. There is no ray casting or anything, it is only a cheap method to propagate light (maximum at 15 blocks). That's why caves entrances are lighten just a little and the end of the caves are pitch black (although I am forcing a maximum darkness to prevent seeing nothing in dark places).
Yourself wrote:
I'm working on an engine for a new game atm. Using polyvox and Irrlicht. Screenshot: http://i.imgur.com/5RxnXfD.png
.

Good luck with that ;)
I started by using Ogre3d with C++ and I had pretty good results but I wanted to know how things worked under the hood.
And relying on external libraries was a mess for compilation times and for cross compiling :/
Yourself wrote:
Edit: also I think you might get better results if you implement directional lighting and turn down the AO slightly.
I haven't planned to have shadows matching the sun's position or other light sources, but I guess it could be done with shaders, like it is in Minecraft with Sonic Ether's Unbelievable Shaders.
rakiru wrote:
Nice work. ^-^
What are you planning to do with this? Release a map-viewer? Release a library for others to use?
Originally, I worked on this project as a proof of concept.
I knew a good client was in dev (Iceball) so I focused only on graphical aspects (as it was not the priority for Iceball).

I have not yet decided what to do next.
I plan to release first a demo and then the source code after a bit of clean up (GPL licence).

Many options are then possible, and all depends of the community :
- use it only as a map viewer
- use it as a base or an inspiration for new voxel based games (hence opening the source up)
- work on an alternative client for AoS : depends if people wants to participate in the project or not and if the rendering constraints (like in Minecraft) are suitable for a game like AoS. Maybe we should merge our forces instead and work only on Iceball ?
- incorporate ideas in Iceball, wink to HoboHob (but I'm not sure I'm skilled enough to incorporate concepts into Iceball, even if the latests commits have already done a lot of work with the addition of OpenGL as an alternative renderer)
- others thing I haven't thought about ? tell me !

What you do think ?

As a bonus, a little preview video of the mesa.vxl map

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Mon Feb 18, 2013 12:02 am
by Yourself
melchips wrote:
Thanks everyone for your comments.

@Yourself The algorithm used is directly the one used by Minecraft. There is no ray casting or anything, it is only a cheap method to propagate light (maximum at 15 blocks). That's why caves entrances are lighten just a little and the end of the caves are pitch black (although I am forcing a maximum darkness to prevent seeing nothing in dark places).
Yourself wrote:
I'm working on an engine for a new game atm. Using polyvox and Irrlicht. Screenshot: http://i.imgur.com/5RxnXfD.png
.
Yourself wrote:
Edit: also I think you might get better results if you implement directional lighting and turn down the AO slightly.
I haven't planned to have shadows matching the sun's position or other light sources, but I guess it could be done with shaders, like it is in Minecraft with Sonic Ether's Unbelievable Shaders.
Wow I'm very impressed by the results from such a simple algorithm! One question though: the posts I've been reading on the minecraft algorithm work per-block and not per vertex. Your screenshots and videos on the other hand show variation in shading over block faces. Are the vertices different colors? What algorithm is this?

Also I wasn't talking about shadows, but rather something like flat shading, phong shading, or gouraud shading. Flat shading is really easy to implement and will give you good results!

Edit:
A possible implementation I came up with: at each vertex, take the average color of the blocks that make up that vertex. This way you get a nice shading effect.

This doesn't explain something like this though:
Image

Edit2: I found https://github.com/overviewer/Minecraft ... h-lighting which explains what's going on. Very nice! Blue_Happy3

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Mon Feb 18, 2013 2:25 am
by Buffet_of_Lies
I love the clouds.

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Mon Feb 18, 2013 3:14 am
by HoboHob
If you ask me this looks 10x better than Ace of Spades 1.0!

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Wed Feb 20, 2013 1:28 pm
by melchips
@Yourself
Exactly, each vextex gets an average value.
Simple but very effective ^^

@Buffet_of_Lies
I love them too ;)
It gives a nice touch to AoS maps.

@HoboHob
Thanks mate.
I think AOS 1.0 implements the same principles but they have also added a texture to blocks and a pixelated texture on the skybox.
Their chunks tesselating seems incredibly fast. I suspect that chunks are pre-rendered at map loading screen and then just loaded from memory (that's would explain why map loading takes a huge amount of time). But I haven't checked that theory yet.

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Wed Feb 20, 2013 3:26 pm
by Sample
Prototype AoS version with that graphic

Image

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Sun Apr 14, 2013 7:22 pm
by melchips
I have uploaded a precompiled demo for GNU/Linux (32 and 64 bits) and windows.

The tool is a command line program with the following switches :
Code: Select all
   ___|         |             ___|  |     
  |      |   |  __ \    _ \  |      |     
  |      |   |  |   |   __/  |   |  |     
 \____| \__,_| _.__/  \___| \____| _____|  v0.4a


Usage : ./cubegl [OPTIONS] <mapfile>

options :
	-f : enable full screen
	-w [value] : window width
	-h [value] : window height
	-z [value] : window depth (bits per pixel)
	-v : verbose output
	-d : debug
	-p : display debug graphs (plots)
	-b : discard block's color information (white blocks)
	-a [0,1] : advanced OpenGL enabled or not (VBO)
	-c [0,1] : draw clouds or not
	-t [0,1] : draw textures on blocks or not
	-m [0-15] : minimum lighting value (0 for dark, 15 for light, default = 2)
	            for 0, dark areas will be pitch black
	            for 15, there will be no dark areas
	-s RRGGBB : color of the sky in hex values (e.g. FF0000 for red)
	            sample values :
	            9BD2F1 : blue sky for day (default value)
	            001F36 : dark blue for night (you may want to lower gamma to have a better effect)
	            E3A857 : for a sunset color (you may want to lower gamma to have a better effect)
	-q [0,2,4,6,8,16] : antialias quality
	-g [value] : gamma value (default 1.0) 
	-r [value] : render distance (default 24)

example :
	./cubegl -w 1024 -h 768 -z 16 -p -v -a 0 -b -c 1 -t 0 -m 2 -f -s 001F36 -g 0.5 ./mesa.vxl
If it's not working straight away, you could try the lowest settings as indicated below :
Code: Select all
cubegl -q 0 -t 0 -c 0 -w 800 -h 600 -z 16 -a 0 map.vxl
On GNU/Linux, if you have a missing library error, try launching the program like this to use the included libs :
Code: Select all
LD_LIBRARY_PATH=./libs ./cubegl map.vxl
Controls are WASD / ZQSD to move, shift to go down, space to go up. Esc to exit.

Links to version 0.4a download :
GNU/Linux 32 bits (2 MB)
GNU/Linux 64 bits (2 MB)
Windows (2 MB)

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Sun Apr 14, 2013 7:29 pm
by Semper
Oh my god this is amazing.

Re: OpenGL map viewer : an experiment [PREVIEW]

Posted: Sun Apr 14, 2013 7:59 pm
by HoboHob
Shut up and take my $0.20!

Plz can haz src.