textures

Lacuna Passage - Devlog #52.5 - Lightmapping with Emission in Unity 5

Light mapping is a technique where you can bake the light from a scene into objects so that they self-illuminate based on a generated lightmap texture that usually is mapped to a second UV channel. This is a great solution to reduce the number of light calculations needed on static objects. But what if you have an object in the scene that needs to appear as if it is projecting light and casting shadows on other objects - and you also want to control the color and intensity of the light ingame? Well that’s where emissive lighting comes in handy.

Emissive lighting is typically used to self-illuminate objects in a scene and make them appear as the light source. A texture specifies the areas of the object that you want to emit light and global Illumination bounces this light onto other objects in the scene. Below is an example of a typical emissive object with global illumination affecting the scene around it.

But when you want precise shadows and lighting that matches the emission produced you need to get a little more complex. Baking the light casted from the emission source in your modeling software can achieve this effect with only a little extra effort. So, in effect, we want to produce our own lightmapping outside of Unity and apply it to the emissive channel in our Unity material.

First things first, we need to get a demo scene started in our modeling software. I’m going to be using 3ds Max along with the Mental Ray renderer. Below is the basic scene in 3ds max (top) and our desired look using a spotlight in Unity (bottom).

The hemisphere in the corner is the lamp of our scene and its bulb will illuminate our objects. To emulate this lighting in 3ds Max we need to place a light source in the center of the bulb. I used a Photometric Free Light and set the shadows to “Ray Traced” and the emit shape to “Sphere.”

Because I am using Photometric lights, I made sure my scene units match that of real-world objects. In this case I used 4 cm for the lamp bulb and made the radius of the emit shape also 4 cm.

After tweaking some of the light and shadow settings, I made a new Arch & Design material to place on our objects. In the diffuse color map slot I placed my diffuse map.  In the glossiness map slot under the reflection rollout I placed my gloss map. I made sure the diffuse and reflection colors are set to pure white, and the reflectivity is set to 1.0. I also checked the “Highlights+FG only” option because bounced light will be taken care of by global illumination in Unity.

Finally, I added a Normal Bump under the Special Maps rollout with the normal map of our projected high poly (Make sure you flip the green channel). After a couple quick render tests I decided to increase the gloss output to 2.0 to make the highlights tighter.

Now that we have our light and materials setup, we just need to render the light to a texture map. To do this, we open the Render to Texture dialog (Rendering > Render to Texture…). With our all our objects attached into one mesh we can easily render the entire texture at once. With our single object selected we can set our render to texture properties accordingly.

Scroll down to the Output rollout and add a “CompleteMap.” Complete maps incorporate all light information including normal, gloss, and diffuse maps into our bake. Set the texture size and save location accordingly and make sure “Shadows” is checked. Then hit “Render.”

Once the render is complete, decide if you need to increase the quality of the shadows before going to Photoshop to tweak any errors. You can do that by going to Rendering > Render Setup and opening the “Renderer” tab. Here you can tweak things like light sampling and noise thresholds. You could also go back to your light source and tweak its settings.

The end result is a custom emission map that reflects the lighting in your 3ds Max scene:

Then you just bring all your assets and textures into Unity and plug them into the Standard shader (I used the specular version). Here’s a quick video of how the emission lighting method compares to a spotlight within Unity:

In the example at the end of the video you can see some of the benefits of this method. Instead of lightmapping the entire hallway we can simulate lightmapping on a single asset that looks reasonably good even when duplicated in several places around the scene. This works particularly well when the light source is attached to the object that you want to have simulated direct lighting. The lighting never needs to be rebuilt and the resolution of the emission map can be scaled smaller than your other texture maps if needed. The emissive properties can also be easily changed at runtime to create effects like flickering or colored lights. The emission coming from our transmissive plastic also contributes to the scene's lighting via Unity's precomputed realtime Global Illumination.

Lacuna Passage - Devlog #34 - Designing the Hab Part 2

Make sure to check part one of our continuing "Designing the Hab" art preview.

The Hab is designed to serve as the main living area for the Hermes and Heracles crew, so it will be a tightly knit and practical space full of dense detail. This week we want to highlight a couple new areas within the Hab and talk briefly about their design.

The laundry and bathroom unit combine into one compact space that utilizes more of the recessed wall space.  The shower, sink, and toilet are all located up a ladder-like set of stairs and behind the area that houses the washer, dryer, and cabinet space.  Combining these units would be a logical way to reserve less space for plumbing across the Hab.

Next we have the bunk sleeping quarters.  There are six bed spaces divided across the main walkway with a large table.  The table can be used for research, repairing equipment, or anything that requires a little counterspace.  Each bunk is equipped with personal locker space, a sliding isolation door, and even a digital screen with a built in radio.  Eventually there will be photos, letters, and other personal items that decorate each crew members’ bunk.

We are all very satisfied with the direction the Hab is going.  Improvements are being made everyday and we can’t wait to finish adding in all the details that make up this complex living space.  Our next big hurdle in the art for Lacuna Passage will be the Greenhouse - so be sure to check back to catch more on its development in the near future.  As always, feel free to comment below!

Lacuna Passage - Devlog #33 - Designing the Hab

My name is Spencer Owen and I am the lead artist for most of our internal habitats and other mission structures. I will be contributing posts to our devlog over the course of development pertaining to the design and art decisions that are being made. For my first post I am going to go over some of the decisions we have made for the main Habitat that you have seen previewed in previous posts.

The Foundation Base Habitat has come even further this past month.  We have added a few new pieces and are currently in the process of messing with the shaders and textures to achieve a cohesive look throughout the Hab.  The internal volume of this structure is meant to be dense and functional, but also a bit spacious and relaxing for the crew.  We are shooting for a certain realism in the Hab that will allow us to satisfy these restrictions.

Since most spacecraft today are designed for zero gravity, you will often see cargo holds and electronics strapped to every surface of an interior such as this.  Our Hab will need to function on the surface of Mars, meaning we have to design a little differently than the ISS.  We had to look for inspiration in things like campers, RV’s, and trailer homes.  I’ll highlight a few areas and talk about the design decisions.

In the kitchen area the size of the appliances and their position is most important for functionality.  Additional cabinet space for the non-essential equipment is stored above, accessible with a ladder.

In the couch seating area we chose to recess the couch into the wall, revealing the shape of the exterior hull.  This way the couch does not obstruct the main walkway, but instead serves as an alcove for relaxation, with a great view of the Martian surface.

The media center area sits directly across from the couch seating area, allowing the television screens to be used for entertainment, communication, or presentation.  The table serves multiple purposes as well, with adjustable computer stations located nearest the wall.  Radio and media equipment sit within arm’s reach.

Another design goal for us was to highlight the functional areas of the Hab so that the player can immediately recognize them.  In order to do that we will be using a signature orange color in the textures of interactive objects and locations, similar to games like Mirror’s Edge.

Most of all, we want the Hab to feel like a safe place for the player to relax and go over any information they find between EVA’s.  We still have work left to do, but we are really starting to get the atmosphere and design of the Hab’s interior finalized. The design problems we have solved here will carry over into the other internal environments throughout the game.

We will be featuring more of the internal modules of the Habitat over the coming weeks in another blog post. If you have any questions feel free to sound off in the comments!

Continue to part two of our "Designing the Hab" preview.

Lacuna Passage - Devlog #6 - Using highly detailed 3D components in your first-person HUD

This week’s devlog is a bit more of a tutorial where we cover our method for creating dynamic, highly detailed 3D HUD elements. The basis for our pipeline involves rendering complex high-poly models onto flat, single polygon planes with a normal map for light interactions.

helmet_in_game.jpg

Pros of this method

  • You effectively have an unlimited polycount for your HUD. By rendering your high poly model to a flat plane you will have no noticeable polygonal curves or sharp edges (if you don’t want them, that is)
  • Extremely low poly count in relation to the quality of the illusion

Cons of this method

  • A change in HUD design requires re-rendering of all your texture bakes
  • The HUD cannot move in relation to the camera or the illusion breaks

So, let’s get started:

1. Setting up your camera angle

In order to model your HUD components you need to setup a camera in your modeling software that is exactly the same field of view as your first-person camera in your game engine. This will help you preview what your HUD will look like in game. It’s also going to be very important later when we need to render out a normal map.

2. Build your model according to the view you want in game

This part just comes down to whatever style you are looking to have with your particular game. In our case we are creating a small visible portion on the inside of a space helmet.

camera_plane.gif

​3. Create a plane to project your model onto

Once your model is finished (no need to texture it yet) you need to create a plane that completely encompasses your model from the point of view of your first-person camera.

camera_plane_orientation.gif

4. Orient the plane to your camera angle

Make sure that the plane is exactly perpendicular to the origin point of the camera. Check the image to see a visual.

5. Quickly unwrap your plane

No frills here. Just unwrap the plane however you like.

camera_plane_normals.gif

6. Render your normal map

Use Render to Texture with a projection modifier on your plane that encompasses your model to create a normal map of the original model. If you’ve never done a normal map bake from a high poly model before check out this guide.

textures_helmet.jpg

7. Create your textures

You can create your textures in Photoshop or texture your original model and do another render to texture for the diffuse instead of the normal map.

8. Create an alpha mask for the model’s texture

Since our projection shape does not perfectly match our plane we need to have an alpha channel somewhere that determines areas of transparency.

dustdevil2.gif

​9. Import your plane and your textures

Bring everything into your game engine and align the plane exactly as you had it in your camera preview in your modeling software. In our case we are using Unity so here are some tips to help you out.

Unity specific directions:

  • Have your plane parented to a HUD camera that is distinct from your scene camera
  • Have the HUD camera render last and mask only the HUD elements
  • Make sure the clear flags are set to Depth Only to preserve your depth buffer
  • Use the same HDR settings on all cameras if you are using image effects
So, there you have it. If you have any questions feel free to leave them in the comments.