Wednesday, June 5, 2013

GEn3CIS: An HTML5 Based 3D Engine for Gaming and Simulations: Part 1

A Little Background

Multi-threading in JavaScript is a topic that is near and dear to our heart.  But a topic that does not seem to get much attention or love on the web.  I have tried "Bringing The Sexy Back To WebWorkers" by presenting at conferences ranging from Game Developers Conferences (GDC) in Austin, San Francisco and Shanghai, China to HTML5 specific conferences such as HTML5 Developers Conference, Dallas Meetups and Ft Worth Code Camp.  My goal was to show the power of Multi-threading in JavaScript and the need to transition our serial code execution to parallel processed execution to start taking advantage of the multicore hardware being used today.  This lead me to start developing a platform that would allow me to demonstrate just how powerful this technology could be,  enter JaHOVA OS.

Most of the slides from past presentations can be accessed from here.

JaHOVA OS
JavaScript HTML5 Online Virtual Application Operating System

JaHOVA OS is an open-source online platform that was designed from the ground up to be flexible and modular.  The goal was to have on demand multithreading capability.  The OS allowed for any method to be serialized and sent over to a WebWorker so it could be executed in parallel of the main application   You could also load external scripts and connect up to the main OS via a "Thread Controller" (more on this later).  To demonstrate this functionality I built a 2 player Networked 3D Game (really just a tech demo) utilizing WebGL, WebSockets,  WebWorkers and Node.js called Omega Resistance v0.1 


The goal was to maximize my frame rate (Frames Per Second: FPS) while handeling Graphics, Physics  Artificial Intelligence and Networking.  Keeping FPS above 30 is crucial for real-time graphics.

The results were great!

As you can see from the chart, when using the multithreaded environment my FPS never fell below 35FPS, but without the browser was not able to keep up with over 55% of all frames rendering below the required 30FPS.  The full writeup of the results can accessed here.

With results that good, I figured lets push my design and just see how far we can go.  Sadly, not much further.


JaHOVA OS was built to allow single or multi-threaded operation for basic web applications to complex distributed applications severed from the cloud.  So once I started adding more complex code to the mix (i.e. Higher Graphics Demands, Full 3D Rigid Body Physics and Collision Detection/Resolution, Higher Level Artificial Intelligence, Gamepads, etc), the FPS dropped.  Version 0.2 of Omega Resistance fell below 30 FPS on lower end machines which hindered gameplay.  The video to the right shows off the upgrades made to Omega Resistance and is online and playable at or.gametheorylabs.com.

After some profiling and debugging the problem became apparent.  JaHOVA OS could not meet the needs for a high performance real-time application such as Omega Resistance, due to its design to be both single and multithreaded.  I need to build a custom platform that was designed from the group up to handle real-time 3D graphics as well as run complex optimization and simulations applications.


From this problem, GEn3CIS was born.

Part 2 of this series will go into various multi-threaded architectures and specifically show the proposed architecture for GEn3CIS.


All code demos can be found in code repos located at git.gametheorylabs.com


1 comment:

  1. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a Front end developer learn from Javascript Training in Chennai . or learn thru JavaScript Online Training from India. Nowadays JavaScript has tons of job opportunities on various vertical industry. JavaScript Training in Chennai

    ReplyDelete