Cool VES Game Engine

Now this is exciting! The graphics engine of Cool VES (that is used by CoolBasic Classic) is currently the most complete sub-project of this entire development process. It’s already featuring all functionality that current CoolBasic does, and even more. This blog entry focuses on to introduce the new graphics engine (with a little surprise at the bottom), and will shed some light to the matter. The new graphics engine is considerably faster, and is now fully GPU accelerated. It uses OpenGL for rendering, and it’s also cross-platform *cough*. We take advantage of modern graphics hardware, thus enabling us to use some advanced effects, which means that CoolBasic Classic users will be able to create stunningly good-looking graphics if they’ve got the skill. Now excuse us about the quality of the preview images you’ll find all over this entry: they’re our internal work and made for testing, and don’t generally look that good. They simply haven’t been meant for demoing/promotional purposes. That’s why there’s lots of test data visible on screen as well. However, they do actually cover a major part of features from the new engine. We’ll create some ‘properly-finished’ sample images at a later time. But now, on with the preview…

Let’s take a look at these 3 images (click for a larger version):
Graphics demos

First Image (on the left)
This one has a lot of going on on the screen. It was one of our first test programs. FPS without 2D drawing is very high. It’s difficult to exmplain everyting as you can’t see it on the move, but here’s a somewhat complete list what you can see in this demo:

  • We have basic object loading from an image file in place. We’ll also support loading from memory and from pack files in the future
  • We can move, rotate, and scale objects realtime without any performance hit. Come new era of particles!
  • Objects support alpha channel extracted from the image texture (encoded in PNG images)
  • We can change the mask color to enable transparent backgrounds
  • We can colorize objects by changing their base color (the red cube)
  • Objects can have a custom-located anchor point around which and according to which they rotate and scale
  • Objects can be alpha-blended (i.e. ‘ghosted’) by a given percentage
  • Objects can have custom drawing order (user-defined Z-depth)
  • We have multiple blend modes, including (but not limited to) additive (lightening) and multiplicative (darkening)
  • We can load fonts and render text to screen
  • Basic 2D drawing works too: lines, dots, rectangles, triangles, and ellipses. Filled or not
  • We can now rotate and zoom the camera in addition to objects! This means we can affect how the entire game world ends up being presented on screen

This is not visible, but we also have a solution to draw static UI elements and backgrounds at absolute screen coordinates as well as showing images in the old-fashion way, i.e drawing them only once. We’re still discussing about normal images, but it just might be that we end up consolidating everything to objects as they can be rendered in much more diverse way than just plain images can.

Second Image (in the middle)
This one demonstrates available filtering modes which basically affects the quality of drawing rotated and scaled (or otherwise transformed) game objects. We can instruct Cool VES to render graphics in a pixel-perfect fashion, which might work well for UI, but in general game objects look better when a filtering is applied: either a bilinear or trilinear methods can be used. We may add additional modes in the future.

Third Image (on the right)
I saved the most delicious one last. First of all, we have multiple viewports, which is cool because it enables more than one camera inside the game world! This will give the users new possibilities to create, say, multiplayer games. I mentioned at the beginning of this blog entry that we take advantage of modern hardware. What you see in 3 of the viewports are actually shaders. They can be used to post-process the rendered game world, or to enhance single objects through our new material system. The possibilities are quite limitless, and I expect to see very beautiful water effects, motion blurs, and color tone-affectors in the future.

The top-left viewport uses a shader that renders its contents in grayscale. Although this is a very simple shader, it’s quite commonly used effect in gaming. This grayscale effect is achieved via a relatively simple shader code:

void test()
{
vec4 texel;
vec3 colors;
float average;
texel = texture2D(p_Texture,gl_TexCoord[0].st);
colors = texel.rgb;
average = (colors.r + colors.b + colors.g) / 3.0;
gl_FragColor.r = average;
gl_FragColor.g = average;
gl_FragColor.b = average;
gl_FragColor.a = texel.a;
}

That’s the contents of the shader file – Cool VES loads shaders from normal text files.

The bottom-left viewport uses a blurring shader, another widely used effect in gaming. It could be used to achieve nice effect to emphasize something on the screen (while the background gets all blur).

The top-right viewport enhances whatever is under the mouse with increased intensity, making everything underneath to ‘bloom’ out. Can be used, for example, to highlight explosions and such.

The final viewport (bottom-right) visualizes a scene graph. Cool VES optimizes rendering through this system. It’s now also possible to assign child objects to parent objects, creating hirearchical models! We can literally construct game characters by attaching the limbs, which are separate objects, to each other, and then, for example, animating them according to custom made sequences (yeah, object animation is no longer limited to image strips). Since object hierarchy enables us to ‘glue’ objects to each other, it’s extremely easy to make objects automatically move and rotate with their parent. Imagine a health bar attached on top of a game character.

Physics

Let’s take a look at these 3 images (click for a larger version):
Graphics demos

Ok, this is really really cool stuff. We’ll replace the old collision system entirely with a 2D physics engine! All collisions between game objects are now affected by full rigid body dynamics. Basically every game object can be applied with a collision shape, mass and a few more attributes. Once set, Cool VES will automatically update them with full physics response! The collision shape can be of any convex or concave polygon, or a simple primitive. We can also access the collision data to determine what happened to any object. Objects will bounce off/collide with each other or static obstacles.

The first demo (on the left) has some static immovable objects horizontally aligned in the center, and lots of bouncing dynamic objects: they get impulse outwards whenever they collide with anything. There’s also a keyboard guided triangular ship flying (at the moment of screen capture, located on the right side). Although very simple, toying with the ship, all objects involved, was quite fun.

The middle image demonstrates liquid physics where a keyboard controlled circle object swims in a sticky goo.

The image on the right combines everything. It’s a pinball test with zoomable and rotateable camera. Collision data has been added and it follows the contour of the image. You can also add new collision walls to the screne by mouse – on the fly!

Networking

Cool VES will finally feature in-built networking using TCP/IP and UDP. More info about that later, but it’s very likely that we’ll build some sort of high level command library to handle some advanced mechanics, such as interpolation and extrapolation (to overcome latency issues), automatically.

Comments are closed.

Copyright © All Rights Reserved · Green Hope Theme by Sivan & schiy · Proudly powered by WordPress