Category: Unreal

Unreal Week 4: Interactive Lighting Prototype with Blueprint

Weekly Goal:

Make a prototype of interactive lighting. Getting familiar with Blueprint coding.

 

Final Result Explanation:

I made blueprints to model three different types of lights: point light, directional light and spot light. All the lights are intractable. You can pick up the light and move / rotate it and you can change its parameters. The lights can be turned on and off with a button, also made with blueprint.

Point Light

Directional Light

Spot Light

 

Things I’ve learnt & Problems I’ve met

1. Fake mesh light

If you make the material unlit and make the mesh no cast shadow, the light inside will pass through the object.

Also, I found that if the material is unlit, the ‘cast shadow’ option is turned off. In the picture below, it shows the spot light I made cast shadows on the desk. This is because there’s a directional light in the scene.

To turn the shadow completely off, you need to deselect dynamic & static shadow options in the Details panel.

2. Using Interface in Blueprint

Blueprint Interface is a collection of one or more functions – name only, no implementation – that can be added to other Blueprints. Any Blueprint that has the Interface added is guaranteed to have those functions. It means in your blueprint you can call this interface of an object as long as it has implemented this interface. The realization of this interface can vary.

For example, in my case, I made an interface called interact and all the lights and buttons implement this interface. When my controllers touch an object, it calls the interact interface on that object and triggers the right way to handle it.

3. Get input for Vive Controllers

This is the blueprint I made at first. It is part of my HMD pawn class. I enabled input during Event BeginPlay.

It does not work because in Pawn, you need to use possess instead. Also in simulation mode, you can not get input until you pressed possess in the menu bar.

4. Map the experience to reality

When I first run my prototype in VR, the room axis look wrong. It is not aligned with Unreal’s x, y, z. The way to fix it is to do Vive room setup again.

I remeasure my playable area and marked it in my scene. It is 2.9m * 1.6m.

If set track origin to eye level: Since my HMD blueprint was used in a sitting experience, you need to reset the value. I put the controller on the ground and it is not on the virtual ground. Unreal has recommended character height to be 160 cm in this documentation: https://docs.unrealengine.com/latest/INT/Platforms/VR/ContentSetup/#vrcharactersettings. So if you set the Vive Camera Height to 80 (Note it is half the value you want) it will look OK.

If set track origin to floor level: Everything seems work well. The headset orientation is different though. Need more observation.

5. Very Stupid problem: cannot get controller input

Debugged a whole day about this issue… Turns out if you don’t turn on the controller before the app starts, it can not get the input.(Weirdly that the controllers were being tracked.)

Always turn on Vive first before open Unreal.

 

6. One last thing to note: Unreal’s own VR template. It implements teleportation, pick up and physics, and seems like a good template to use. I am not using it right now for learning purpose and may do in the future.

Here’s a guide to it: http://www.tomlooman.com/vrtemplate/

Unreal Week 2: Day Scene, HDR, Post Processing

Weekly Goal:

Get Familiar with the lighting in Unreal. Learn about its structure and make a day scene with foliage.

Final Result Explanation:

This is a standing experience. The player can go closer to the small houses and it will trigger a post-processing effect like a memory.

During my daily noon walk I saw this shadow on the wall and decided to make something similar to this. The scene is a small European town .  It’s not the final product yet, and I will work on this scene in later plan. The time is around noon and it creates the sharp shadow.

Parts Breakdown:

Importing models created with Maya into Unreal

I made the house model myself and tried to import it into Unreal. I would like to make each house a little different, so I didn’t combine the model, which created a mess in the content browser.

So I combined parts together but I have some power to customize it:

However when I am copy pasting the house in the scene I found it hard to organize. I tried to put it into folders, but seems that you cannot copy folders.

Also, when importing into Unreal, it does not keep the model’s pivot. You have to put your model on the origin to get the right transformation, especially rotation.

So I suggested assemble the models outside Unreal. Since I find some problems of the model I made, I am thinking of replacing the model in the future, and let’s see what trouble it will have. (As you can see below, the shadow has strange behavior.) As comparison, Unity’s prefab system is really easy to use.

Using HDRi to light the scene

Unreal support HDRi lighting in both its Skylight and its post-processing.

The left one is using the skylight, and the right one is using the post-processing cube. (Called ambient cubemap, and I also added ambient occlusion since there’s no shadow with ambient cubemap alone) The first difference is that the skylight creates shadow. (Not very obvious in the picture above but I noticed where below the roof and the pavement shading.) Another difference I found: in the refection map, it is layered differently.

For the skylight, it renders behind the scene. For the post processing, you can see it is rendered in front of the scene. See the blurry highlight?  ( Left: skylight. Right: Post-processing)

 

Post-processing Cube:

In unreal, you simply need to drag a post processing cube into the scene, then you can add a lot of cool effects. It gives a lot of controls for artist to better tune the scene.

I put two post-processing cube in the scene. The smaller one has fancy Chromatic Aberration, Vignette, Grain, Bloom and Lens Flare. I only set a small value since big intensity will make it look fake. I haven’t test how it feels inside VR.

The larger one only has Auto Exposure. I find it interesting since it is adjusting the exposure and has very natural transition. To better demonstrate, I turn down the light in the scene and here’s the result of enter/exit the post-processing cube:

 

Other tricks I learned

  • If the master texture is too complicated and you want to use just part of the texture parameters, you can put a white texture instead of creating a new material.
  • Keep you naming convention since Unreal is strict about repeated names.

Problem Unsolved:

  • When  I build the lighting after importing the trees, it gave me some error complains about overlapping UV. By default, Unreal imports the model and sets its lighting to static.  In unity, you can generate lightmap UV in the engine without doing another UV channel. Still trying to figure out what to do.

 

Credits:

HDRi: from HDRiHaven  https://hdrihaven.com/

Low poly tree by AnthonyVD: https://skfb.ly/6sSUr

Street by 3DMaesen: https://skfb.ly/6wtQu

Textures from quixel megascan: https://megascans.se/

 

Found a place which lists resources of HDRi maps:

https://www.daz3d.com/forums/discussion/57531/list-of-sites-with-free-hdri

The creator of HDRiHaven has an old post about how to correctly use HDRi:

There seems to be a bug in Unreal and the asset from HDRiHaven can not be imported. It generates an asset error but no message shown in the message log.  Resaving it with Photoshop will work.

 

Unreal Week 1: Getting Familiar with Unreal Engine

Weekly Goal:

Go through the interface. Understand the set up of a level & VR. Build a program for HTC vive. Make the player interact with the scene with the controller.

 

Final Result Explanation:

This is a seated experience. The player sits on the chair and there’s an alien cube in front of him. By touching it with the controller, the lights outside will be turned on.
The two images below shows the scene before and after the light turns on.

Parts Breakdown:

Vive Setup:

It is very easy to set up the Vive. Keep SteamVR on and you can access the headset & controllers. No need for special settings; however, you do need to write your own blueprint to use it.

I created on according to the official tutorial. I also imported the Vive controller model. One problem I encountered was that, I scaled the controller model since it’s not the right size inside Unreal, and the controller is not moving correctly.

The fix is to scale the model to the right size outside. Then import with scale 1.

There’s more Vive-related control that I haven’t explored.

 

Material Network:

The material network is similar to Maya’s. Compare to Unity, it is more powerful and also more complicated. It brings a lot of artistic freedom (During my study, I found that Unity is also adding something similar in its newest beta version.)

If you installed the substance plugin you can directly import the .sbsar file into Unreal and it will be extracted to texture files. Remember to set the textures to the right color space ( and flip normal green channel).

One thing I really like about Unreal is its master & instance material hierarchy. When creating a master material, you can set parameters and when you instance them, the instance material can only do modification to these parameters. It’s a great way to manage repeated shaders. When the master changes, all the instances will change too.

I created different kinds of materials this week:

Glass – translucent

Plants & Leaves – masked, translucent & two sided

Lamp – emissive

Landscape – using special nodes to blend two texture together ( need further study)

 

Simple Blueprint:

Blueprint is another powerful tool in Unreal. Without writing any code you can create interactions in the game:

This is a simple implementation of touching the cube and triggering the lights to toggle visibility.

 

Creating Landscape:

I made a simple landscape with Unreal’s build in tool. It’s similar to Unity’s except for the material part. You need to set the textures in the landscape’s material to paint it.

 

Lighting Overview:

I went over different lighting type and its parameters. I also did some research about Unreal’s advantage over Unity about lighting:

What Unreal is better at:

  • linear colorspace
  • signed distance shadow
  • PBR
  • post process

Unreal is very good for creating realism environment. Unity is easier to use, and to learn Unreal you need to learn its workflow.

 

Credits:
Models:

forest by RubenBuchholz644c9d600cf24bcb on sketchfab – https://sketchfab.com/models/b1aec792d03a4d11a91cc4c0d7c8fb7e

room by Anex on sketchfab – https://sketchfab.com/models/6417cbc1870a4a1691cca06912ae0369

Textures & Materials:

textures.com

substance share forum

quixel megascan