Experimenting with HDR Skyboxes in Unity 5.

Unity 5 has implemented a HUGE update on the rendering / graphics side of the engine, introducing new lighting workflows with realtime GI, a Physically Correct Shader (Metallic & Specular workflows supported) among many other things..

I wanted to do an experiment today, where I test out HDR Skybox’s in Unity 5 to see how drastically the lighting and mood of a scene can change.

HDR:

High-Dynamic-Range is an imaging photography technique to produce a higher dynamic range of brightness. This is achieved by capturing different exposures of your chosen subject matter and combining them into one image.

In Unity we can use these HDR images to help blend 3D models into the environment, this can drastically add to the belief that the 3D model is actually in the environment.

Quick mention – I’m using HDR images from NoMotion HDR’s¬†– 150 free HDR images, check EULA before using for commercial usages.

I’ll be showing how these 3 HDR images help create a completely different feel and look to the scene:

I have daytime, evening and night-time HDR’s, they should all create drastically different lighting conditions in Unity.

Time’s up chumps..let’s do this:

Unity 5’s new standard shader has built-in support for image based lighting (IBL), this really helps with the belief that the 3D model is in the environment I am setting with the HDR skybox.

Here’s the model with just Unity 5’s current default procedural skybox:

Default Skybox

With a bit of trickery (not really, just pushing a few buttons in Unity), let’s now see what happens when I add the daytime HDR Skybox:

Daytime Skybox

I haven’t messed with any lights at all, all I have is the default Directional Light in the scene with default settings. looks rather impressive after just adding a new HDR Skybox to the scene.

Let’s try the evening HDR Skybox now:

Evening Skybox

Awesome, I am really enjoying playing around with this, I love how quickly I can completely change the lighting conditions which in turn drastically changes the mood and atmosphere in the scene. I can’t wait to see how games are going to utilize these new features.

Okay, last one, the night-time HDR Skybox, I’m a little skeptical about this one, I’ve no idea how this will look and I imagine it’s not really desirable to use a night-time HDR image. Anyway, let’s see what it looks like:

Nighttime Skybox

Actually turned out rather well, the image doesn’t show the white spots on the model as much as in the editor, these white spots are produced by the specular smoothness on the Standard Shader, i.e the more smooth I make it the more white spot artifacts are produced, not sure why this is more present in the night-time scene, I’m sure there’s a setting I’ve missed or something..

Overall, I’m really impressed with this, especially how quickly I can change the mood and lighting of the scene and the visual output from Unity 5’s new rendering / graphics update.

Look forward to seeing what you all produce with Unity 5. ūüôā

Unity and the Beast

I must say I experiment a lot with Lightmapping in Unity using Beast and I have never wrote anything about it, so I wanted to share what it is and how it might be useful to some of you.

Since the time of Quake¬†which¬†was the first video game to utilize lightmapping, Unity has integrated the Beast lightmapping technology for both the pro and free version, yes! you can use expensive rendering power for free on your games, I know what your thinking…this is awesome, and it is, ¬†lightmaps can really bring your environments to life.

What are lightmaps?

If you have read this far without knowing what lightmaps are, I’ll give a quick overview, a typical lightmap is light data stored into a texture and applied to static objects in your scene, lightmaps in Unity take into account meshes, textures, materials and lights.

Unity contains 3 lightmapping modes to choose from, Single Lightmaps. Dual Lightmaps and Directional Lightmaps, each mode has slightly different functionality.

Single lightmap mode uses the far lightmap only, this is a baked texture, so pre-computed and contains full illumination.

Single lightmaps

Dual Lightmaps use a near and far lightmap texture, the near lightmap texture contains indirect illumination from lights set to auto, full illumination if your lights are set to BakeOnly, emissive materials and sky lights.

This near lightmap is only used when within the distance of the camera, when within the camera distance auto lights are rendered as realtime allowing for specular, bump and realtime shadows, this is not a feature for single lightmaps.

Single and  Dual Lightmap

On the right hand side on the image showing dual lightmapping, the near lightmap texture is used, this is because we are within the camera’s distance, near lightmap texture is showing both specular and bump, as if it was realtime lighting. If we were to pan the camera away from the leaf we would eventually not see the bump and spec because it will fallback to the far lightmap, which is shown on the left.

Using Directional lightmapping in Unity has the ability to bake specular and normal maps into the texture without using any realtime lighting, the lightmaps encode the direction of the light so that it can be used in the pixel shader to vary the lighting depending on the per pixel normal and calculates specular for the average light direction.

The image below shows baked specular using directional lightmaps, I have a simple mouse orbit script attached to the camera which allows me to see the specular highlights on all the cubes in the scene.

directional lightmap

Other area’s of lightmapping which I haven’t mentioned in any real detail or at all are using emissive materials, they can give some really interesting effects, as well as area lights, light probes and lightmapping¬†dynamic objects, that’s a whole new¬†dimension¬†of fun.

Maybe I’ll write about those some other time, for now I encourage you all to have a play around with lightmapping. Catch you soon!