Unity 3.0 several lighting issues, any help appreciated

I’m wondering how to port my game from U2.6 to U3.
I’ve encountered many issues, and was hoping someone will be able to shed some light on some of those.
U3 comes with a lot of goodies which are worth porting, and also if I’m able to customize beast for my needs - it will save me a lot of time later on.

Lighting Setup overview

  • Isometric, FOV 10. (camera is setup far away)
  • GI creating soft blue tone, baked to lightmaps
  • Main direction light, main source of shadows. Also baked bounce lights into lightmaps.
  • Many static lights scattered with shadows - no need to bake bounce, and shadows I plan to bake to lightmap.
  • A few dynamic point/spot lights (e.g. roadlights), help to set the mood.
  • AO baked into lightmaps (very important)
  • AA - very important.

1. Light spread - I’m noticing much difference in spot/point lights spread.
basically in U3 there seems to be sharper falloff and the contrast is very high, I was going for a certain look in U2.6 but was unable to recreate it in U3. solved by increasing range and decreasing intensity to compensate. (cheers Kurylo3d)

2. Specular Deferred Issues - When I switch to deferred, specular highlights seem way off. (even without using beast), I wasn’t able to root the cause. solved by using custom lighting models. (might be a bug in Unity ?)

3. Forward rendering shadows - if I choose to go the forward route (performance isn’t that bad), how would I generally approach realtime shadows for point/spot lights on characters ?
And what if I want to have a flashlight, does it mean unity limitations force me to use deferred in that scenario ?

4. Deferred AA - I’ve tried many solutions, but it seems my game unique FOV and small details make MSAA the only option.
Until its support added to Unity, I’m curious about performance issues and the important question - and the main concern is are the performance costs of MSAA compared to traditional AA will defeat the purpose of going from Forward->Deferred in the first place for my setup ?

5. Customizing Beast - I require 4 things for my lightmaps - GI, indirect bounce from main directional (sunlight), static shadows on static objects and AO. (I can combine those via code to one image)

  • GI + indirect light - can easily get from “near” map mode".
  • Baking shadows only (for static lights/objects) - this is easy with external lightmappers, but how to do this with beast ? any ideas or tricks ? (especially as beast lightmapping implementation seems to be screen only instead of multiply/overlay) solved by scripting a dual baking system and extracting shadows from the difference.
  • AO - how will I bake just AO (whether I go forward/deferred), since beast lightmaps seems to only brighten (instead of multiply/overlay) ?? (worst case scenario, I can still bake it using external software, but not very convenient)

5.1: what do you mean with this explicitely? having lights that only cast lightmap lighting? If so thats handled through the type on the dropdown which you can set to dynamic only, bake only or both.

5.2: you can’t the beast map is 1 thing, you either get all or nothing.

cheers dreamora.

5.1: I meant baking shadows only for static lights/objects (I edited the post), so basically you can have the light still computing in realtime but
the shadows are baked into the lightmap to save on performance.

5.2: yes but despite poor flexibility of beast implementation in unity, there are often hacks that can be done. (like how I bake the indirect direction lighting) - so I was wondering maybe there’s one in this case.
However I doubt there’s any way in this case, because beast baked maps seem to only brighten.

for 1.)lightspread…

maybe you can try increasing the range of the spot light. and then tweaking the intensity based on a higher or lower range. With a higher range… the light i suppose would have the same consistentcy of intensity for a longer distance… with a lower range it would fade faster … at least i think that… dont have unity open right now.

2.) I guess they just look different in different rendering pipelines… try adjusting the material to put the spec up a bit.

3.) i dont think forward rendering can have shadows except 1 for directional light… doubt theres a way to fix this, though i have seen some scripts out there for creating shadows before unity had shadows implemented in version 2. Check the unifywiki if you want to try them, but i wouldnt recommend it. Probably garbage at this point.

4.) For some sort of AA in deferred mode… try this… to me its like a 2x aa, but its a huge improvement… very grateful to the guy who made this.
http://forum.unity3d.com/threads/63330-Better-fake-AA-for-deferred-lighting

5.) From what I saw with beast, and correct me if im wrong, you can bake lighting and shadows 2 different ways.

1 way is bake an illumination map and a shadow map… and the shadow map switches out for real time shadows after a certain distance.
2nd way is to make it all into 1 map…yes beast allows you to do this too… Im pretty sure this even allows you to bake ambient occlusion. (Im not positive but you may have to use the legacy lightmap shaders that come with unity3 to have those objects interact with lights at that point…)

cheers Kurylo3d, your lightspread one worked great, thanks !

  • I will have to try the spec suggestion, though I think it should happen in the first place. (maybe I’m missing something here)
  • About the AA, I’ve tried it but it doesn’t work well with my kind of camera I guess.
  • Beast out of the box is useless to me, which is why I’m trying to customize it.

Again thanks mate, I appreciate your time writing all of this and am very happy 1 out of these 5 problems has been fixed :slight_smile:

Orthographic / near orthographic in general is a problem as various features won’t work or have problems in such a setup (shadows don’t work in ortho, partially in near ortho and alike).

What are you trying to achieve with lightmapping that does not work with Lightmap + dynamic shadows (how its meant to be used if you don’t use single lightmap mode only).
Also don’t forget you can modify the generated EXRs in photoshop to tone them down if they are to bright etc :slight_smile:

@Kyrulo3D: 5.1 is only available if you use dynamic shadows as the dynamic shadow range defines the fading range for the lightmap around you (this is Dual Lightmapping). You don’t have any explicit control over it other than this actually.

cheers dreamora - I haven’t had any issues with my camera view regarding shadows, in U2.6 or U3.0 deferred.

I thought it was clear from my post, I’m using custom shaders for lightmaps, which are tailored based on my game’s requirements. (GI, indirect bounce from main directional, shadows from static lights to static objects, and AO)

It’s very good to be able to prototype lighting instead of having to bake every time for changes, which is why I’m very interesting to bake the shadows in unity. (GI+indirect bounce is easy, AO I’ll probably have to do externally

So the idea is to bake the various parts and combine either in unity / external editors / batch scripts / etc …

Well if you have own shaders you will likely also want / have to build them outside as the beast implementation is tailored against the intend usage and automatically generated lightmap shader code part from surface shaders. Not even legacy lightmap shaders are meant for beast.
As such I don’t see you getting much if anything from using Beast in this case if you basically have a finished pipeline, setup and specific needs which beast will not fullfill.

The splitting of light / shadow aspects and partial baking on their own are already good enough reasons to go with an external solution

dreamora see I was using external solution for 2.6, but the thing is if you read my post - I’m very interesting in laying out the lights in realtime straight in unity, I’m really happy with those lights.

Problem with using external solution, it won’t match with those lights - though I have to admit it might suffice for just a shadow pass.
It’s also very nice how beast generates uvs on the fly. (though it seems you can’t use that for shaders )

But if beast can’t do any more than what we’re given out of the box, so I guess I have no choice but to accept it.
Hopefully I’ll be able to write my own pipeline to bake in external app with minimal manual setups.

Cheers dreamora

Im pretty sure beast can also bake ambient occlusion into your shadow map. I saw some options in there, but i havent messed with them yet. Let me know if I am wrong about this… again i have not tested it.

Also with the AA camera shader… keep in mind i beleive you have to save your scene with it applied to your camera… and then restart unity to see it actually take effect… i dont think it works right off the bat… u have to restart unity at least once.

Beast could do a lot but Unity does not expose control over various things or just not implement them at the time.
Various parts of it can be unleashed through manually configuring beast through the xml but that will require some research and experimenting (until someone decides that he is pissed by text editors and writes an editor window for it)

Over the life cycle of 3.x Beast though kill away any external solution due to light clouds etc given you have use for it, as those things are not replicable with lightmap only solutions.

As for using the UV: I think thats possible. But where you don’t get your feet in is dual lightmap handling (though your environment looks rather stylized so you might actually bake to single lightmap as the differences between realtime lighting and GI - AO lightmaps is pretty large)

I fully understand and agree that live placement is a serious Pro, though depending on the software you use to model the things and do the lightmapping, it potentially offers comparable capabilities already.
Its the reason I’ve been experimenting with it at all (I’m no artist nor do I pretend to have any talent / motivation to invest the time) :wink:

  1. Speculars do indeed look different (I did a quick test now, in my case the speculars were brighter and more obvious with deferred). Does anyone have a more scientific explanation for this? (Unity devs?)

  2. Directx11 support will eventually be added to unity and with it proper AA support for deferred. So I guess you will have to wait till then to see what the performance is like. But if you really want AA in your game and deferred, it means you are targeting machines with DX10+ cards, so at least mid-high end, so I don’t think performance will be that much of a problem.

  3. Beast has a AO option which does indeed darken the corners.

I have found a walkaround to the specular issue in deferred by accident, just used a custom lighting model and suddenly the specular was identical between forward deferred :slight_smile:

I have also found a possible way to bake shadows with beast, by dual baking all lights with and without lights, and using the difference as a shadow intensity pass for the final lightmap.
I’m trying to implement this and will keep this thread updated.

AcidArrow - the question is how to separate the AO from everything else, so I can tailor it to my own needs.

You can’t, the AO is baked along the rest.
But you could disable AO and use SSAO for example

or bake with and without AO and use photoshop to get the difference to store as AO map and use then in some form