Monday, October 24, 2011

Ignition

It's been a while since my last post here, but there has been a good reason for the silence.

I took most of the summer off from the Jasper engine project mainly because I needed a break. Before the break, however, I worked on some low-poly trees and found some great videos that gave me a lot of new ideas. One of those can be found here and the other one can be found here.

Over the summer I also gathered some more game ideas, did some more animation research, and began preparing to take the engine into a game design phase. Much of the game design process will initially take place on paper, and I have given some thought lately to rolling out a short-term (1-2 month) game to demonstrate the engine's capabilities and to get some feedback. This way I could also run the engine through some more realistic tests and get some early user feedback.

I also created some basic trees in Blender and dropped some of them onto a terrain map for testing, but the screenshots are not all that impressive at this point, so I'll defer to a later date before posting those. That said, the major systems of the engine are all in place (particle systems, UI elements, sound, character animation, terrain rendering, etc.). The next goal is to either to start in on the major game I have planned or write up a small, side game project that may become available for download in the future.

Whatever the case, I'll post some more updates in the coming days as to where this technology is heading...

Friday, April 8, 2011

Debugging Is An Art

Most of the time, debugging is an art. It takes a careful balance of knowledge, hard-won experience, compiler tools, investigative skills, and loads of patience. But sometimes there comes a point when even these things have their limits and you throw your hands in the air in frustration trying to figure out what is going wrong.

Case in point: the strange texture bugs I was finding when I tested my engine on a Vista laptop.

Every other feature seemed to be working fine on the laptop, but every time I used a texture, the results were unpredictable. Often times, when rendering a tile map and some terrain features, the same texture would be used everywhere even though the tile map called for a variety of textures to be used...especially when rendering mountains.

Then, when testing some animation features, the textures on the animated model would look okay at first, but when I pressed a key (and another model came onto the screen), the texture on the original model swapped places with the new model that was being rendered.

Ugh.

Then I created a tile map with an array of textures just to test those functions.

The entire map was rendered with the exact same texture.

Can you say, hello brick wall? What was strange was that the issue was only occuring on the Vista laptop, and was not occuring on the XP box or the Windows 2000 I tested the engine on.

Somewhere, in the back of my mind, I kept wondering if it was a graphics driver issue.

I started eliminating possibilities. Was there some unitialized variable somewhere that was holding unpredictable values? Nope. Was the texture loading function failing? After lots of investigative work, the answer appeared to be no.

Then, I spotted a type/casting issue. Surely that must be it, I thought. Fixed the bug. Recompiled and tried again.

No dice.

At this point, things were getting discouraging. To add to the issues, the frame rates on the Vista machine were down by 10-15 fps compared to the XP machine. I know it is a laptop with a low-end processor, but this was ridiculous.

So I checked out some forums. I looked into the OpenGL on Vista issues. I prayed about it. Ugh...I was ready to just give up and live with it.

Then, I checked on the graphics drivers issue. According to the Device Manager's "Update Driver" feature it said I had the most current version of the driver installed.

I didn't buy it.

I went to the manufacturer's website and checked on the drivers that were available. And wouldn't you know it, there was a driver out there that had an update date of 2007 (vs. 2006, which was pre-installed on the machine itself).

At this point I was so used to hitting brick walls with these bugs that I didn't hold out hope. I was preparing a "Plan B". And C. And D. And E...

I installed the new drivers, ready to hit the rollback button if necessary.

And then I tried the engine again.

In one swoop, a whole class of bugs was wiped out. Every. Single. One of them.

The texturing issues went away. Completely. The frame rates shot up 10-15 fps, and in some cases it was faster than my XP machine. Wow what a relief! Now I can really, truly, start focusing on game design.

Moral: check your drivers!

Monday, April 4, 2011

Water, Water Everywhere

Today's screenshot, while rather uneventful looking, actually represents a significant step forward for the engine.


It represents weeks of work...and the final promotion of the water mesh concept into the map tool (and subsequently rendered by the engine). In other words, I can now add water meshes/features to my tile maps, similar to how terrain features (mountains, hills, etc.) can be added to a tile map. Then, when the map is imported into the engine, it will be rendered as a water feature, just like other terrain features.

Additionally, I have also been testing the engine on a Vista machine, as well as a Windows 2000 machine. There are a few minor bugs on each system to work out, but they are not showstoppers. At this point, the engine is officially "feature complete" and I'll be enlisting some other users soon to get rid of as many bugs as possible before moving ahead with games building.

Next up: the game design phase. :-)

Tuesday, March 22, 2011

Testing News

No screenshots today...although I have some testing news. I began to test the engine on other systems, most notably a laptop with Windows Vista installed on it. The tests ran reasonably well, although there was a 10-15 fps performance drop on terrain rendering and UI rendering, but that was to be expected considering it is a Celeron/Windows Vista Basic laptop. I'm just happy at this point that it is working without a hitch for the most part. Hopefully at some point soon I'll be able to test it on a Windows 7 system, too.

Over the next couple of weeks I also plan on making some tool updates and will promote the water/mesh functionality I developed over the past month so that it is on par with the terrain map feature I have in the map tool today. I'm also continuing to improve the UI functionality I mentioned previously.

Tuesday, March 15, 2011

More Waves and Dialog Boxes

After several weeks of testing several different algorithms, I think I've finally settled on one for rendering basic waves (without the help of shaders). It's been a long road, and oddly enough, I've pretty much come back to where I started, with some minor modifications to an original idea...combined with a minor discovery. First some wave screenshots:


The new algorithm essentially checks the nearby eight vertices (as opposed to the four I was originally working with) and averages them. Also, when a waveheight initially passes over a point, it essentially starts the point "spinning" around. That angle is translated via a sine function into a value which is added to the point's height. The key discovery I made was that through this combination, I could make each vertex of the mesh simluate a dying sine wave by continually decreasing the radius value in the following equation:

y = r * sin (angle)

Basic trigonometry, yes, but in all my previous testing I ignored the r component for some unknown reason.

I've also been busy working on some 3-D dialog box improvements, seen here:


In this screenshot, I'm demostrating some basic checkboxes, a slider control, a textbox control, a button, and an image control. All on a fully rotatable, 3-D dialog box/window. The main use for this will be heads-up-displays, pop-up dialog boxes, etc. It is also fully alpha-blending enabled.

With these items nearing completion, I'm now turning the corner towards actual game design. There is one last stubborn textbox bug to squash, and after that I'll run some tests over on my Vista box. Then...it's design time!

Thursday, February 24, 2011

Rendering Waves, Part I

For the past couple of weeks I've been testing several different algorithms for water rendering. I've limited myself in terms of technology a bit because of the age of my video card (7+ years old) and to keep the user base somewhat broad...therefore...no pixel shaders or any effects like that. Yes, I can go out and buy a shiny new high-end graphics card, but again, it would ultimately limit the user base down the road because of my tendency to want to push my graphics hardware as far as I can. :-)

I started out by building a basic mesh class (jMesh), and then running various functions across the mesh data. One of the most peculiar algorithms I came across "averages" the four surrounding points to calculate the current point's height on every pass:

y0 = (y1 + y2 + y3 + y4) / 4

I'm not sure who to credit for coming up with that, but I thought I'd give it a run and see what happened.

I was surprised to see that when I randomly dropped raindrops onto the mesh, little wavelets spread out from each drop and then faded out. Soon, though, I ran into some limitations of this concept because I wanted my waves to propagate out further and (hopefully) reflect off some walls I'd set up at the edge of the mesh.

Today, however, I spent some time paging through a 1960's physics book and came across a diagram of something called a "wave machine". That, along with the explanatory text beneath the photo, gave me some new ideas. The text described the wave machine and how it worked. As a result, I changed course on my own algorithm tests and added an "angle" value each point on the mesh. Also, I let the x coordinate and y coordinate of each mesh point be controlled by output of a sine and a cosine function.

The result?

What is difficult to see in this screenshot is that the entire mesh is in motion, and it looks pretty close to what a storm-tossed sea would look like. With a little bit of coloring, and some mountains thrown in, it looks like this:

Maybe I should post a movie at some point. Anyway, this new algorithm is a cross between the sine/cosine functions my own "averaging" type function that has damping and a whole bunch of other variables to play around with.

One key design point I want to make here is that because I've generalized all this into a generic "mesh" class, it opens up a lot of new possibilities such as basic cloth simulation, erosion-generated terrains, etc. I suppose you could also use some of it for creating landscapes altered by earthquakes. One other thing I plan on testing down the road is whether this could be morphed into a semi-realistic cloud mesh for cloud banks.

Tuesday, February 15, 2011

3-D Dialog Boxes, Part II

Things are moving along pretty well with the game engine...and there have been some recent updates to the 3-D dialog/GUI functionality. So far, the dialog box library can render buttons, picture boxes, text, etc. I'll be adding textboxes soon, too. Again, every GUI that is created with this library is fully 3-D (capable of being rotated, scaled, etc.) and has alpha-blending capabilities.

As usual...here are some screenshots...


Friday, February 4, 2011

Electric Maze

I threw this together in an about an hour or so. Just another test to see how fast I could create a playing field...in this case, a Tron-like 3-D maze.



Thursday, February 3, 2011

Mountains

Here are a couple of screenshots demonstrating a basic mountain range made with the contour map tool. This was a basic test not only for the map tool but for the engine itself.

Several engine features are at work here, including terrain rendering, tile map rendering (brown ground tiles) and the skydome (along with a sunset). It probably took me less than an hour to create the tile map, the mountain range (using contours), and the mountain/ground textures. This scene can be viewed from any angle or elevation, by the way.


I have yet to perfect the sunset/sky coloring yet (or clouds for that matter), although the algorithm I created for it is up and working properly. Now it is just a matter of adjusting some color tables I've created for the skydome to make it look a bit more realistic.

Thursday, January 27, 2011

Turning the Corner

I've entered a new phase with the engine...bug cleanup and performance testing. At this point  I've pretty much locked the codebase down in terms of adding new features. Now it's a matter of speeding things up and pushing the limits of it to see where improvements can be made and to identify any lurking bugs. Then...it's off to design a set of games!

In a few short weeks, I'll post some more pictures of where things are at with the engine and the game itself. For now, here is a feature list of what is currently up and running in the engine:
  • Skydome rendering with a time/date based sun position, time-of-day shading, and star rendering
  • Tile map rendering (using height maps)
  • Terrain feature rendering (for higher detail features such as mountains, hills, rivers, etc.)
  • Keyframe character animation
  • Wavefront model rendering (.obj format)
  • Collision detection
  • Basic physics properties for all objects in the game (mass, velocity, acceleration)
  • Basic shadows
  • Billboard rendering
  • Particle system that can render particles, billboards or models
  • Keyboard/mouse input
  • Gameboard rendering (with model pieces)
Concurrently, two tools have also been developed alongside the engine: a particle system design tool and map design tool. The map design tool can create gameboards, terrain features, tile maps, and more. Additionally, the map tool can take an existing contour map and convert it to a height map...or allow you to create your own from scratch with adjustable contour lines.

Underneath all of this, however, is the fact that this engine if fully object-oriented, and that the graphics portion is written in OpenGL. This opens the door to potentially porting games down the road to the iPhone, Linux, and maybe even the Macintosh platform.