What are my options for lighting a game with Unity?

Hi,

after some searching and browsing I haven’t been able to find a satisfying answer to my question so I will ask it here.

The question is more about shadows than lights actually. Lights I’m able to get quite easily, but I’m unsure where to get my shadows from.

From what I can tell my options are lightmaps, shadow projectors for blob shadows etc., and dynamic shadows if I upgrade to Pro.

Is that all I can choose from?

How would I get shadows for a dynamically created level within my game if I don’t have Pro? Would that be impossible? Or what if I bake a lightmap into my level, but have multiple movable objects within my game. Would those objects have to be without shadows?

I actually thought Unity was like the Hammer editor for Half-life 1 2 where lights and shadows are baked when you compile your level, but it seems I have to bake my lighting into my textures using an external application? If Unity can bake lightmaps for terrains within the editor why can it not for the objects in my level?

What kind of lighting solution does a game like Half-life 2 actually use? Every object has some kind of projected shadow, but there’s also this prebuilt lightmap like thing. :slight_smile:

Also, how do I make an object going into a shadow react to the shadow, i.e turn dark like in Half-life? A lightmap is just a texture, right? So that won’t affect anything sitting on the texture?

My game ideas involve a lot of physics affected movable objects and a random level generator. If I want shadows for my game will I have to get Pro to use dynamic shadows?

A lot of questions here, some may be stupid, some may be answered before and for that I’m sorry. :slight_smile:

Some answers and literature for further study would be awesome.

Thanks.

I knew it would be a good idea to start being more involved in the forum. Up until now (for about a year now) I didn’t notice even once that shadows were a pro-only feature :slight_smile:

Well, first of all - yeah, if you don’t have pro you will have to do with lightmaps and shadow projectors. Having said that - even though shadows are an awesome feature, unless you’re designing a game that will only run on high end computers - most likely you will use them wisely and not go wild anyway.

Usually a game has a mix a LOT of lightmaps (everything that is in your level and doesn’t move - is basically lightmaped), dynamic shadows (characters and objects that move around) and projections. And I don’t mean just casual games.
Check out Mirror’s Edge:MetaGame: Image
You think those pretty soft shadows are calculated in real time? No freaking way :slight_smile: And this is a AAA title, mind you. They have the best looking lightmaps I’ve seen so far, and they add a lot to the style of the game.

Well, since the unity dev team is extra busy. That’s why.
When you bake a terrain - you create one lightmap. That’s it. If you want to bake textures into objects - you need to calculate and create a lightmap for each object. And take into acount the shaders each object uses, and lightmaps that object already has on it.
Oh, and there ARE scipts on the wiki that do this:
http://www.unifycommunity.com/wiki/index.php?title=LightMapper

I’m not sure that you can lightmap a terrain if you don’t have pro, BTW. I use one of the scripts on the wiki to lightmap the terrain, and that one uses pixel lights to calculate shadows, so it won’t work in Indie. But maybe the built-in lightmapper in Unity will…

Further more - baking in an external 3d app will create better results… You can use HDR maps, reflection maps, sub surface scaterring, radiosity and layers upon layers of textures to achieve results that are life-like and that will create more realistic shadows.

Yup. pretty much this is correct. You can add blob shadow projectors that won’t effect the surface of the ground, for example, but will effect characters moving underneath them. Put them in dark places and you’ve created an illusion that the character is effected by the lightmaped shadow.

Now, let’s say you have a rocket launcher that fires a rocket with a bright red flame.
This is the perfect place to use dynamic shadows, since the rocket is moving - the shadows that are created should be computed dynamically and will much more impressive.

Nothing can replace dynamic shadows, but you can do a very good job if you think hard enough and out of the box :slight_smile:

And about your game - that depends on how you design it… Hard to tell without more details.

Yes, I own Mirror’s Edge and it has some spectacular graphics and lighting, but every single object in that game is static. What if there were movable objects in Mirror’s Edge? Then they would have to use some form of projected or dynamic shadows.

Mirror’s Edge also use the same kind of projected shadows for characters as Half-life 2 it seems. What kind of shadows are these?

Here’s an example from HL2:
http://www.scubb.com/images/prd_detailed/PC%20half%20life%202%20aftermath_ss2.jpg

The shadows under the zombies. Every character and object in HL2 as well as Mirror’s Edge has these. I couldn’t find one of Mirror’s Edge, but it uses the same kind of shadows for characters etc. They are very nice and coupled with a proper lightmap they produce great results.

Would I have to find a way to, in real time, create a blurred black 2D silhuette of all my objects and then project that the same way as a blob shadow? Do you think they are doing it a similar way?

I haven’t decided on a game yet, but one of my game ideas involve a random maze generated each time you start a level. The maze could either be made up from just primitive cubes or some modular geometry I create in 3ds max.

I will eventually get Pro, I’m just wondering if I have some viable options for creating shadows for such a game in Indie? :slight_smile:

I’m reading some articles on gamasutra and gamedev now and I’m starting to suspect I’m right about the shadows in Mirror’s Edge and Half-life 2 (the ones visible in the screenshot in my last post).

They basically flatten a second copy of the object or character and project that onto the ground? Does this mean shadows enabled are twice as costly in terms of geometry as shadows disabled?

Or am I way wrong? :slight_smile:

I’m guessing this won’t be so hard to script, but how to make the shadows soft I have no idea. :slight_smile:

Probably something like this, and yes there is an added expense for projectors since each object touched by one has to be re-rendered.

Like this maybe? :slight_smile: The shadows on the title screen are a procedurally constructed UV-mapped mesh actually. The shadows in the game are just the absence of light (which is what shadows really are, of course). In this case the shadow resolution is extremely low as only 8 points are computed for each square and it relies on bilinear filtering of vertex colors to work at all, but it’s reasonably effective especially considering the main target is the iPhone.

–Eric

Yeah, that wikilink looks about it. Being pro only I guess it’s kind of pointless now though.

Minutes before reading your reply I discovered your maze game and immediately checked my iphone to try it, but then noticed you haven’t submitted it yet. :slight_smile:

Will be nice to check it out once you submit it.

I don’t quite understand this part. I agree about your definition of shadows :), but in my experience light in Unity Indie travel through geometry so how do you achieve those shadowed corridors leading out into the brightly lit corridors?

There aren’t any “real” lights in the game; the lighting is computed when the maze is generated and baked into vertex colors.

–Eric