New A.I. system, PhysX 3.1.1 and fixed that damned water transparency and depth sorting issue

The A.I. part:

For a final’s exam this semester, I had to develop a multi-agent system that could play team-based 2-on-2 tenis (with a soccer ball) and came up with this:

It’s just the first test of the AI Framework used to create multiple agents for single or team-based interactions. Just a test of visual sensors, communication, coordination and stuff like that.

Also a test of thread safety for the SceneGraph as each entity’s local transformation matrix is modified by the AI thread and rendered in a separate thread. 3 threads, one pointer 🙂

Some shadow artifacts occur during mid-video, but that’s due to the not yet finished PSSM system I’m working on. Also. don’t mind the complete lack of animations :)) I have better things to code for now.

Performance is choppy due to the Profiler from VS2010, Fraps, the code being compiled as a debug build, shader failing on the ball. Also, the quality is low as this video is used to pass my AI exam, and I don’t have a lot of time to waste on compression.

The PhysX part:

nVidia released the 3.x iteration of it’s PhysX SDK which you can read about  >>here<< so I thought of adding it to the framework. Specifically the 3.1.1 iteration (info >>here<< )

After some long coding sessions, the API was up and running, driverless and really fast. Only simple box-collisions for now, but it proves that the API is syncing data with the SceneGraph nicely and in a thread-safe manner:

The water transparency stuff:

Water wasn’t really transparent, because 2 very important states, culling = off, blending = on, weren’t set correctly while rendering. This was due to the absence of a Render State Manager and a Render Queue. Everything was rendered via a recursive callback on the SceneGraph. Adding a Render Queue sorting method and some minor changes to the State Manager, I finally managed to properly switch states and render transparent objects in a back-to-front order. The result? Well, semi-transparent water:

Underwater transparency

SceneGraph and ResourceManager

[notice][Warning: This post will be updated as I progress][/notice]

For now, the basic SceneGraph structure for the island scene produces this output:

( root )
-Sun ( Sun )
-box ( box )
--box_box.obj-submesh-0 ( box.obj-submesh-0 )
-Default omni light 0 ( Default omni light 0 )
--Default omni light 0_impostor ( Default omni light 0_impostor )
-SkyBox ( SkyBox )
-waterEntity ( waterEntity )
--waterPlane ( waterPlane )
-test ( test )
--pin_7 ( pin )
---pin_7_pin.obj-submesh-0 ( pin.obj-submesh-0 )
---pin_7_pin.obj-submesh-1 ( pin.obj-submesh-1 )
--copacel_5 ( copacel )
---copacel_5_copacel.obj-submesh-2 ( copacel.obj-submesh-2 )
---copacel_5_copacel.obj-submesh-0 ( copacel.obj-submesh-0 )
---copacel_5_copacel.obj-submesh-1 ( copacel.obj-submesh-1 )
--pin_8 ( pin )
---pin_8_pin.obj-submesh-0 ( pin.obj-submesh-0 )
---pin_8_pin.obj-submesh-1 ( pin.obj-submesh-1 )
--copacel_10 ( copacel )
---copacel_10_copacel.obj-submesh-2 ( copacel.obj-submesh-2 )
---copacel_10_copacel.obj-submesh-1 ( copacel.obj-submesh-1 )
---copacel_10_copacel.obj-submesh-0 ( copacel.obj-submesh-0 )
--copacel_1 ( copacel )
---copacel_1_copacel.obj-submesh-2 ( copacel.obj-submesh-2 )
---copacel_1_copacel.obj-submesh-0 ( copacel.obj-submesh-0 )
---copacel_1_copacel.obj-submesh-1 ( copacel.obj-submesh-1 )
--copacel_3 ( copacel )
---copacel_3_copacel.obj-submesh-0 ( copacel.obj-submesh-0 )
---copacel_3_copacel.obj-submesh-2 ( copacel.obj-submesh-2 )
---copacel_3_copacel.obj-submesh-1 ( copacel.obj-submesh-1 )
--pin_2 ( pin )
---pin_2_pin.obj-submesh-1 ( pin.obj-submesh-1 )
---pin_2_pin.obj-submesh-0 ( pin.obj-submesh-0 )
--copac_6 ( copac )
---copac_6_copac.obj-submesh-1 ( copac.obj-submesh-1 )
---copac_6_copac.obj-submesh-2 ( copac.obj-submesh-2 )
---copac_6_copac.obj-submesh-0 ( copac.obj-submesh-0 )
--infinitePlane ( infinitePlane )
--pin_9 ( pin )
---pin_9_pin.obj-submesh-1 ( pin.obj-submesh-1 )
---pin_9_pin.obj-submesh-0 ( pin.obj-submesh-0 )
--copacel_4 ( copacel )
---copacel_4_copacel.obj-submesh-2 ( copacel.obj-submesh-2 )
---copacel_4_copacel.obj-submesh-1 ( copacel.obj-submesh-1 )
---copacel_4_copacel.obj-submesh-0 ( copacel.obj-submesh-0 )

Fixed water and added shadows. Now … the SceneGraph …

Well, water is up and … flowing 🙂 Reflections are working nicely and so are caustic effects. Refractions are good but transparency needs tweaking. The hard part’s over:

Reflections working

Under water caustic effects

And shadow map generation is getting better and better.  Only directional lights are working for now, but still:

Shadow Maps

 

Now that the engine supports some more rendering eye-candy, back to logic behind the scenes. SceneGraph implementation is buggy, crash-prone, Resource Manager doesn’t work, Mesh – SubMesh <-> SceneGraphNode parent <-> children conversion not working etc. But … things are looking promising for the future.

Broken water and Post Processing effects

Been working on fixing water rendering issues (water plane Y-position keeps changing with camera movement) and ended up adding PostFX ;))

I’ll post the water issues later (when I find a fix for them, so that I don’t seem stupid for missing something obvious), but the post processing engine was needed for underwater rendering. So, since the code was already written, why not have some fun with:

Anaglyph rendering:

Anaglyph rendering

Bloom:

Bloom

Now, Depth of Field is already implemented, but depth calculations are still buggy and the image is just too blurred. Will fix that later.

On another note, just signed up for the GameDev section of this: ImagineCup

Trac is Up, Milestones are set, Framework crashes all the time .. great :D

Project Hosting:

As a recent attempt to make a friend see all of the changes I’m committing via SVN, I’ve moved the entire code-base to Trac thanks to the people at XP-dev.com.

What this means:

  • Timeline:  every change to the code is archived and documented on a line-by-line basis.
  • Roadmap: the various milestones we’ve set for the development process.
  • SVN hosting: everyone can download the code via a SVN client.
  • Ticket and Bug report systems: Submit bugs, ideas or changes for us to review.
  • And lots more …

 Commit interval:

Commits have been slow lately due to the following reason:

  •  Resource management in the code was a complete mess. No real relation between elements in the code. Thus, a SceneGraph was developed to help clear the mess. It was not commited to the main code base due to memory leaks and improper handling of FlyWeight object creation and shading assignment.
  •  The ResourceManager class was rewritten to create objects based on a ResourceDescriptor that contains the future object’s name, physical location on the disk (i.e. model files, textures etc. if they exists), flags for various conditions on create (i.e. flipped textures, no-material geometry). Not committed due to the same FlyWeight problem.
  • The Material system needs a rewrite. Switching between shaders all the time isn’t a good idea. Also creation/destruction is a complete mess.
  • Other minor bugs/improvements.

These changes are massive. They will reflect object management in scenes and proper loading/unloading of resources. Rendering large batches of geometry should be faster (forests?) and the whole scene setup easier to understand (SceneGraph defined/dumped in XML format?). Once this commit is in the main codebase, a lot of smaller ones will follow adding features: Shader/Material based batch rendering, Advanced lighting based on material properties, Deferred Lighting, Speed improvements etc.

If you look at the videos available on the main site in the media gallery, the time difference from the “OBJ importer” video and the “Grass generation” one is of about 6 months. From the last video until now (as of writing this post), it’s been well over a year. The changes ARE that massive. Hope future videos will prove that 😉 Until then … check for changes, and feel free to study the code and give feedback if you feel like it.

Crashes

Crashes

From the depths of my chair … I salute thee!

Ok, I’ll be adding some content to this, taking about who I am, and why am I here and stuff like that. Really busy now, can’t be bothered with blog filling non-sense, but I promise, stuff will appear here automagically.

Load more