Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

RE5 lighting in Unity Pro?

Discussion in 'General Discussion' started by Warrior1424, Oct 2, 2014.

  1. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    So I was playing Resident Evil 5 for the Xbox today, and noticed how visually stunning it is.
    This is due mostly in part to the amazing lightmapping.

    Now here's where it gets weird.
    In Unity, you either have completely baked and beautiful lightmaps, or you have lightmaps (without any shadows, just bounced light) with real-time lights casting real-time shadows.

    In RE5, their scenes look something like this:
    Static level geometry, fully lightmapped with baked shadows only. Casts real-time shadows onto characters, but not onto the rest of the static geometry.
    Character models with standard real-time shadows from a set angle regardless of light source (shadow is also actually projected onto static geometry, not onto an invisible plane, as it deforms across uneven terrain).

    Now how in the world would you set this up in Unity?
    I really love lightmapping, and I hate real-time shadows for environments, but I like direct shadows for characters.
    Currently in Unity for me, either everything is affected by real-time shadows, or the static geometry is affected by baked shadows while the dynamic characters are only able to cast real-time shadows onto each other, and not the static geometry. The static geometry is also unable to cast shadows solely onto dynamic objects while also having baked lighting.

    Here are some images to show what I'm talking about


    Notice the real-time shadow from the character, and the baked shadow from the level geometry



    Notice how the dogs are shaded by the shipping crates, but the shipping crates themselves and the road are clearly shaded by a baked lightmap.

    Any tips for doing something like this?

    EDIT: After playing some more, I noticed that only sometimes the static geometry casts shadows onto characters. Either this is due to only certain objects casting shadows, or somebody went in and added a bunch of invisible meshes with the sole purpose of casting shadows onto the characters, and the static geometry isn't casting shadows at all.

    EDIT2: The way some complex structures or ceilings cast basic shadows further leads me to believe that it is not the actual level casting the shadows. But why go around placing invisible objects to cast shadows? That seems like it would an extreme pain to do.
     
    Last edited: Oct 2, 2014
    BrandyStarbrite likes this.
  2. smd863

    smd863

    Joined:
    Jan 26, 2014
    Posts:
    292
    I am just speculating, but I would imagine they have very simple collision meshes for the environment anyway and they could be using some (or all) of those to cast shadows. You might need to tweak them a bit, but most of them would already be there approximating all the solid geometry in the level--at least in the areas that the character can walk around in. Maybe the objects in the environment that don't cast shadows are the same ones that don't need a collision mesh?

    Having imperfect shadow silhouettes isn't very noticeable (especially on an enemy dog as it's running around), but having simple cast shadows on dynamic objects is a huge improvement over no shadows at all.
     
  3. Deleted User

    Deleted User

    Guest

    Hmm, I'm not sure how this is different to what you normally do.. Set a dynamic shadow caster distance enough to cover characters and NPC's in close range and then bake the rest of it.

    So for long range you'll still have shadows, but they won't be dynamic so you don't have to suffer heavy performance issues. But you still get lesser quality up close char and NPC shadows.
     
    calmcarrots likes this.
  4. hippocoder

    hippocoder

    Digital Ape Moderator

    Joined:
    Apr 11, 2010
    Posts:
    29,723
    Static shadowmaps are a good place to start: http://forum.unity3d.com/threads/ba...ios-a-la-bladeslinger-source-included.182682/

    Since it's essentially just uvs and a blended texture, performance is incredibly good. I'd love it if Unity 5 natively supported this at editor time instead of what it is today.

    Basically, shadows should be static, dynamic and have a bunch of quality options in Unity. That would be pretty great all round really. With option to lazy update certain parts of the static. It's a pretty great solution for mobile.

    In our current game, we're 2.5D, so we opted to have the shadows realtime, all of the time. Saves ram and so forth for Vita. but we had to hack in and heavily modify the Unity shadows to get good performance. Don't really have the manpower to develop a robust static shadow solution right now either.
     
    Deleted User likes this.
  5. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    @CaptainScience I mean that would definitely work, it just seems so... strange

    @ShadowK But if you bake the rest of it, it no longer reacts to real-time shadows.

    @hippocoder Thanks for the link, although I'm still trying to wrap my head around what exactly it does. Could you possibly explain what's actually going on? Is it pretty much just a pre-calculated projected shadow that affects only dynamic objects?
     
  6. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,782
  7. Deleted User

    Deleted User

    Guest

    It does in my version of Unity, not sure what's going on in yours :D..
     
  8. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,782
    Maybe he bake the lightmap using single lightmap or directional lightmap those two remove the realtime shadow isn't??
     
  9. Deleted User

    Deleted User

    Guest

    Hmm, I did always use dual lightmapping. Then I just reduced the shadow distance in the quality settings, worked well.
     
  10. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    With dual lightmaps, the main shadows are provided by the real-time shadows, and only things like light bouncing are baked.
    I also noticed with reducing the shadow distance, my dynamic objects turned black. I also thought turning down the shadow distance also turned down the distance on the real-time shadows, as with dual lightmaps the full on shadowed lightmap appears when the real-time shadows are no longer visible.

    Also, how do static shadow maps work if for example, an object can move inside a building where it is shadowed, but can also move on top of the building where it wouldn't be shadowed?
     
  11. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,782
    That's how the shadow work, have you tried the static shadow example??
     
  12. Deleted User

    Deleted User

    Guest

    Were not talking about shadow distance in the lightmap display here, were talking about SD in the quality settings for dynamic shadows. It's simple, the approach is to overlay realtime shadows for characters and provide constants for static meshes.

    http://docs.unity3d.com/Manual/LightmappingInDepth.html

    Dual lightmaps is for blending baked and realtime shadows. Read up on it from the Unity docs above...
     
  13. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    I haven't had a chance to sit down and actually use it, that's why I was asking some questions about it.

    @ShadowK But isn't it still the same setting? From the docs for shadow distance in the LM display: "This setting overrides, but not overwrites, the QualitySettings.shadowDistance setting."

    But anyways, I think with the game I'm making I just need to use projected shadows, as I don't have any directional lights in my scene, and casting shadows from every single point light would be unnecessary. Does anyone know of any simple, basic implementations of projected shadows? Like directional projection instead of say projecting from a point?
     
  14. Reanimate_L

    Reanimate_L

    Joined:
    Oct 10, 2009
    Posts:
    2,782
    Uuh the link from hippocoder also can do that If you have pro
     
  15. Warrior1424

    Warrior1424

    Joined:
    Sep 30, 2010
    Posts:
    984
    Huh. I guess I'm all set then.
    Thanks everyone for the help!