When having to develop a UE4 project that deals with a tiny world scale, like the whole level being less the 50cm size for example, The following steps may help make the project more easily navigate-able and convenient to work on.
Scale down the camera Icon: UE4 has by default a huge, bulky, opaque camera icon. For a tiny scale project, this camera icon may cover the whole level and be very inconvenient to work with. Select the relevant camera component and scale it down. In my tests, this modified camera matrix isn’t breaking the camera optics in any way, But if you want to have no such scale offsets in your project, you can also replace the camera icon with a suitable small one.
In Editor Preferences > Viewport: Decrease both: Mouse Scroll Camera Speed and Mouse Sensitivity To allow finer navigation at small scale
Note: A global scale conversion factor can be used instead of taking these measures, And in many cases this can be a more practical solution for managing a sub 50cm world, For example, building everything 100X size so that 1 meter will be representing 1 centimeter in your project’s world. But take into account, that if the project demands rendering realistic physical lighting and optics, extra conversions will have to be made to account for the scale conversion factor, so is such cases it may be better to setup a real-world scale project.
The Static Lighting calculation in UE4 is performed by the Lightmass module (UE4’s integrated GI* engine), and the result of this calculation is stored in each object’s Lightmap, an extra texture map used for storing static light and shadow information.
This post provides a list of useful tips and techniques for improving your UE4 scene setup for an efficient light calculation.
Notes:
The following tips are aimed at achieving a good lighting calculation/solution but they don’t include optimization methods for high performance projects.
Namely, we don’t get into manual Lightmap UV optimizations here.
The following tips don’t take into account the now real-time ray-tracing options that have become available with Nvidia Geforce RTX / DirectX DXR.
Scene Setup:
Delete unseen polygons from your mesh, so they wont waste Lightmap resolution.
* For example, in an interior Archviz project, delete the outer polygons of the walls.
Set the architectural surfaces to cast shadows from both sides: Details > Lighting > Shadow Two Sided
Place “light blockers” around the structure to avoid light licks.
* Wrap the structure on all sides with scaled cubes that have an absolute black material:
Set the “light blockers” to be invisible in rendering:
Scale the Lightmass Importance Volume fit around the structure tightly.
Lightmap Resolution:
Optimize the architectural surfaces (static meshes) Light map resolution.
A higher resolution will allow the Light Map to store more detailed lighting.
The Static Mesh resolution setting is found in: Static Mesh Edior > Details > General Settings > Light Map Resolution:
* This setting can also be overriden at the actor settings by selecting the actor in the map/level and activating: Details > Lighting > Override Lightmap Res
Use the Lightmap Density optimization display mode to inspect the actual Lightmap texel density.
The Lightmap Density display mode also color codes the display to indicate the efficiency of the Lightmap resolution per object (green color being optimal, and warm colors being too dense)
* Note that in many cases of Archviz you may want a higher density than the editor displays as optimal.
Lighmass Settings:
The Lightmass setting are found in: World Settings > Lightmass
Decrease the Volumetric Lightmap Detail Cell Size to increase the light calculation accuracy:
* This will increase the calculation time
Decrease the Indirect Lighting smoothness to get more detailed shadows:
Disable Compress Lightmaps to avoid banding artifacts in the shadow gradient:
Use the Lighting Only display mode to evaluate the lighting solution:
For final quality, set the Light Quality to Production: Build menu > Lighting Quality > Production
* GI – “Global Illumination” is a term referring to indirect light simulation, namely a calculation of how light reflects and bounces between surfaces.
The TeoSidedSign node let’s the shader “know” if a rendered polygon is facing the camera or not by outputting a value of 1 for facing polys and -1 for back-facing polys.
This is useful for creating materials that have different properties when seen front-facing or back-facing.
Example 1:
Blending two different colors based on face direction:
Check the Two Sided material attribute.
* Needed so that the engine will render the polygons beck sides.
In the material blueprint, create a blend of to colors using a Lerp (LinearInterpolate) node and connect it to the material’s Base Color input.
Add a TwoSidedSign node to get polygon facing input (1,-1).
Connect the TwoSidedSign node’s output to a Clamp node to clamp the values to (1,0).
Connect the Clamp node’s output to the Lerp node’s Alpha input so that the polygon’s facing direction will control the Lerp blend.
Note:
You can use this method to blend any other material attribute based on polygon facing direction.
Example 2:
Create an “inwards facing” flipped normal material:
Set the material’s Blend Mode to Masked.
* Needed for being able to make areas parts of the mesh invisible.
Check the Two Sided material attribute.
* Needed so that the engine will render the polygons beck sides.
Add a TwoSidedSign node to get polygon facing input (1,-1).
Connect the TwoSidedSign node’s output to a Clamp node to clamp the values to (1,0).
Connect the Clamp node’s output to a 1-X node to invert the facing input.
Connect the 1-X node’s output to the material’s Opacity Mask input so that polygons facing the camera will be invisible.
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 versions 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 GitHubdesktop 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:
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…)
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.
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).
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
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.
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)
In GitHub Desktop, choose File > New repository to open the Create a new repository dialog.
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. 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:
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.
Open Git Bash for the new repository by right clicking its root folder background and choosing Git Bash Here:
In the Git Bash console, write the command: git lfs install
This command sets-up Git LFS for the repository:
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. 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:
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:
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.
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.
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…
Once the process of publishing the new repository has finished, we can browse the new remote repository on GitHub:
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:
Commit the changes to Git:
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.
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.
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:
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:
And displaying the following message when I tried to launch it through the Epic launcher:
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:
To this:
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:
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
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.
The example explained in this article is creating a blend between a mud material, and a mud-leaves material using a mask (Alpha) texture.
>> The scanned PBR materials in demonstrated in this post are from Texture Haven (texturehaven.com)
How does it work? There is actually no blending of Unreal materials, but rather a regular Unreal material in which each of the parameters is defined as a linear blend between 2 different source values for that parameter.
We could create such a material blueprint that uses a Lerp (Linear Interpolate) node’s to provide each of the material parameters with a blend of 2 input textures/colors or parameters, connecting the alpha texture to all the Lerp nodes’s Alpha input, and effectively achieve blending of 2 different materials, but it would be a complex blueprint in which it’s very inconvenient to design each of the individual materials participating in the blend:
This complexity can be greatly simplified by collecting each of the participating materials parameters into a Material Attributes data structure.
The Material Attributes data structure contains all the data needed to compile a material, and allows input, output, and processing of this data as a single blueprint data stream (connection).
For example, when the material parameters are grouped as a Material Attributes data structure, they can be blended by connecting them into a single BlendMaterialAttributes node, instead of “Lerping” (blending) between 2 inputs to create each individual material parameter, which produces an unworkable complex material blueprint like the previous example.
> To collect material parameters into a Material Attributes data structure, connect them into a MakeMaterialAttributes node:
> To create a blend between 2 Material Attributes data streams, use the BlendMaterialAttributes node:
* The Alpha parameter determines the weights of the blend (a black and white texture can be connected to it as the blend mask)
> In order for the material output to receive a grouped Material attributes input instead of individual inputs for each parameter, select the material output, and in the Details panel, check the Use Material Attributes option:
Using the Material Attributes data structure, the blended material’s Blueprint in now much simpler and cleaner, while producing the exact same result as before:
But designing 2 different materials within one material Blueprint is still far from being ideal..
What if we want to use just one of these materials on some surfaces?
What if the individual materials are not as simple as the materials shown here, it would be mush more efficient to be able to have one Blueprint for each of the materials allowing to focus on its development and preview it.
We can achieve this desired workflow by developing each of the materials as a Material Function.
Each of the participating materials is created as a Material Function with a Material Attributes output.
> One of the huge advantages of UE4’s material editing is that it allows us to preview a full material while developing it as a Material Function.
* This may sound trivial, but it isn’t. the Material Function isn’t compiled by itself as a material, it just produces data needed to define a material. in many other media production systems, this would have meant that you can develop data within the function but only preview it in the main material where the function is used.
The Material Function defining the mud-leaves material:
The Blend material using the Material Function nodes:
Note:
When blending a non-metallic material with a metal material, the alpha values (mask colors) should be only 0 or 1 (black or white), otherwise blend areas that have a mid-range metallic value will make no sense visually.
> A RemapValueRangenode can be used to force a color threshold on the mask texture or value.
Having to remap a value range is very common in designing shaders, whether it’s to perform a traditional “levels” operation on a texture, or use just a specific range of values in a float input.
The RemapValueRange node let’s us do just that. this node has 5 inputs:
Input: The input value
Input Low: Input mapping range minimum
Input High: Input mapping range maximum
Target Low: Output range minimum
Target Height: Output range maximum
Mono Noise examples:
The original noise pattern:
Mapping input 0 -> 1 to output 0 -> 1 obviously has no effect:
Mapping input 0 -> 1 to output 0.3 -> 0.7 reduces the pattern contrast:
Mapping input 0.3 -> 0.7 to output 0 -> 1 increases the pattern contrast:
Mapping input 0 -> 1 to output 1 -> 0 inverts the pattern:
In this example RemapValueRange nodes are applied to a texture’s individual color channels to increase contrast (Levels): > Note that this operation can be performed using a simpler graph by using float3d adding and multiplication operations on the texture color (this will be a subject for a different post) > Note that a different remapping operation can be performed on each color channel of a texture to adjust its color balance.
Before the value remapping:
After the value remapping tha value in each channel 0.1 -> 0.9 to 0.0 to 1.0:
The same operation performed by multiplication by 1.2 and subtracting 0.1:
To create animations and trigger them to play on game start:
First create a Level Sequence containing the animation:
Create a new Level Sequence actor:
Name the new Level Sequence and drag it to into the level:
Select the actor you want to animate in the level and double click the Level Sequence in the Content Browser to open it in the Sequencer window:
In the Sequencer window, press the +Track button to add a sequence track, choose the upper most option Actor To Sequence, the option to Add the selected actor will automatically appear first on the menu that will open on the right:
Add the selected actor as a sequence track, expand the track’s Transform channels to reveal the Transform property you would like to animate, and click the + button for that channel to create the first key-frame:
Activate the Create when channels/properties change option button:
Move the time slider to a desired time for the motion and move/change the actors transform to create a new key-frame:
The Level Sequence now contains animation for the Actor, but when we play the game, the animation doesn’t play.
For the animation to play in game, we must trigger it fro a Blueprint, in this case the Level Blueprint:
From the Editor Blueprints menu, choose Open Level Blueprint:
In the Level Blueprint, drag the Event BeginPlay execution graph and create CreateLevelSequencePlayer node that will follow it:
Drag the CreateLevelSequencePlayer node’s Return Value output and create a Play node that will be executed after it and receive it’s output:
The Level Blueprint now has instructions to play a Level Sequence,
but it’s not yet specified which Level Sequence to play:
In the Variables list on the left, press the +Variable button to create a new variable and name it:
With the new variable selected, in it’s details on the right, press the Variable Type button, and locate Level Sequence – Object Reference type:
The Level Blueprint now contains a variable named seq of type: Level Sequence – Object Reference:
Drag the new variable to the Blueprint and choose Get when placing it:
Connect the variable’s output to the Level Sequence input of the CreateLevelSequencePlayer node:
With the variable selected, in the details panel on the right, select the Level Sequence object it will be referencing:
Press Compile and save the Level Blueprint:
The Level Blueprint now has instructions to play the desired Level Sequence when the level begins playing so a the animation we created plays when we hit play game in the editor:
This simple Unreal Editor Python example sets the Z axis location of all actors with names beginning with ‘Sphere_’ in a way that their bottom (minimum Z bound) is at height 0.0.
import unreal
from unreal import Vector
lst_actors = unreal.EditorLevelLibrary.get_all_level_actors()
print('place actors at 0 z')
for act in lst_actors:
act_label = act.get_actor_label()
if 'Sphere_' in act_label:
print('placing: {}'.format(act_label))
act_location = act.get_actor_location()
act_bounds = act.get_actor_bounds(False)
act_min_z = act_bounds[0].z - act_bounds[1].z
location_offset = Vector(act_location.x, act_location.y, act_location.z - act_min_z)
act.set_actor_location(location_offset, False, False)
* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.
Note:
The get_actor_boundsunreal.Actor class method returns a tuple object containing 2 unreal.Vector objects, the first being world space location of the actor geometric center, and the second is the corner of the bounding box relative to the center.