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.
Thursday, February 24, 2011
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...
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.
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:
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.
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)
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.
Monday, December 27, 2010
Forward Progress
It's been a busy few weeks since I updated this blog, but I've been hard at work adding several new features to the engine. These new features have included basic collision detection, a sound system, and simple projective shadows. Right now, I'm in the middle of upgrading the lighting system to accomodate spotlights and multiple light sources (as opposed to one). This is taking longer than I expected, but theoretically it should be done by the end of the year.
In a previous post, I said I would talk more about one of the features I added earlier this year: the contour map tool. This tool (seen below) has two main capabilities. One feature is the ability to create contour maps from scratch, and then, using Bezier curves, allow the user to manipulate a series of concentric rings in order to create mountains, hills, lakes, valleys, or even simple riverbeds.
Eact tiny white ring in the picture above is a "handle" which the user can use to shape the blue contour lines. I can imagine this would get tedious if you wanted to create a multitude of unique mountains or lakes, for example, so in the future I might allow for some procedural mountains to be rendered by this particular tool.
The other feature is the ability to take a pre-existing contour map which has been pre-color-coded and then convert that into a 3-D heightmap (using the "Import File" option above). I haven't fully tested this particular capability of the tool yet, but I plan to in the near future with an area lake map. The goal, of course, is to create more realistic terrain features and hopefully begin to use various real-world features in the first game I hope to release using this particular engine.
Mt. Ararat, anyone? ;-)
In a previous post, I said I would talk more about one of the features I added earlier this year: the contour map tool. This tool (seen below) has two main capabilities. One feature is the ability to create contour maps from scratch, and then, using Bezier curves, allow the user to manipulate a series of concentric rings in order to create mountains, hills, lakes, valleys, or even simple riverbeds.
Eact tiny white ring in the picture above is a "handle" which the user can use to shape the blue contour lines. I can imagine this would get tedious if you wanted to create a multitude of unique mountains or lakes, for example, so in the future I might allow for some procedural mountains to be rendered by this particular tool.
The other feature is the ability to take a pre-existing contour map which has been pre-color-coded and then convert that into a 3-D heightmap (using the "Import File" option above). I haven't fully tested this particular capability of the tool yet, but I plan to in the near future with an area lake map. The goal, of course, is to create more realistic terrain features and hopefully begin to use various real-world features in the first game I hope to release using this particular engine.
Mt. Ararat, anyone? ;-)
Tuesday, December 7, 2010
Character Animation, Part I
Over the past month I've worked hard to complete one of the major features of the engine: keyframe character animation. As of this post, the engine is only supporting a customized format which can be exported from Blender (via a Python script). Here is a recent test I performed on the engine by exporting a spinning cube animation out of Blender:
The fps rate is decent (for a basic six-year old video card) even on animations with hundreds of triangles. At some point, however, I'd like to experiment with pushing all of the individual keyframe renderings into display lists instead of doing all the interpolation on the fly.
A decision was made early on (by me) to go with keyframe animation versus bone animation. Someday I hope to add a much more comprehensive set of animation functions that could handle multiple formats.
One thing to note, however, is that many of the objects in this engine (lights, models, billboards, character animations) are all full class objects with inhertiable properties from the parent class of "jObject". The basic jObject class declaration looks like this:
class jObject
{
public:
float mass; // for physics calculations
j3Dvector location;
j3Dvector velocity;
j3Dvector acceleration;
j3Drotation rotation;
objectstate state;
};
I have lots of ideas for these properties, but the obvious one is the soon-to-be-implemented feature of collision detection and basic physics calculations. :-)
A decision was made early on (by me) to go with keyframe animation versus bone animation. Someday I hope to add a much more comprehensive set of animation functions that could handle multiple formats.
One thing to note, however, is that many of the objects in this engine (lights, models, billboards, character animations) are all full class objects with inhertiable properties from the parent class of "jObject". The basic jObject class declaration looks like this:
class jObject
{
public:
float mass; // for physics calculations
j3Dvector location;
j3Dvector velocity;
j3Dvector acceleration;
j3Drotation rotation;
objectstate state;
};
I have lots of ideas for these properties, but the obvious one is the soon-to-be-implemented feature of collision detection and basic physics calculations. :-)
Subscribe to:
Posts (Atom)






