Light Prototype: Faking Dynamic Global Illumination in Unity - Part 1

published Friday, 1 April 2011, 12:00 by ZPSHicks

Join me in my first attempt to push lighting in Unity to meet our high ambitions for making Interstellar Marines as realistic and dynamic as possible.

Unity 3 have given us Deferred lighting so in this light prototype we'll see if I can create a lighting scheme close to Running Man while being completely dynamic appose to completely static.

Pre-Calculated lighting in Running Man
Hangar level in Running Man, lighting is completely static, created using pre-calculated lightmaps, looks good but is as dynamic as hardened concrete!
Hangar level in Running Man, lighting is completely static, created using pre-calculated lightmaps, looks good but is as dynamic as hardened concrete!

When we created Running Man in Unity 2.6 we relied on baking all lights into static lightmaps for performance; No doubt baked light looks fantastic, as it allows for calculating advanced and accurate global illumination as well as ambient occlusion, but with the obvious downsides of forcing lighting to be completely static as well as increasing the size of our builds (Mb) due to all the scene lightmaps.

Sure we would all love to have real-time Global Illumination like CryEngine 3 ... but experience tells me that we can get 80% of the way by faking it and the last 20% is a real nice to have at the moment, I guess we just have to wait till Unity integrates real-time GI in Unity. :)

Lets begin!

This prototype is created with what is available in Unity 3.3:

  • Spot Lights
  • What I'll generally use to create primary light sources as spotlights provides a lot of control and is perfect for casting shadows on key environment elements and dynamic meshes.
  • Point Lights
  • Used to simulate in-direct lighting from primary light sources as well as setting up very crude bounce light areas in the environment. 
  • Ambient Light (Render Settings)
  • I'll use this option to apply a discrete color value to the scene to simulating a general base-ambiance in the environment, which then dependent on which colors that dominates the lighting scheme and how much light is available. The idea is to adjust this value on the fly to help simulate the global ambience in a given scene.
  • Screen Space Ambient Occlusion (Image-Effect)
  • I'll rely on applying a bit of detail to the lighting setup by using the SSAO image-effect on the camera. In Running Man SSAO was pre-calculated during bake-time which made it completely static.
  • Bloom and Flares
  • The goal is not to polish the hell out of this light prototype so other tricks such as using color correction image-effects, particles etc. is not part of this first journey into creating advanced dynamic lighting in Unity. But we got to have a bit of glow on the light fixtures - its so easy to setup and looks great.

 

Step 1: Setting up primary light

Spot lights and light fixtures are placed logically throughout the environment.
Spot lights and light fixtures are placed logically throughout the environment.

 

Step 2: Setting up primary ambient light

Next I add a point light near the primary light to fake/simulate in-direct light on the nearby environment.
Next I add a point light near the primary light to fake/simulate in-direct light on the nearby environment.

 

Step 3: Setting up secondary ambient lights

To simulate a bit of bounce light (including simple color bleeding) I add a few small point lights where needed.
To simulate a bit of bounce light (including simple color bleeding) I add a few small point lights where needed.

 

Step 4: Setting up Scene Ambient Light

Next its time to set the global ambient light color (Render Settings) to help simulate a base-ambiance in areas not directly influenced by primary- or ambiance light.
Next its time to set the global ambient light color (Render Settings) to help simulate a base-ambiance in areas not directly influenced by primary- or ambiance light.

 

Step 5: Setting up Screen Space Ambient Occlusion

The Screen Space Ambient Occlusion image-effect is applied to the camera which brings out a lot of details near meshes in the environment.
The Screen Space Ambient Occlusion image-effect is applied to the camera which brings out a lot of details near meshes in the environment.

 

Step 6: Setting up Bloom and Flares

Final touch to bring the light fixtures to life is to apply the Bloom and Flares image-effect with moderate "fancy" settings.
Final touch to bring the light fixtures to life is to apply the Bloom and Flares image-effect with moderate "fancy" settings.

 

Step 7: Final result

When looking at the combined effect that all the above steps achieves, then its great to think about that all this is completely dynamic and do not have to bake/render for hours each time you need to change something in the scene.
When looking at the combined effect that all the above steps achieves, then its great to think about that all this is completely dynamic and do not have to bake/render for hours each time you need to change something in the scene.

 

Faking Dynamic Global Illumination in Unity

  • Warning:
  • Deferred lighting is calculated based on how many pixels the light influence pr. frame, so be sure to set resolution if you native default resolution is too high!
Unity Light Prototype - Faking Dynamic Global Illumination - Part 1
Take the light prototype for a spin and see the final result for yourself - all part of our commitment to letting you guys and girls in behind the scenes of developing Interstellar Marines, the best we can.
  • Warning:
  • This Prototype is not optimized for optimal performance so if you're "playing" on a small notebook, please do not expect the best frame-rates in the world!


I hope you've enjoyed this small preview into our efforts of making everything dynamic in Interstellar Marines, including lighting. In 'Light Prototype - Faking Dynamic Global Illumination in Unity - Part 2' I'll reveal more interesting ideas on how we're faking global Illumination in Unity for Deadlock.

For the love of the game!
/ZPSHicks

Note:
Not to hype or sell CryEngine 3 in any way .. but if you want to know more about the real-time global illumination in Crysis 2, take a look at this PDF - You just gotta respect the wizards at Crytek for what they have achieved with CryEngine 3.


Comments

Avatar

3 years, 3 months ago

nice nok men jeg tror der vil være mange der ikke vil forstå et kuk af det her.jeg forstår det kun da jeg har lidt kendskab til 3D og lysopsætning.PS kan ikke vente på ´DEADLOCK´

Badge
Avatar

3 years, 3 months ago

Oh, that looks very good for an early prototype... This and the dynamic sound effects will make for astonishing battle areas!

Badge
Avatar

3 years, 3 months ago

My graphics card is running HOT trying to process this preview. Even on 1280x800, 'good' setting and all effects on. I can only imagine how high system requirements will be in the future. I know it's not optimized, but there are still some features to come, if I got you right.

Now for the looks: I like that I can turn some effects on and off to see where there is a difference. I little bit too much bloom for my taste, but maybe you just wanted to show the effect in an exaggerated way.

Also: good to hear you can add or remove lights without having too much trouble/work with it. Keep up the good work.

My regards, Kendzi

Badge
Avatar

3 years, 3 months ago

nice looking game :) so fare and can only be better

Badge
Avatar

3 years, 3 months ago

Beautifull. Luckly i can run it in 1920x1080 and beautifull. + Nvidia 3D Vision (i just got it). It looks stunning.

Badge
Avatar

3 years, 3 months ago

Is my NVidia GTX 280 really that bad? :/

Badge
Avatar

3 years, 3 months ago

Nice work guys, this is going to be one intense game, from the back end of it. I might have to upgrade my video card for the first time in 3 years :P

Badge
Avatar

3 years, 3 months ago

@ Kendzi i have got an GTX 480 there is not much it can't handle. But it is realy hot, you could probalbly cook on it.

Badge
Avatar

3 years, 3 months ago

Omg, I absolutely love these previews. Beautiful style. I have also noticed that there is movement acceleration in the game. You don't just start at full speed, which is great.

Badge
Avatar

3 years, 3 months ago

I'm not really good at english, but if I got it right from here (see link) Unity 3 has already GI.
http://unity3d.com/company/news/unity-unveils
-3rd-generation-platform-press.html

"Unity now includes fully integrated licensed technology from Illuminate Labs and Umbra Software. Used in games such as the highly regarded Mirror's Edge, Illuminate Lab's Beast lighting software provides Unity developers with a complete global illumination solution for photorealistic scene lighting. Ensuring exceptional performance for games with large, open scenes and complex geometry, Umbra's occlusion culling software is also fully integrated in Unity 3.0. Both Umbra and Beast are included in Unity Pro at no additional cost."

Badge
Avatar

3 years, 3 months ago

I rather got twice the performance so render2texture plz ;)

GI is really a good feature and color bleeding a beauty but still wish to see this someday soon and really make the real transition to the next gen.

http://www.youtube.com/watch?v=jLFrP0c7VWw


http://www.youtube.com/watch?v=mtHDSG2wNho

Badge
Avatar

3 years, 3 months ago

very good.
But remember to add more darker areas into the game to make use of the flashlight. Crysis suffered from this problem too, cave, night jungle, whatever, it never was dark. Turning the lights off looks good so far but it really should make the enviroment darker than it is now.

(and you even had a night vision mode)

Badge
Avatar

3 years, 3 months ago

Looks great Hicks!
Fun fact about that CryEngine 3 PDF: They spelled the authors name wrong. It's Thiago. Just something I noticed. :P

/Nerd over and out.

Badge
Avatar

3 years, 3 months ago

@Kendzi / @Suubersnake / @vfn4i83
We'll soon settle on our Deadlocks recommended requirements and make sure everything run around the magical 60fps.

@ClaymoreMD
Thanks, better get use to it as we'll make these previews prototypes all the time moving forward.

@Adidas25
The GI available in Unity is available via the Beast lightmapping solution which is great .. we used it on the Xmas2010 map, this solution is completely static so it'll not be our primary foundation for lighting. We'll still use the lightmapper where needed eg. outdoor environments etc.

@Vidmaster
You're so right, m8! When flashlights and night vision game-modes are introduced in Deadlock we'll do all we can to master darkness! :)

@Kosai106
Thanks marine and glad you liked the Crysis 2 PDF (with naming errors) its sure shows great ideas and implementations.

For the love of the lights
/ZPSHicks

Badge
Avatar

3 years, 3 months ago

Kosai106 the name is not spelled wrong on the PDF, Tiago Sousa is a Portuguese graphics effects engineer (i'm also from Portugal) and we write Tiago without a H here.

About the preview it looks fantastic and i'm really happy that you guys are going for the real time lighting solution for indoor parts, by the way resolution does really have a impact on the fps's, at my native resolution of 1680*1050 it was running at 25 fps, i brought the resolution down to 1440*900 them it was at a constant 30fps, i know this is not optimized and running at 900p was not much different them at 1050p just the aliasing was more pronounced.

My specs

W7x64
8GB RAM
AMD HD 5770 1GB

Badge
Avatar

3 years, 3 months ago

I forgot to say that i was running at fantastic settings so that low fps are expected.

By the way guys remember that the final game is some years away so probably we all will have the hardware to run this at 60fps with no problem by then.

Badge
Avatar

3 years, 3 months ago

On 1920x1200 Fantastic settings I had about 37fps going up to 60fps based on what lighting was used. All in all I think that's pretty good considering it hasn't been optimized yet. Looks great.

I hope with the ability to change lighting so easily we can have interactive elements in the real game such as knocking out a power box to switch the lights off in a corridor or alarms setting a red light siren off? All in all good work and can't wait for Deadlock.

Badge
Avatar

3 years, 3 months ago

@ Aragoon: He said it's spelled wrong himself in a Facebook convo. ;)

Badge
Avatar

3 years, 3 months ago

nothing to do with the preview but i loved how the moving felt.

Badge
Avatar

3 years, 3 months ago

Kosai106 i don't want to take this offtopic but if he said it was spelled wrong them it was before that pdf came out, because the name has it is in the PDF posted is correct in portuguese terms, you can't change the original name of a person because you write it differently on your country, for example a emigrant called John comes to Portugal we will still call him John, we have a portuguese word for that name, João, but is name is not written like that so we can't change it.

Just to kill all doubts i have here a link to a interview that Tiago did for a Portuguese magazine see how is name is just like the one on the pdf.

http://ez.mygames.pt/pc/especial/conheci-t
iago-sousa-ainda-nem-sequer-ele-sonhava-entrar-num
a-empresa-com-a-dimensao-da-crytek-117/

Guys sorry for the big offtopic, but i needed to correct this.

Badge
Avatar

3 years, 3 months ago

Sweet!

Badge
Avatar

3 years, 3 months ago

Hello, I just had a mess around with the 'in engine' lighting thing and it looks VERY cool, more developers should let fans play around with stuff like this =)

One strange thing I noticed though and I don't know if it's because I'm using a LED monitor(contrast isn't set that high) but when I had the main lights off the floor reflected a kind of 'gloomy light' that seemed like a fog that followed me around as I looked at it, don't know if it's just me or the monitor but have a look.

Otherwise the lighting is realistic and nice. I like the detail on surfaces etc like the crates, you should add destruction physics(as on option) in the game to destroy the, and other cover and so on, but that's for another time. keep up your great work, I look forward to seeing more.

Badge
Avatar

3 years, 3 months ago

Great demo. Loved the lighting. I had a little bit of framerate dip/lag for a moment here and there, but overall, it ran nice and smooth, at 1360x768, full effects, and set at fantastic. On Beautiful, it performed well even with only 2 gigs of system ram, 1 gig vid ram. I don't have a super high end system, and Running Man and Bullseye run wonderfully.

Can't wait for Deadlock.

Badge
Avatar

3 years, 3 months ago

Runs well on my Radeon HD 5870 Platinum 2GB 256-bit Video Card at 60fps on 1920x1200 (Fantastic settings). I also have 3.2 GHz AMD six-core processor with 6 gigs of ram.
So no problems here.

I enjoy your tech demos, had fun just staring and making comparisons on the different light settings ( I also had a rave party when mashing the e key).

Gonna get out my wallet again for this.

Badge
Avatar

3 years, 3 months ago

i noticed that you can jump extremely high and choose your direction while you are in the air . that ain't realistic - but fun ;P i remeber this map because it's extremely easy to win in. get on 1. floor. jump onto the railing. then jump onto the wire that hangs in the ceiling - Voila! any robots can't touch you there xD !

with this kind of jump there are going to be a lot of bunny jumping and halo-kind-of battles and that ain't the way I believe ZPS's vision for this game, is. - or is it ?
i hope you read this because will kill the gameplay if you can jump up there.

Badge
Avatar

3 years, 3 months ago

@AlphaBoy Last time I replayed Running man you can NOT jump like you can in the light prototype demo. I assume it was cause you didn't have player model here and not "weight" to speak of, only basic movement functions. It is even hard to "scale" the double crates in running man, so you shouldn't worry.

Back to the subjects of light, I would like to see a swinging lamp :D . Just think about possible gameplay implementations of it. Theif, anyone?

Badge
Avatar

3 years, 3 months ago

Nice to see that my 5850 still has the power to muster when its required :P. Looks damned sweet to run it in 1920*1200 with no shutter at all. Tomorrow I am gonna try out on my Asus U36J and see how well it musters in comparison :P

Badge
Avatar

3 years, 3 months ago

Jerom,

You would annoy a certain person I know by putting it like that ;). Its Thief and not Theif :P. But yea I agree it would be a nice touch with swinging fixtures. I wonder what it would take to be taken on as a official ZPS tester, considering I'm a dane >_>

Badge
Avatar

3 years, 3 months ago

@PraetorianGurad
I think we all are official ZPS tester. I mean we get to play it as soon as it is possiple and can then suggest changes, Find bugs in other words test the hell out of it.

Badge
Avatar

3 years, 3 months ago

You got a point. But I figured they most likely also had some prerelease testers more then likely. Unless thats actually the 3+ developers working on this

Badge
Avatar

3 years, 3 months ago

On max setting and at the max res this laptop could take it actually run acceptable, albeit with a slight bit of lag. Whether that is down to the game NOT supporting this laptop's technology or the technology in it is just not high spec enough well remains to be proven.

Badge
Avatar

3 years, 3 months ago

I suspect it is the case that a laptop such as mine might actually not be supported for its technologic wonder >_<. But I am not sure I am able to prove whether or not it is considering its running the Nvidia Optimus system, ie with 2 graphics cards on board, a basic one for normal windows stuff etc for longer battery life and then a Nvidia 310M for the more graphically intensive jobs.

I am not sure how to test which of the cards are in use considering I can not "trigger" the file that runs the player.

Badge
Avatar

3 years, 3 months ago

Can't believe I missed this. Works well enough, looks great.

I can finally see the influence of SSAO in this tech demo. It is a very subtle effect.

Badge
Avatar

3 years, 3 months ago

Oooh, looks awsome~ -Thumbs up!-

Badge
Avatar

3 years, 2 months ago

Warning:
This Prototype is not optimized for optimal performance so if you're "playing" on a small notebook, please do not expect the best frame-rates in the world!

Im glad to read this, my PC cant handly it super smooth on the max :)

Looks really good. But a small question. Does the map also going to have particles... like dust falling off the lamps or something?

Badge
Avatar

2 years, 2 months ago

Greetings from Jessica..

I am new in unity and wanna learn this protoype instead of baking for hrs and hrs. Can you please send me the scene on the page so that i can atleast start to learn this. It will be a great help to me.

My mail id is jessicastorm1986@hotmail.com

Badge

You need to login / enlist to comment.


Listing Development articles (sorted by date)