Tadam!

Found the issue with the frame rate… The game is running at a good framerate, but due to some old code, the frame rate got locked to 50 FPS, which in a normal monitor that refreshes at 60 Hz causes some jumps in the image…
“So, Covenant, you just had to change a variable to get it to 60FPS, right?”…
Nope… Doing so, exposed a more serious problem, namely the use everywhere of “timeGetTime()” to fetch the time of the system so I can do calculations… The precision of timeGetTime() is terrible, much worse than I expected… It took me some time to figure this one out, because adding logs was upsetting the measurements… I had to use a more precise timer and fix some parts of the code to get it working correctly, but the good news is that it now runs at 60 FPS, and there’s not much optimization to be done at this moment (since I still have about 6 ms to spare per-frame now)…
Now listening to “Hybrid Theory” by “Linkin Park”
Link of the Day: And more out-of-date Star Wars… Looks sweet!
I wasn’t happy with the performance of the game in certain points, with drops to 30 or 40 FPS, as measured by Fraps…
So, I decided to dust off my profiling tools and try to figure out where were the bottlenecks, but when I was running the initial benchmarks I got a very strange issue:

So the game is reporting that a full frame takes 3 ms to render (333 FPS), but the frame rate reported by Fraps is 47 FPS… My first thought was that my profiling system was wrong for some reason, but other simpler tests (just time it directly and output the result to a file after 200 frames) corroborated this data…
My second thought was that I was losing time because of the monitor couldn’t take more than 50 frames per second, but that should be registered below the “Swap” meter, and I was able to play a YouTube video with Fraps showing 60 FPS.
Switching to Direct3D and setting the presentation interval to immediate, the results were even stranger:

I’d say the zero in render time is impossible and doesn’t make any sense whatsoever…
So I’m still diving into the code, trying to figure out exactly what’s happening with the timers/profile code… There has to be something I’m missing that explains this… Anyway, the frame rate is better than I thought, so I may not need to really go into optimization for now!
Now listening to “Maniacal Renderings” by “Jon Oliva’s Pain”
Link of the Day: When this goes up, everybody has already seen this, I’m sure, but this is fresh at time of writing, and I’m such a fanboy, I need to share my excitement:
The more we approach the end of the development cycle, the more bugs we fine… or more precisely, the less we can ignore them and hope they don’t happen again… 
I’m having a nasty bug that I have no idea what causes it and I can’t replicate it consistently…
When I run the game in “final mode”, with the Direct3D renderer, and with the debug flags on DirectX turned on (which enforce more validation and force a crash on error), I sometimes get a crash because “The Index stream does not have the required number of indices: DrawIndexedPrimitive failed”.
Well, I understand the cause of the crash, and I want to fix it, but I can’t find a single place that might cause this to happen! I increase the index count when I add an index, so this should be impossible, but apparently it’s not… There’s probably a stilly fringe case somewhere that causes this, but I have no idea where, and since I can’t replicate it reliably (sometimes it happens on the first loading screen, other times it takes 30 minutes), it makes it extremely hard to track!

Anyway, I’m looking into this and other small bugs, trying to get enough courage for the next big task: stop using an extremely old version of FMod and start using the latest one, which has support for Mac and Linux… Or find another audio API, I’m cool… 
Now listening to “Educated Horses” by “Rob Zombie”
Link of the Day: This is advertisement well done… I totally want one of these! 
Still working on the press stuff, making screenshots, etc…
So that the screenshots reflect the current state of the actual game, I’m running the game in “Final” mode, and that (of course) gave rise to some more bugs, so I’m fixing those by adding a “stack tracer”, which is a piece of code that when a crash occurs, it (hopefully) pinpoints where it happened (since I don’t have debug information in final mode).
So, that was my day, how was yours? 
Now listening to “Back Through Time” by “Alestorm”
Link of the Day: If you follow our YouTube channel, you already saw this two weeks ago, but since I write blog posts in advance, here’s a new short gameplay video:
Today was a full day… I did a bit of bug fixing, related to turrets and traps and collision detection:

Also added some polish in the end of the laser beam, and worked on testing recording gameplay video, so I can prepare to start doing some marketing stuff, contract press, and some SEO with the WordTree maketing company…
I’m currently uploading a short gameplay video, tomorrow I’ll link it!
I’m a bit unhappy with the performance of the game at this moment… The frame rate is normally about 50 FPS, but it has some weird stutters that I can’t seem to identify the source… It doesn’t seem related to anything particular, but it’s on my to-do list to identify the source!
Now listening to “The Diary” by “The Gentle Storm”
Link of the Day: This is probably the best music video ever made:
This is the best definition for today… It started great, adding new content the artist built:


Also fixed a lot of small stuff, like making the player fall to the ground when he’s killed in flight, or selecting an upgrade automatically when purchasing things in the shop…
But then I started hitting bugs… a lot of them, and most of them quite mysterious and difficult to track down, like turrets in pirate lairs that were sunk on the ground, a crash on “glUseProgram”, or hitting enemies that weren’t “there”.
After a couple of hours of looking puzzled at the screen, finally figured that all of it had a single root-cause: the multithreading system! Because I now generate multiple areas and have them in RAM all the same time, I can no longer use stuff like singletons and globals for some stuff…
For example, the turret was buried because when I generated that area, it was using the navigation mesh of the area I was actually in, instead of the one I was generating… I was also hitting enemies that were in another area, instead of the current one, stuff like that…
After figuring this out, it was easy to fix, but time-consuming, because I had to move a lot of code from one class to another and remove all singletons (not many, though)…
Anyway, still have a couple more small bugs and I’ll go back to some polish…
Now listening to “Shadowmaker” by “Apocalyptica”
Link of the Day: Here you go, a fun parody of the upcoming Superman V. Batman:
As the title indicates, mostly that kind of work…
The bugs were mostly small things, like the way one of the voxel faces UVs were not correctly mapped, moving the near plane of the camera when it was too close, etc…

Also polished some things related to the camera controls… Now the character will turn the right away, depending on the camera orientation.
I also played the initial part of the game again, and I’m not really happy with it… It doesn’t grab the player as much as it should… It’s the beginning of the game, so the player should get excited… The excitement of the game builds up during the game, but those first moments are crucial, so I might need to redesign it…

Now listening to “A Matter of Time” by “Voicians”
Link of the Day: Here’s a really good read about a full working game-worthy rendering pipeline… It filled me with ideas about my own, but I need to stop adding stuff to the task list!
https://interplayoflight.wordpress.com/2015/04/08/the-rendering-technology-of-skysaga-infinite-isles/
I spent a lot of time looking at a bug all wrong…
I noticed that the voxels that had transparency were rendering wrong:

Check out the front window of the ship…
Anyway, my first thought was that I was adding to the vertex buffers the faces between two adjacent objects with the same material, but after looking and looking at the code, I couldn’t see where that would happen… Nothing I changed lately would break that code, so it felt weird…
Out of inspiration, I tried running the game in DirectX instead of OpenGL (been running the game in OpenGL since I made the port, so I can see if something is wrong)… And in DirectX the problem didn’t appear…
Then I tried isolating a single voxel to see if it had any problems, and I couldn’t see anything as well… Only when I added multiple voxels the problem would be apparent…
In this process, I figured that the backface culling wasn’t working properly, because I was seeing faces that I shouldn’t (the backfaces)… Thinking about it a bit, and considering that alpha objects don’t render to the depth buffer, I finally figured out that what I was seeing wasn’t the face between the voxels, but consequence of the parallel nature of the GPU (multiple triangles are drawn at the same time, not one after the other), allied to bad backface culling (backfaces and frontfaces were rendering) and the fact I wasn’t writing to the depth buffer (so it wasn’t resolved properly)!
Investigating a bit more, I figured out that the problem was that the backface culling wasn’t setup only with glCullFace, but I also had to do glEnable(GL_CULL_FACE) or glDisable(GL_CULL_FACE), depending on the cull mode…
Then, the result was this:

It looks cool, but it’s all wrong..
Culling was reversed, and not only that, it was doubly wrong, which resulted in the ambient occlusion being wrongly computed, which creates that negative aura effect!).
After inverting some flags, I finally got this:

So basically I lost 3 hours because I don’t read documentation properly… 
Now listening to “The X Factor” by “Iron Maiden”
Link of the Day: Another game with great aesthetics… Indies are really raising the bar nowadays: http://triple-eh.tumblr.com/
Today I did mostly polish on the game.
First I worked on giving some visual feedback to the player about where he can or not fly the ship:

Then I added code to build “asteroid planets”, much more irregular… It was a bit hard reaching the balance of “don’t want to code this whole thing just because of a background item” and “this looks terrible” 

It adds a bit of variety, which is one of the things I appreciate in games: that moment when mid-way a game you still find something new, not only in terms of storyline, but also in terms of game-world, scenario, etc…
Tomorrow is bug-fixing day, since I found a bug that’s annoying me to no end… 
Now listening to “Piece of Mind” by “Iron Maiden”
Link of the Day: This looks AMAZING:
I spent most of my time today creating a page on Playfield, a site that generates pages for indie games.
It’s still in beta, but it already looks very cool, and for us that dislike any kind of web programming and rather spend time working on the game than on the marketing (although I recognize that’s almost as important), it’s a real time saver!
You can check out the game page at http://playfield.io/gateway, spread it around! 

The only thing it’s remaining is to have a blog feed somewhere… But it looks way better than this blog… If I wasn’t lazy I’d do something like this for this site, but I rather spend that time working on the game… 
Now listening to “A Sense of Purpose” by “In Flames”
Link of the Day: I always loved the Deus Ex games, from a thematic and a game perspective, and although Human Revolution wasn’t as good as the first one, it was a very nice step in the series… So I’m excited about this: