The CE2Devs Group gathers teams and individuals that have chosen Crytek's next-generation engine to power their upcoming Map, MOD or Game.

Post tutorial Report article RSS Feed Petrograd Mod Level Design (Interior Lighting/Optimization)

In this tutorial, I explain how to use VisAreas and Portals in CryEngine in order to setup lighting for interiors.

Posted by ben72227 on May 18th, 2009
Intermediate Mapping/Technical.

I've gotten some questions regarding how to create interiors in the CryEngine2 Sandbox editor. This tutorial will explain how to create interiors using VisAreas and Portals. I will also briefly discuss how to setup lighting in interiors. If you have any questions or comments, feel free to post them in the comments section at the bottom of this article.

The first thing we need to look at is how VisAreas work:

Now that we have that out of the way, I'm going to give you a step-by-step example of how to set up a VisArea and add a few Portals. I'll work with a simple 4-sided room with 2 doors. You can get larger versions of the screenshots below by clicking on them.

First, we will need to get both the interior and exterior model of the building:

Here we can see the two models - the interior on the left and the exterior 'shell' on the right.

When we move the exterior model onto the interior model we get this:

As you can see, we have shadows turned on for the models, so the sunlight casts a shadow onto the floor of the building. However, since we do not have interior lighting set up, the entire inside of the building is still receiving sunlight which makes it look unrealistically bright on the inside.

This causes problems when we try to setup an interior light source. As you can see below, the sunlight makes the interior light source barely distinguishable:

In order to remedy this problem, we will add a VisArea. To do that, you'll need to go to the RollupBar and go to Objects>Area>VisArea. Once you have your VisArea selected, you should click "DisplayFilled" so that it's value is true. This will help you align the VisArea better (since VisArea placement has to be precise, just a slight error can cause the area to not render properly). I separated the interior and exterior models again for the time being so that I can place the VisArea around the interior model.

Since I want the sunlight to be able to come through the doors, I also clicked "AffectedBySun" so that it's value is true. Once I have the VisArea setup around the interior, then I need to adjust the height so that the VisArea will not interfere with the exterior model that I'm about to place over it. The building is a little under 3 units high, so I set the VisArea's height to 3 units. It is very important that the VisArea is constrained around the interior model as tightly as possible, so not to interfere with the rendering of the exterior model.

As you can see below, the with the VisArea completely enclosing the interior of the model, none of the exterior light (i.e. sunlight) is being rendered.

Now that we have the interior model enclosed by the VisArea, we need to integrate the exterior model.

Once we have moved the exterior back onto the interior model, we will need to create Portals. These are for areas where we want the outside world to be visible from the interior (and vice-versa); examples include doors, windows, etc. We go again to the Area tab in the RollupBar, except this time we'll select Portal. Once the Portal is selected, you need to place it so that it goes in the doorway, with half of the portal on the interior side of the VisArea, and the other half on the exterior side of the VisArea. As with the VisArea, you will need to adjust the height of the Portal so that it only covers the door/window/etc.

Once that is done, if the Portals are aligned properly, the entire building (exterior and interior) should render instantly.

And with that, your interior area is setup. As you can see below, the VisArea/Portal combination makes the inside lighting look more realistic while adding light bloom effects to the outside light that is coming through the Portals (which helps to add contrast between the bright and dark areas). And since the interior is darker, we are now able to easily distinguish the interior light source that we set up early:

Also, performance will be MUCH better optimized since the interior area is being rendered seperate of the exterior area. This is particularly helpful if you are using multiple light sources; CryEngine2 uses a forward renderer so more lights equals lower performance. Using VisAreas to separate different areas from one another will greatly improve the rendering speeds and framerates during gameplay (particularly when it comes to rendering multiple light sources).

And with that I conclude this tutorial. If you have questions or comments, post them below in the comments section. I prefer that over everyone sending me individual PM's - with comments everyone can see all of the questions and I will only need to provide the answer to them once. Thanks again for the support!

-Benjamin Thatcher (ben72227)

Post comment Comments
Chrissstrahl May 18 2009 says:

Hey, that was quick!
Good work! I like it :)

+1 vote     reply to comment
Tokoya May 18 2009 says:

Great tutorial once again Ben, very descriptive and easy to follow. These really help me and fellow Hammer users understand what level creation is all about outside of Source!

+1 vote     reply to comment
ben72227 Author
ben72227 May 18 2009 replied:

Thanks. I did this in part because I get a lot of comments along the lines of "I didn't think CryEngine could do interiors" and I just want to show that it is in fact possible and not very complex at all.

+1 vote   reply to comment
hushpuppy May 18 2009 says:

I kinda liked the first result better...looked a lot moore realistic than that "bloom-tastic" thing

+1 vote     reply to comment
ben72227 Author
ben72227 May 18 2009 replied:

I think Crytek were trying to simulate that effect you get when your eyes readjust as you go from a dark environment to a very bright one (i.e. Ocular Adaptation). A lot of buildings I don't even bother with using VisAreas, especially if they are something simple like a shack/shed or something similar. I generally use VisAreas for large buildings that would have tons of light sources and need the optimization that comes with a VisArea (such as a warehouse or a building with lots of corridors (i.e. like Doom 3 levels)).

+1 vote   reply to comment
chris_sloany May 18 2009 says:

very awesome job! this worked really nice, the only problem, (and this is on my part), is that since i suck at making it around the building properly, if i walk up too close to it, the building disappears. lol. nothing major though, good job! i was hoping it would be a video tutoiral, but this worked just as great!

+1 vote     reply to comment
w1ngzer0 May 19 2009 says:

yay more people giving simple to normal on walkthroughs. love it love it!

+3 votes     reply to comment
ben72227 Author
ben72227 May 19 2009 replied:

Great! I aimed to make it easy to follow, I'm glad you were able to understand it.

+1 vote   reply to comment
moci May 19 2009 says:

But why is it more realistic? Are you saying that CryEngine2 does not stop the light once it hit's a polygon? (And thus making the inside brighter by letting light pass trough a polygon)

Because if you have 1 door and the lightning works perfectly... and the inside is that bright than that's realistic so why darken it (which would make it unrealistic)?

0 votes     reply to comment
ben72227 Author
ben72227 May 19 2009 replied:

It does stop light (hence why it is able to cast shadows). However, there are other factors involved - global illumination factors such as ambient occlusion, radiosity, etc.

+2 votes   reply to comment
moci May 19 2009 replied:

But all those things are to make sure that the light bounces correct from the polygons/walls. If you go for realism, why stop the sunlight from doing it's job?

0 votes     reply to comment
ben72227 Author
ben72227 May 19 2009 replied:

It's more about the ambient light. There is a more advanced tutorial made by ZapWizard, which deals with creating VisAreas and Portals for voxels/caves:

+1 vote   reply to comment
Argoon May 22 2009 says:

I'm with deathcaller on this, first thanks for the tut as it is really useful, but the end result is not realistic at all, like others have said the first image is what would happen in reality in a small "house" that have a big open door, light bounce would make it bright. But i can see its benefits in cutting down on light rendering and also to make interior maps like doom3 or quake 4.

+1 vote     reply to comment
ben72227 Author
ben72227 May 23 2009 replied:

Yes, that is why most of the small shacks and village houses in Crysis did not use VisAreas - they are more useful for 'true' interiors, such as the alien spaceship and aircraft carrier levels in Crysis.

+1 vote   reply to comment
darkenes Jun 9 2009 says:

thanks for the tut it will help a lot

+1 vote     reply to comment
TheSyndicate Jul 2 2011 says:

Images have been deleted.

+1 vote     reply to comment
GARYOSAVAN Dec 3 2011 says:

All photos Dead!

+1 vote     reply to comment
Post a Comment
click to sign in

You are not logged in, your comment will be anonymous unless you join the community today (totally free - or sign in with your social account on the right) which we encourage all contributors to do.

2000 characters limit; HTML formatting and smileys are not supported - text only

Nov 9, 2007
Open to all members
Send Message
Join this group
Group Watch
Track this group
Report Abuse
Report article
Related Mods
Petrograd Crysis - Single Player First Person Shooter
Related Games
Crysis Single & Multiplayer First Person Shooter
Related Groups
CryENGINE 2 Developers
CryENGINE 2 Developers Fans & Clans with 217 members