UE4 – HDRI Environment & Lighting

Software:
Unreal Engine 4.25

Annotation 2020-05-20 162811

Creating HDRI environment backgruond and lighting* in UE4:
Note:
Lighting using a panoramic HDRI background is also referred to as IBL – Image Based Lighting.

* The example HDRIs in this post are from www.hdrihaven.com

  1. Import HDRI environment file.
    Note:
    The file must be saved as a *.hdr file and not *.exr because AFAIK that’s the only way UE4 will recognize it as an HDRI environment and encode it as a Texture Cube (cube map)
  2. Enable the HDRIBackdrop plugin:
    Go to Edit > Plugins
    Type “HDRI” in the search field to locate HDRIBackdrop and enable it.
    * You’l have to restart the UE Editor before using the plugin
    Annotation 2020-05-20 153925
  3. Drag a Lights > HDRI Backdrop object to your level:
    Annotation 2020-05-20 154657
  4. In the HDRIBackdrop details, select the wanted Cubemap:
    Annotation 2020-05-20 155212
  5. > Set the HDRIBackdrop‘s Intensity (self explanatory..).
    > Rotate the HDRIBackdrop around its Z axis to set the environment’s direction.
    > Set the HDRIBackdrop‘s Size.
    * Make it larger than your whole scene,
    And if Use Camera Projection is unchecked make it also large enough so that noticeable objects in the HDRI image will be distant enough as to not move incorrectly when you strife.
    * When Use Camera Projection is activated the Size property has no effect.
    > If Use Camera Projection is unchecked, set the Projection Center Z value to define the background image height below which it is projected as a flat ground.
    > Lighting Distance Factor defines ground projection area that will appear to receive shadows from your scene objects.
    * Set this attribute to 0 in-order to turn off the ground projection shadow.
    > Use Camera Projection:
    Activate this option to get a traditional infinitely far background with no flat ground surface projection.Annotation 2020-05-20 160338

 

Related:

  1. Sun & Sky link
  2. UE4 Architectural Glazing
  3. 3ds max & V-Ray to UE4 Datasmith workflow
  4. Preparing an FPS project for archviz
  5. UE4 – Archviz Light calculaion tips

UE4 – Change the size of the UI and fonts

Software:
Unreal Engine 4.24

To Change the size of the UI and fonts in the Unreal Editor:

  1. Select:
    Window > Developer Tools > Widget Reflector
    To open the Widget Reflector window
    Annotation 2020-04-23 150847
  2. In the Widget Reflector window, change the Application Scale parameter:
    Annotation 2020-04-23 151022

Unreal Engine 4 + GitHub First Steps

Software:
Unreal Engine 4.24 | Git for Windows | Git LFS | GitHub Desktop

What is this all about?
A game development project is in fact a software development project, and therefore requires Source Control (aka “Version Control”).
A Source Control solution is a software system that registers and stores states of the code as it develops, and allows the developers to manage the changes, compare different versions of the project, revert to previous version and much more.
There are more than one popular Source Control solutions in the market.
This article is written specifically about setting-up Source Control for an Unreal Engine 4 project using Git Source Control software, focusing on working with the GitHub desktop client app for Windows.

Disclaimer:
Although I’ve already had some experience using Git Source Control,
This is the first time I’ve had to set it up for myself by myself from scratch specifically for UE4 (using Git LFS), So this article can’t be regarded as an authoritative guide to the subject.
This is simply an informative record of the steps taken, problems encountered, notes, etc.
Hopefully, this post will be helpful, and if you find mistakes, inaccuracies, or that I forgot some steps, I’ll be grateful if you’ll post a comment.

General Preparations:

  1. Create a GitHub account:
    github.com
    Note:
    The installations of the Git client tools in the next steps will require your GitHub login credentials (I don’t remember exactly which and when, because I didn’t document every step being busy getting things to work…)
  2. Install Git for Windows:
    gitforwindows.org
    Note:
    With the installation of Git for windows we not only get the Git Client software, responsible for performing all the Source Control operations, but also Git Bash which is (in my opinion) a very convenient command-line console specialized for Git operations.
  3. Install Git LFS:
    git-lfs.github.com
    Note:
    The Git LFS client is responsible for compressing and uploading the large binary files, which is to simply say, the files that are not ascii text format like software source code files / scripts / meta-data / settings etc., but typically media files like 3D models, graphic files, audio and the like.
    We generally don’t have to do anything directly with the Git LFS client, The Git Client automatically runs it, and it operates according settings written in text files placed at the Git repository root folder (more detail on this below).
  4. Optional: Install GitHub Desktop:
    desktop.github.com
    Note:
    This is an optional desktop Git client with a GUI for performing git operations.
    You can do everything without it, but its convenient, and was specifically helpful for me with setting up a UE4 repository, because it provides preset Git LFS settings (more on that below).

Steps for setting up a UE4 project GitHub repository:

Note:
I’m using GitHub Desktop to initialize the repository with UE4 Git LFS settings and also
  1. Create an Unreal Engine 4 project (if you haven’t already created one..)
    Note:
    If you want the 3D assets, texture files, etc. to be tracked and version controlled as an integral part of the UE4 project, add a “Raw_Content” or “Raw_Assets” folder inside the UE4 project folder to store them in their editable formats prior to being imported to the Unreal project.
    Uploading such large binary files to git requires using Git LFS as described below.
  2. Important: Backup a full copy of the UE4 project somewhere safe at least for the first steps.
    Note:
    I Actually needed to use this backup to save my own project (see below)
  3. In GitHub Desktop, choose File > New repository to open the Create a new repository dialog.Annotation 2020-04-18 212957
  4. A. In the Name field Type the exact name of the UE4 project (The name of it’s root folder).
    B. Write a short description of your project in the Description field.
    C. Set the Local path to the folder containing the your project folder, not the project folder itself.
    D. In the Git ignore drop-down select the UnrealEngine Option.
    E. Press the Create repository button.Annotation 2020-04-18 213139
    Note:
    Stage D is very important, it creates an initial .gitignore file with specific settings for a UE4 project, namely what files and folders to track and upload. a UE4 project generates massive files that are needed to run the game but are redundant, because they can always be generated again. these files shouldn’t be tracked or uploaded, and without proper settings in the .gitignore file, you wont be able to push (upload) the repository to the remote server.
    This is one of GitHub Desktop’s advantages, that it offers these Git Ignore presets.
    Another Note:
    We could “Publish” the repository to to GitHub server at this stage (see explanation below).
    But the reason I don’t recommend performing this action at this stage is that for a UE4 project to be successfully uploaded (“pushed”) to the remote server, we must have proper Git LFS settings, which we haven’t finished to set up prior to that.
    Blender Note:
    If you work with Blender and it’s setup to save the *.blend1 backup files, it’s recommended to add this type of file to the Git Ignore file like this:Annotation 2020-05-29 140520

Setting up Git LFS for the new repository:

Note:
Git LFS (Large File Storage) is necessary for tracking and uploading large binary files like 3D models, texture files, audio, etc.
Depending on the size of your project, you may need to upgrade the LFS storage capacity of your GitHub account.

  1. Open Git Bash for the new repository by right clicking its root folder background and choosing Git Bash Here:Annotation 2020-04-19 002454
  2. In the Git Bash console, write the command:
    git lfs installA
    This command sets-up Git LFS for the repository:B
  3. For every type of binary file that you want to be tracked and uploaded by Git LFS,
    Type the command:
    git lfs track *.<file type extension>
    To add this file type to the list of files tracked by Git LFS:
    * This list is stored in the text file named “.gitattributes” that was automatically created in the project folder when the repository was initiated.C
    Note:
    You can at any time type the command:
    git lfs track
    to display a list of the file types being tracked.
    You can open the .gitattributes file and see the list.
    This is an example of the LFS track list for one of my UE4 projects:E

Publishing the new repository to the GitHub server:

Note:
This step includes initiating the remote repository on the GitHub server, setting it as the local repository’s origin, verifying it and pushing (uploading) the current state of the local repository to the remote one.
GitHub desktop let’s us perform all these actions at ones with it’s Publish repository button.
If you wish to know how to perform these operations without using GitHub desktop, this article gives detailed explanations.

Steps for publishing the new repository with GitHub desktop:

  1. Commit the recent changes (Git LFS settings we just set):
    In Github desktop (assuming the repository we just initiated is selected in the Current repository drop-down), in the Changes pane, observe the list of latest changes to the repository. it should include the changed .gitattributes file, and maybe more changes.
    In the Description field, type a short description of the changes like “Updated Git LFS settings” for example, and press the Commit to master button to commit the updated state of the repository to the source control history.Annotation 2020-04-19 012328
  2. Publish the repository:
    The next actions will both initiate a remote repository on the GitHub server, set it up as the origin of the local repository, and push (upload) the the local repository to the server.
    In GitHub desktop, make sure the new repository is selected in the Current repository drop-down and press the Publish repository button to open the Publish repository dialog.Annotation 2020-04-19 012509
  3. In the Publish repository dialog, name the remote repository (AFAIK it doesn’t have to be the exact name as your local repository’s root folder’s name, but it’s convenient if it is..), Type a description for the project, check weather it should be public or private and press the Publish repository button.
    The repository’s remote origin will now be initiated, and the local repository’s state and commit history will be pushed (uploaded) to the server to update the origin.
    * Depending on the size of your local repository, this may take some time…Annotation 2020-04-19 012541
  4. Once the process of publishing the new repository has finished, we can browse the new remote repository on GitHub:Annotation 2020-04-19 013620

Regularly committing and pushing updated state of the project/repository:

Note:
You might want to commit an updated state of your project to source control at the end of a day’s work to back it up, or when some specific development goal has been reached, or prior to some significant change, or maybe in-order for other team members/users to be able to get the latest version of the project. there could be many reasons for committing the current state of the project to Git, but the most important reason is that you want to be able to restore the current state of the project In the future.
Steps for committing the updated state of the repository to Git and pushing it to the remote server:
  1. Commit the changes to Git:
  2. In Github desktop select the repository of your project in the Current repository drop-down, observe the list of latest changes to the repository in the Changes pane, where you can highlight a changed file and see on the right the actual change in code it represents. un-check changes you don’t want to commit.
    In the Description field, type a short description of update, and press the Commit to master button to commit the updated state of the repository to the source control history.Annotation 2020-04-20 232346
  3. After the latest changes have been committed, you’l see the new committed state appear in the History pane, with an upwards arrow icon indicating it hasn’t been pushed to the server yet.
    Highlight the top committed state and press the Push origin button to update the remote repository on the GitHub server.
    Note:
    When the repository wasn’t yet initiated on the remote server,
    The same button that now has the title Push origin had the title Publish repository.Annotation 2020-04-20 232419
  4. While committing changes to source control for version management and backup is the basic usage of Git, there are many more source control operations that can be performed, like reverting to past commits (states) of the repository, opening new branches for to manage different version of the project, merging branches etc. to name just a few examples. these operations are beyond the scope of this article, and I strongly recommend to get to know them and more.

Unreal Editor Git Plugin:

Annotation 2020-04-21 222458
There is a free, open source Git client plugin for the Unreal Editor developed by Sébastien Rombauts, that ships (at beta stage) included with UE4 4.24, and has many useful features integrated into the Unreal Editor like initiating the project repository with Git LFS setting, committing project states directly from the within the Editor, comparing versions of blueprints and more.
I did some tests with the plugin and found it very convenient, however It doesn’t track changes to the projects C++ code so if your coding you’ll have to commit code changes using a different Git client.
It may be that I just didn’t understand how use the plugin or set it up to track C++ code. I didn’t to find out if it officially doesn’t support this. however, if you work heavily with Blueprints It should be very useful.

Some issues I encountered:

Note:
I don’t know if these issues happen frequently, the reason may very well be me not doing things correctly.
There may be simple solutions to these issues that I don’t know about..
What’s absolutely certain is:
When you’s about to start your first steps with source control on a real project, make sure you back it up first!
Corrupted .uproject file:
After the first time I managed to get all the LFS setting right and successfuly push publish the project, strangely, it wouldn’t launch in the UE Editor, displaying the following message when I tried to double click the project .uproject file:
Untitled-1
And displaying the following message when I tried to launch it through the Epic launcher:
Untitled-2
After some inquiry I found out (to my astonishment) that some how the git operations have replaced the text contents of the .uproject file from this:
Untitled-3
To this:
Untitled-3
Luckily for me I had a full backup of the whole project before starting the setup trial and error process, so I could manually restore the .uproject file to it’s correct state and go on working.
Corruption during download from GitHub:
After a couple of successful commit and push operations with my project, I decided to test how a git repository works as backup, so I tried to download the project folder compressed to a zip file.
The extracted project would launch and compile, but fail to load the main (and only) level it had, displaying this message:
clone
Looking into this, I found that the level umap file is was actually in it’s place but drastically reduced in size:
* The left is the original
clone2
The good news:
I then tried to clone the project via git clone command, and that way it did work as expected.
That’s it!
I hope you’ll find this article useful or even time/error saving.
If you find anything unclear, inaccurate or missing, I’ll be grateful if you leave a comment.
Happy Unrealing and Source Controlling! 🙂

UE4 – Blueprints – Set Parent Class

Software:
Unreal Engine 4.24

When It comes to OOP inheritance, the best practice is to take a moment to think about code structure and decide which classes should be be extensions of a common super-class. But in a wild hackathon or game-jam, we may be blueprinting too hastily for that, and we may find out different blueprint classes actually have to be child classes of a common parent class after they already exist and have existing blueprints in them.
In this case will have to Set their parent class as a different class than the class we chose when we initially created them, and also create calls to the parent class event functions if needed.

Setting a BP’s parent class:

Click Class Settings, and under Class Options, in the Parent Class drop-down select the wanted parent class (superclass).
Annotation 2020-03-22 131138

 

Calling the Parent Class’s event functions:

Note:
When creating a BP class that is defined as child class in its creation this is done automatically

  1. Right-Click the current class’s Event icon, and select Add call to parent function:Annotation 2020-03-22 153156
  2. Connect the execution flow graph, and other inputs if necessary:
    Annotation 2020-03-22 161019

 

 

UE4 Blueprints – Spawn Actor Transform Note..

Software:
Unreal Engine 4.24

Short version:
When Spawning new actors via the SpanActor Blueprint node, initial transform must be supplied to the SpanActor node, and not defined in the spawned Actor Class’s Blueprint.

Annotation 2020-03-22 131138

Explanation:
Just found out the hard way, that when you spawn an Actor using the SpawnActor blueprint node, the transform data connected to the SpawnActor node is actually applied after the actors Construction Script and BeginPlay Event.
This means any transform you will try to apply in the spawned Actor’s Blueprint will be overridden and therefore not work.

UE4 – Enable complex collision for models

Software:
Unreal Engine 4.21

By default UE4 uses fast simplified convex collision shapes to calculate collision for static mesh actors.
This means that the player or projectiles wont be able to path through holes, openings or doors in the model.

To set complex (concave) collision for a static mesh model:

In Static Mesh editing window, in the details pane, under Collision:
Set Collision Complexity to: Use Complex Collision As Simple

Static_Mesh_Complex_Collision.jpg

This example shows the default behavior for a model that has an opening, neither the projectiles nor the player can pass:

Simple_Collision.gif

In this example collision for the model was set to Use Complex Collision As Simple:

Complex_Collision.gif

 

Sprite Sheet – Storing animation frames in one texture

Runner_Atlas

An efficient way to store 2D animation for games is to layout all the frames withing one texture called a ‘Sprite Sheet’ or ‘Texture Atlas’.
This saves resources by avoiding multiple texture loading operations and only animating the UVs of the shader to display the needed image at each frame.
Sprite Sheets are also used to pack various states of game graphics and textures for multiple objects in one file.

Creating Sprite-Sheets:
Sprite Sheets can be created manually using any image editing software,
For an automated process and more control, a specialized software like Texture Packer can be used.
And it can also be done automatically in Adobe Animate (Flash).
* There are many more solutions / scripts that will do that you can find on the web…

Creating a Sprite Sheet in Animate

Software:
Animate CC 18

To generate a Sprite Sheet (Texture Atlas) in Animate:

  1. Create a new project.
    * the type of the project doesn’t matter.
  2. Drag all your animation frames from into the Library window in Animate.
  3. Select all the frames in the Library window.
  4. RMB Click the selected frames and choose Generate Sprite Sheet.
  5. In the Generate Sprite Sheet window, set the Sprite Sheet settings, output path and press Export.

Untitled-1.jpg

Untitled-2

Untitled-3

Runner_Atlas