Home Unity

Creating a real-time lighting solution for a procedurally generated environment

polycounter lvl 9
Offline / Send Message
barnesy polycounter lvl 9
Hey PC,

I was just wondering if any of you Unity Veterans could please help me out with a hypothetical lighting solution a tilable environment.

I am interested in how you would suggest tackling lighting multiple procedurally generated environments in Unity. I am thinking of a style similar to X - Com, where you would be able to pan across
the screen and see multiple small rooms with little procedurally generated guys walking through them.

XCOM-Enemy-Unknown-secret-underground-base-1024x576.jpg

In essence the rooms will be constructed randomly by putting together a series of tilable assets, ie: floor, wall tiles, computers etc

The project would be aimed at ipads and the lighting solution would need to work for a real-time solution.

In terms of my own solution, I was thinking about having a main directional light with a low opacity to act as global illumination, then adding multiple point lights to each room to make them unique,
while creating some nice soft lighting.

I was also thinking about looking into using semi-transparent lighting planes to fake the look of lighting have looked at is using lighting planes to fake lighting volume.

Another option was to just bake the lighting into the textures and use the lighting planes and a main directional light.

Apologies if this all seems really vague, I do not really have that much experience with lighting in Unity and the performance costs that are involved with lighting scenes.

Thanks in advance :)

Mike

Replies

  • Parkar
    Offline / Send Message
    Parkar polycounter lvl 18
    Hi,

    I am doing something similar but in first person and targeting PC so I am using the deffered pipeline with custom shaders using AO maps with ambient imagebased lighting, one directional light for sun/moon and a bunch of dynamic spot and point lights.

    I doubt something like this would be viable on a mobile platform though.

    I don't know to much about the capabilities of mobile platforms in terms of handling dynamic lights but I suspect it might be problematic to rely heavily on point lights in the rooms.

    If your rooms are not them self dynamically generated you could bake your own light maps in an external application and rely quiet heavily on them. You may even get away with baking the secular in those as from my understanding the camera angle will always be from the same general direction. Then you could use dynamic lights to light only the dynamic objects. Might also work well to use image based lighting from a static cube map for each room. All of this would require writing some custom shaders though.

    It's to bad beast can't be used to generate light maps for instanced prefabs.

    It's probably a good idea to do some prototyping to see what works and what doesn't.
  • barnesy
    Offline / Send Message
    barnesy polycounter lvl 9
    Thanks Parkar, the image based lighting from a static cubemap sounds like a pretty solid idea! I will have to do some tests with that and see how it goes :)
  • Elyaradine
    Offline / Send Message
    Elyaradine polycounter lvl 11
    If you want to have it running nicely on iPad (and this will vary depending on what stuff is in your scene and how you've authored/planned everything), having dynamic lights is super expensive.

    For the most part, you'd be sticking to baked lighting, using lightmaps and light probes. If anything is dynamically lit, it'd likely just be a very small number of objects (e.g. only the player character), and they'd likely have to be vertex lights (i.e. they tend to look quite plasticky).

    In my experience with mobile, unless having dynamic lights heavily influences gameplay (say, stealth games, where dynamic lights/shadows are important), you'll have a much easier time with both performance and quality of work (yay global illumination) if you bake everything into lightmaps and lightprobes. You can have your lightmaps as part of your object's prefab too, so when you instantiate your rooms they'd already be lit nicely without using any dynamic lights.
Sign In or Register to comment.