Day 7. Static and dynamic lighting

1. Static lighting, lightmapping.

Lightmapping is very important for me as i’m lazy graphic designer and i love to have some help with lighting. Of course base for robust lightmapping techniques is Global Illumination.

Thanks to GI we have nice, realistic, smooth gradients in scene. Great addition to GI but not neccesery connected with lightmapping is Tone Mappinig. It’s mostly usefull if we go for realistic style. But either way i like to have possiblity to bake tone mapped version of light.

Last but very important thing is Image Based Lighting. I just love games using this techinque to produce static lighting for scenes. First one that comes to my mind is Killzone 2 and 3. Game looks great and uses IBL for static lighting and light probes for dynamic lighting. These two provide great tools for artists.

So perfect solution for me is possibility to create static lightmapps using Global illumination, Image based lighting and of course standard lights including mesh lights. Which engines provide full support for all these features. None within my indi budget. But we can create nice and cheap pipeline which will provide us with all these features. So recipe for great static lighting goes like this:

I can’t wait to buy full version of vray to start production tests. For now i used demo version and baking works great. Quality of vray plugin for blender is outstanding! As for price, in EU it’s 315 Euro for Vray and 35 Euro for USB dongle. Blender of course is free.

So final price tag for our static lightmapping workflow is 350 Euro which is nice!

2. Dynamic lighting with deffered shading and light probes.

Forward lighting is big performance eater. Because of that there was need to create more flexible solution. Currently most popular approach to dynamic lighting is deffered shading. This technique is great for crowded scenese with many lights. Drawbacks of deferred shading are bigger performance drop for simple scenes and some problems with big lights (which can be overcome with tile bassed deferred shading).

Second, additional technique to deferred shading is dynamic lighting using Light Probes. Idea behind it is very simple. Artist create light probes in crucial parts of the map. Then these probes are used to light dynamic objects like characters. In connection with static lighting, light probes can create immerse enviroment.

One probe contains approximate light information from all main directions at specific position in scene. Best solution to generate light information is to use Spherical Harmonics. Ready to use solution with explanation is presented in „Orange book” http://www.3dshaders.com/home/.

How to create cheap pipeline which will include those two solutions? I can’t get anything that will be perfect.

Esenthel engine:

  • Deferred lighting
  • Available Shader pipeline
  • Sadly no Occlusion Culling.
  • 150$ and license for one game.

Unity3d

  • Deferred lighting
  • Available shader pipeline
  • 1500$ for Desktop, additional 800$ if we want android and ios. (or additional 3000$ if we want advanced).

Shiva

  • No deferred lighting
  • No shader pipeline
  • 223$.

UDK

  • Deferred shading
  • Node Shader pipeline, Don’t know if it’s possible to write more advanced shaders with custom input, needed for Light Probes.
  • 99$ and 25% after first 50 000 $.

So there is no perfect solution. I could use Shiva for mobile and Unity3d for desktop. For now that idea looks best. But if i could implement occlusion culling in Esenthel i would save some money.

UDK looks promising and it could replace Unity3d. But i need to test shader node pipeline. If implementation of Light probes will be possible i will go with UDK.

If not i will try to write implementation of occlusion culling for Esenthel, based on available papers and COH alghoritm. If i succed i will go with Esenthel for Desktop and i will stay with shiva for mobile and tablets.

If i fail with UDK and Esnethel i will need to start saving money for unity3d.

I also thought a little about using Ogred3d and collect some available libraries, but after some research i decided that i’m to stupid for that.

I’ve got nice solution for static lighting and some open selections for dynamic one. Of course robust dynamic lighting is not so important, especialy for mobile but i want to create immersive maps and light probes could help me with that.

Day 6. Occlusion Culling research and Engines first sum up.

I made a little research on topic of occlusion culling. I found 4 most popular methods:

  • 1. Coherent Hierarchical Culling
  • 2. Hierarchical Occlusion Maps 
  • 3. PVS
  • 4. Portals and sectors

1. Coherent Hierarchical Culling

Most universal and quite fast method. I was impressed by it’s performance. In addition author wrote whole paper about COH with sources. Should be easier going from here:

Paper:

http://www.cg.tuwien.ac.at/research/vr/c…chcull.pdf

Examples (only second one works for me) http://http.download.nvidia.com/develope…ent/06.zip
Press 1 for occlusion preview, space for changing method (frustrum by default)

City example: http://www.cg.tuwien.ac.at/~matt/chc++/FriendlyCulling.zip
There is whole folder available with some examples http://www.cg.tuwien.ac.at/~matt/
I would love to learn how to implement it within Esenthel.

2. Hierarchical Occlusion Maps

It seems to use occlusion maps and alpha testing.
Paper and video on HOM: http://www.cs.unc.edu/~zhangh/hom.html
http://www.youtube.com/watch?v=8i0A00iNijs

3. PVS

It seems as best solution for Mobile and it’s already used by shiva and unity.
http://en.wikipedia.org/wiki/Potentially_visible_set
It could be easy to implement it inside Esenthel.

4. Portals and sectors

It’s good addition to methods above. Especialy if game include mixed enviroment of outdoors and indoors. Not usefull for open world only games, or game where indoors are loaded as separate location (Skyrim).

I don’t need very robust occlusion culling solution for my game, but even simple occlusion culling could provide great performance improvement. It would be possible to create quite detailed location with properly located occluders, especially for PC and Mac.

So which engine ?

I’m a little torn appart. I tested a Esenthel engine lately. Whole engine performs beautifully for huge amount of objects and it’s a lot faster then Unity3d and Shiva for PC.
But sadly Esenthel provides only Early Z occlusion culling method which is not great for my game structure. And it’s far behind occlusion culling available in Shiva or Unity3d.
So I don’t really know in which engine invest my time and money  (I already have Shiva3d)

I hope that performance issue will be fixed in near beta release. But at the same time i’m testing other soultions as they are kind of similar if you learn basic structure of Game engines. Current sum up looks like this:

Shiva
Pros

  • Nicely working occlusion culling with PVS, static and dynamic occluders.
  • Great, consistent Editor.
  • Lots of supported devices.
  • Price to value ratio.

Cons

  • Huge performance problems with higher amount (5000 >) of objects for PC.
  • Hard to extend for now.

Unity3d Pro
Pros

  • Awesome occlusion culling.
  • Awesome, extendable and consistent Editor.
  • iOs, Android available for extra bucks.

Cons

  • High price tag for iOs and Android.
  • Medicore performance for higher amount (10 000>) of objects on PC.
  • No built in Pathfinding. But it has nice external one.

Esenthel
Pros

  • Superb performance for huge amount of objects (10 000>) on PC.
  • Nice editor.
  • A lot of graphical features.
  • Easily extendable.
  • Price to value ratio.

Cons

  • C++, but API itself is super easy and backed by lots of examples
  • No robust occlusion culling. It’s “deal breaker’ for me at the moment.
  • No real docs. But again, lots of examples instead, and documented headers.

Day 5. Time for drawing and prototyping.

So after 5 days, i feel confident to start prototyping destruction. And so i decided to create concept of “The Tower”. Below is result of my drawing session. Next step, 3d model in blender and then finaly textures and baking lights. Along that i need to remember about creating structure for building that will be reatively easy to access by mesh api. I want to use as small amount of objects as i can. I see some areas that will be problematic but i will try to overcome problems and create final model as interesting as possible. Towers will have important role in game :P

Dev 4. Shiva parenting performance and New interesting engine.

Thanks to NiCoX help, i know now that parenting in new version of Shiva engine is very pricy task. It was causing big performance drop for huge amount of object.

Details on that topic here.

So without parenting i get 2 – 3, genearting 80 000 object with colliders. It’s good :)
Using parenting i end up with 144s,  LUA or C++, same thing. I hope that in the end stonetrip will provide performance fix, and we i’ll be able to safely parent huge amount of objects, which can be useful for combineRuntimeObjects.

So as i said few post before, i feel confident going further with Shiva, but meanwhile i found realy nice engine that has stunning amount of features for afordable price.

Esenthel

I saw this engine before, but it was long time ago and i wasn’t to much into game developing. But even then people were talking about enormous amount of features done by one Dev.

Now, with a little more experience with Game Engines i decided  to test as many features as i can and make some performance benchmarks before going further.

Mine main concerns lays in iOs and Android perfromance. But i could just stay with shiva for that part and use Esenthel for Desktops. Whichever way i choose to go it’s nice that there is Mobile support ( only gles 2.* ). Second concern is about performance. But i saw some complex commercial mmorpg game created with this engine and it made me a little calmer.

So what are benefits. There is evertyhing that good engine should have. From occlusion culling to deffered lighting. World editor with possibiltiy to create literally endles worlds. There is even mesh structure supporting creation of minecraft like games :) You can see all features for yourself: Esenthel Features

Ok, so there is a lot of everything including possibility to write your own Shaders and access to source code for selected Engine parts ( depends on choosen license ). I’m realy impressed how engine looks on paper. But how it will perform in real world cases. I can’t wait to test it out :) Currently i want (very much) to try creating Light probes with Spherical Harmonics. If i could get it working with good performance, i would be thrilled :)

As for my current task with destruction module, i’ve tested Esenthel C++ examples for Mesh api and i don’t see any obstacles. I also need to add that amount of examples is impressive. Most of features have simple and clean c++ examples :) C++ it’s not that scary when all heavy codding is already done for you.

Ok, so everything is awesome. I can even test big part of engine for free. Sadly free version doesn’t support custom shaders and it’s one of a things that i want to test out. But it’s allright, price for personal license is set at very afordable level and i’m afraid it could go higher in near future (today came Android support) :) So before i decide to buy it i only need to get some answers about licensing and create basic benchmarks for mesh api and performance on my old mac machine :)

As for shiva, i don’t plan to change engine. I will select prefereable engine for specific game ideas and targets. So for sure i will feel safe with shiva for mobile and old desktops. As for more power demanding game ideas i could go with Esenthel. It’s nice to have choice :)

Day 3. Shiva C++ Performance and Unity colliders

Today i spend time testing Shiva performance for huge amount of colliders. And i’m happy with results.

For amount of 40 000 box colliders shiva performs beautifully. Raycasting is very fast and i don’t see any big drop on perfromance.  I get 57 – 60 fps with mad raycasting everywhere using mouse click. CPU usage stays between 3 – 6 % on my i7 machine.
Even with 80 000 box colliders performance is allright. 40 – 60 fps.
I think i will never have 80 000 active colliders on my scene, part of them will be deactivated by frustrum and others by distance. I feel comfortable to begin filling my buldings with grid of colliders for destruction detection.

I also performed  same test with sensors instead of colliders. For my suprise they perform very badly. With 40 000 box sensors i get 10 fps in avarage. Luckily i don’t need sensor features and for my task colliders are perfect.

Along with shiva testing i also had fun with Unity. I tried mesh generation and mesh collider update feature. Everything works as suposed but i need to test mesh collider performance vs primitive colliders.
For now i will focus on Shiva because of performance results for raycasting with huge amount of colliders.

Working with shiva i also noticed some performance problems with C++ compiled version. Here it is topic about that.

Day 2. Shiva problems and trying some Unity Love.

During prototyping i faced some problems with Shiva engine. Colliders for object’s can’t be scalled in runtime. And second one, I can’t apply collider to mesh created in runtime.

Problem was know sinc 2009, but despite some plans for changes in Physic engine, nothing happened:

Collider problem

So I decided to try Unity and C# Api. I only tested simple raycasting and scalling mesh with collider. And it works ok. Now i need to test updating collider after changing mesh in runtime. Menwhille i’m waiting for new Shiva Beta relase with some improvements in that topic.

Along way i learnt to use Shiva mesh api and found really nice snipet for generating planes:

Create an arbitrary divided plane

Upcoming

I’m planing to test Shiva colliders further. Trying to create some sort of grid of them. Or maybe use sensors.
I will also try to learn Unity Mesh api and test if engine updates coliders properly.

Day 1. About project

Shit need to be done and this blog will provide diary of whole process. I’m new at game dev and .. writing in english. But i will try to do my best and improve upon time.

Blog will have two parts. 

First one will keep track of every day development. I will try to write about what was done and new ideas. I want to do something every day, even small things.

As for second part i want to write quality tutorials about some bigger things i learnt during development. Maybe in addition i will try to create screencast  but as for now i don’t think it’s good idea.