Blender to Unreal Engine tips

Software:
Blender 2.9 | Unreal Engine 4.25

The following is a list of guidelines for preparation and export of 3D content from Blender to Unreal Engine 4 via the FBX file format.

Disclaimer:
This is not a formal specification.
It’s a list of tips I found to work well in my own experience.
* Some of the issues listed here may have already been solved


Blender Scene and model settings:

System units in Blender:
Define the scene units in Blender as:
Metric unit with 0.01 scale (centimeters)
And model your content correctly using centimeter units.
* Modeling in 1 meter units may seem to be imported correctly into UE4 but will cause unsolvable problems like a skeletal mesh physics asset having incorrect auto-generated shapes, a problem that in my experience can’t be fixed manually.

Transform:
Model your model in Blender facing the -Y world axis, +Z obviously being up (obviously for Blender).
* This way the model is aligned to Blender’s views so the front view displays the model’s front etc.
Make sure to apply your model’s transformations before export.

Armatures:
Make sure the Armature object isn’t named “Armature”.
naming or leaving the Blender skeleton named “Armature” will cause the UE4 importer to fail due to “multiple roots”.
* Also remember some weird related bug with animation scale incorrectly imported, but can’t confirm this now..
No need for a dedicated root bone in the hierarchy. the Armature object is the root of the bone hierarchy.
* See export option below

Texture baking:
Set the normal map’s green channel to -Y.
* This is not critical at all because if baked as +Y it can easily be fixed in UE4.

Metadata:
Blender custom properties import as UE4 asset metadata that can be read by editor scripts for automation purposes.
* See export option below


FBX Blender export and UE4 import settings:

I recommend saving an FBX export preset with these settings.

Optional:
I prefer the export settings to include only selected objects.
* It’s more efficient for me to select the specifics objects I want to export into a single FBX file prior to export, than to delete all the temp / reference / draft objects from the scene.
If you want to export Blender custom properties with to the FBX check the “Custom Properties” option

Axes:
Blender’s native model/world orientation is model’s forward facing the -Y axis, left side facing +X and of-course up facing +Z.
UE4’s native model/world orientation is model’s forward facing the +X axis, left side facing -Y and up facing +Z.
There are axis settings in Blender’s FBX export module, that theoretically, should be set like this:

However, in tests I did, The axis settings made no difference when importing to UE4, even when setting intentionally incorrect upside-down axes.
Maybe the FBX exporter writes these settings to metadata that the UE4 importer doesn’t read..
From my experience, what’s important is to orient the model correctly in Blender (see above), apply the transformations,
And in the UE4 import menu, check the “Force Front XAxis” option:

Geometry:
Make sure either “Edge” or “Face” is chosen in the “Smoothing” option to import the mesh’s smooth shading correctly ans avoid a smoothing groups warning on import:

Optional:
Depending on how much control you need over the mesh’s tangent space,
You may want to check the “Tangent Space” export option,
This will make Blender export the full tangent space to the FBX and make UE4 read it from FBX instead of generate it automatically.
* For this option to be supported, the mesh geometry must have only triangle or quad polys.
In the UE4 import settings, choose the “Import Normals and Tangents” option in “Normal Import Method”:

Armature:
Set “Armature FBXNode Type” to “Root”.
Uncheck the “Add Leaf Bones” option to avoid adding unneeded end bones.
Set bones primary axis as X, and secondary axis as -Z.

Animation:
Uncheck “All Actions” to avoid exporting actions that don’t actually belong to the skeleton.
* Un-related animations in the FBX can also corrupt the character rest pose in UE.
The “NLA Strips” option is useful for exporting a library of animations with the skeleton.
* In Blender’s NLA editor, activate the actions you want exported to the FBX.


Related:
3ds max & V-Ray to UE4 Datasmith workflow

Blender – Adding a texture to an Area Light

Software:
Blender 2.82

Adding a texture to an area light can make it produce softer and more detailed highlights and an overall more organic lighting effect.

Note:
Since an Area light in Blender isn’t rendered as an actual mesh object with UV coordinates, it’s texture coordinates are parametric (see below).

Adding a texture to an Area Light:

  1. In the Area Light properties click the Use Nodes button (see image A) to initiate its node graph and allow texturing it.
  2. In the Shader Editor view (with the light selected), drop your texture to the light’s node graph and connect it to the light’s Emission node’s Color input. (see image B)
  3. Create a new Input > Geometry node, and connect it’s Parametric output to the Image Texture’s Vector input. (see image B)

A. Without a texture the Area light produces a hard flat highlight:
a

B. With the vignette texture, the Area light now has a more subtle organic effect:
* The Emission node’s Strength was increased in this case to compensate for the lower light output with the texture.
b
Related posts:

  1. Cycles Area Light pleasent surprise
  2. Cycles Area Light shader visibility

Blender – Basic time-dependent animation driver examples

Software:
Blender 2.82

To setup a time-dependent Driver in Blender, simply use the built-in frame variable.
In this example the expression:

sin(frame)

Set as a Z axis location driver for the cube causes it to oscillate up and down:

frame_driver

Changing the expression to:

sin( frame * 0.1 ) * 2

Causes the motion to be twice as high and 10X slower:

frame_driver2

 

In this example, the expression:

( pow( -1 ,  floor( frame / 30 ) )  *  0.5 ) + 0.5

Set to the cube’s Emission shader’s Strength attribute causes it to alternate between values of 0 and 1 every second (30 frames in this case):

frame_driver3

 

Related:
Blender – Create constraints quickly

Python for Blender – Batch renaming objects

Software:
Blender 2.8 | Python 3.7

Some useful short Python snippets for batch re-naming objects in Blender:

  1. Remove last 4 characters from selected object names:
    import bpy
    objects = bpy.context.selected_objects
    for o in objects:
        o.name = o.name[:-4]

    Annotation 2020-04-23 202028

  2. Rename all selected objects to a set base name followed by a 3 digit numeric suffix:
    import bpy
    objects = bpy.context.selected_objects
    for (i,o) in enumerate(objects):
         o.name = "some_base_name_{:03d}".format(i)

    Annotation 2020-04-23 202718

  3. Prefix all selected objects name with their Blender data type like renaming “SomeModel” to “MESH_SomeModel” or for example:
    import bpy
    objects = bpy.context.selected_objects
    for (i,o) in enumerate(objects):
         o.name = "{}_{}".format(o.type,o.name)

    Annotation 2020-04-23 203345

 

* note that when copying and pasting a script from this example, the indentation may not be pasted correctly.

Note:
Blender 2.8 has a robust batch renaming utility that is invoked by pressing Ctrl + F2 so we don’t have to write scripts to do batch renaming of objects:

Annotation 2020-04-24 174503


Related:

Python for Blender – Accessing Mesh Triangles

Understanding Transparency Render Settings

In theory, all clear* refractive surfaces should have their shadow calculated using a refractive caustics calculation in-order to render the refractive lensing** effect correctly, have their transparency color calculated as volumetric absorption of light through the medium in-order to render the color correctly for areas of different thickness, and have not only external reflections, but also internal reflections calculated, in-order to render the interaction between light and the transparent body correctly.
However, for thin surfaces of even thickness, like window glazing and car windshields, these optical effects can be rendered in much cheaper (non physical) methods, with very little compromise on final image quality or look, and even have an easier setup in most cases.
For this reason most popular render engines have object (mesh) and material (shader) parameters that allow configuration of the way these transparency effects will be rendered.
In this short article we’ll cover the different methods for rendering transparency effects, the reasoning behind them and the way to configure these settings in different render-engines.

In the comparison images below (rendered with Cycles), the images on the left were rendered with physically correct glass settings, 8192 samples + denoising,
And the images on the right were rendered with “flat” transparency settings and 1024 samples + denoising.
> See the shader settings below
Note that while for the monkey statue, the fast flat transparency settings produce an unrealistic result, the window glazing model loses very little of its look with the flat fast settings:

Transparency_Settings

Lensing, caustics and transparent shadows:

3D-Rendering-of-glassware

It’s a common intuitive mistake, that transparent objects don’t cast shadows, but they actually do. they don’t block light, they change its direction. light is refracted through them, gets focused in some areas of their surroundings (caustics) but can’t pass through them directly, so a shadow is created.
A good example of this would be a glass ball, acting like a lens, focusing the light into a tiny area, and otherwise having a regular elliptical shadow. if we tell the render-engine to just let direct light pass through the object we won’t get a correct realistic result, even if the light gets colored by the object’s transparency color.
There is however one case where letting the direct light simply pass through the object can both look correct and save a lot of calculations, and that is when the object is a thin surface with consistent thickness like window glazing.
So in many popular render-engines, when rendering an irregular thick solid transparent body like a glass statue or a glass filled with liquid, we have to counter-intuitively set the object or material to be opaque for direct light and let the indirect refracted light (caustics) create the correct lensing effect (focused light patterns in the shadow area)
> physically, light passing through a material medium is always refracted, i.e. indirect light. but for thin surfaces with even thickness like glazing, the lensing effect is insignificant, and can be completely disregarded by letting light pass directly through the object and be rendered as ‘transparent shadow’.
So the general rule regarding calculating caustics (lensing) vs casting transparent shadows (non physical), is that if the transparent object is a solid irregular shape with varying thickness like a statue or a bottle of liquid it should be rendered as opaque for direct light but with fully calculated caustics i.e. refracted indirect light.

Transparency color:

Cola_Test_ODED_ERELL_3D_Crop_signed

Physically, the color of transparency*** is always created by volumetric absorption of light traveling within the material medium. as light travels further through a material, more and more of it’s energy gets absorbed in the medium**** (converted to heat), therefore the thicker the object, less light will reach its other side, and it will appear darker. this volumetric absorption of light isn’t consistent for all wave lengths (colors) of light so the object appears to have a color.
For example, common glass, absorbs the red and blue light at a higher rate than green light, and therefore objects seen through it will appear greenish. when we look at the thin side of a common glazing surface we see a darker green color because we see light that has traveled through more glass (through a thicker volume of glass) because of refraction bending the light into the length of the surface. tea, in a glass, generally looks dark orange-brown, but if spilled on the floor it will ‘lose’ its color, and look clear like water because spilled on the floor, it’s too thin to absorb a significant amount of light and appear to have a color.
Most render engines allow setting the transparency (“refraction”/”transmission”) color of the material both as a ‘flat’ non physical filter color, and as a physical RGB light absorption rate (sometimes referred to as ‘fog’ color), that can in some cases be more accurately tuned by additional multiplier or depth parameters.
Setting an object’s transparency color using physical absorption (fog) usually requires more tweaking because in this method, the final rendered color is dependent not only on the color we set at the material/shader, but also on the model’s actual real world thickness.*****
In general, the transparency color of thick, solid, irregularly shaped objects (with varying thickness) must be set as a physical absorption rate color, and not as a simple filter color, otherwise the resulting color will not be affected by the material thickness, and look wrong.
For thin surfaces with consistent thickness, like window glazing, however, it’s more efficient to setup the transparency color as a ‘flat’ filter color, because it’s more convenient and predictable to setup, and produced a correct looking result.
For example, if we need to render an Architectural glazing surface that will filter exactly 50 percent of the light passing through it, it’s much simpler to set it up using a simple 50% grey transparency filter color, because this method disregards the glass model’s thickness. This approach isn’t physical, but for an evenly thick glazing surface, the result has no apparent difference from a physical volumetric absorption approach to the same task.

Internal reflections:

Diamond-close-up-inspection

It’s not intuitive to think that the air surface itself has reflections when seen through a transparent material volume like water or glass.
Viewed from under water, the air surface above, acts like a mirror for certain angles, reflecting objects that are under water. a glass ball lit by a lamp has a very distinct highlight, which is the reflected image of the light source itself (specular reflection), but it also has an internal highlight appearing on inside where the glass volume meets the air volume. we can easily ‘miss’ this internal highlight because in many cases it’s appearance converges with the bright focused light behind the ball, caused lensing (refractive caustics). the distinctly shiny appearance of diamonds, for example, is very much dependent on bright internal reflections, diamond cutting patterns are specifically designed to reflect a large percentage of light back to the viewer and look shiny, and if we wish to create a realistic rendering of diamonds, we will not only have to setup the correct refractive index for the material, but also model the geometric shape of the diamond correctly, and of course, set the material to render both external (“regular”******) reflections and internal reflections.
Your probably already guessing what I’m about to say next..
For thin surfaces with even thickness, the internal reflection is barely noticeable, because it converges with the main surface reflection, an for this reason, when rendering window glazing, car windshields, and the like, we can usually turn the internal reflections calculation off to save render time.

Underwater_31.12.18

Render Settings:

Simplified settings summary table:

Flat (Glazing) Physical (irregular volume)
Shadow Transparent Caustics
Color Filter Volumetric Absorption
Reflections External only External and Internal

Example Cycles (Blender) shaders:
> The Flat glazing shader is actually more complex to define since it involves defining different types of calculations per different type of rays being traced (cheating).
In general, for Shadow and Diffuse rays that shader is calculated as a simple Transparent shader and nor a refraction shader, and when back-facing, the shader is calculated as pure white transparent instead of glossy to remove the internal reflections.
> While the flat glazing shader is only connected to the Surface input of the material output, the physical glass shader has also a Volume Absorption BSDf node connected to the Volume input of the material output node.
> Note that a simple Principled BSDF material will have flat transparency and physical shadow (caustics) by default.
> For caustics to be calculated, the Refractive Caustics option has to be enabled in the Light Path > Caustics settings in the Cycles render settings.

Cycles

Example V-Ray Next for 3ds max material settings:
>
In V-Ray for 3ds max (and Maya) the Affect Shadows parameter in the VrayMtl Refraction settings determines weather the shadows will be fake transparent shadows suitable for glazing or (on) or opaque (off) which is the suitable setting for caustics.
> The caustics calculation is either GI Caustics which is activated by default in the main GI settings or a dedicated Caustics calculation that can be activated, also in the GI settings.
> For flat glazing the color is defined as Refraction Color and for physical glass the Refraction color is pure white and the glass color is set as Fog color.

V-Ray_Glass

Example Arnold for Maya settings:
> In Arnold 5 for Maya the Opaque setting in the shape node Arnold attributes must be unchecked for transparent shadows, and checked for opaque shadows suitable for caustics.
> For rendering refractive caustics in Arnold for Maya more settings are needed.
> When the Transmission Depth attribute is set to 0 the Transmission Color will be rendered as flat filter color, and when the Transmission Depth attribute is a value higher than 0 the transparency color will be calculated as volumetric absorption reaching the Transmission Color at the specified depth.

ArnoldMaya

General notes:

> in Brute Force Path Tracers like Cycles and Arnold the Caustics calculation is actually a Diffuse indirect light path. this seems un-intuitive, but the light pattern appearing on a table surface in the shadow of a transparent glass is actually part of the table surface’s diffuse reflection phenomenon.

> what we refer to as ‘Diffuse Color’ in dielectric (non-metals) is actually a simplification of absorption of light scattered inside the object volume (SSS).

* Optically all dielectric materials (non-metals) are refractive, but not all of them are also clear, the is, most of them actually have micro particles or structures within their volume, that scatter and absorb light that travels through them, creating the effects we’re used to refer to as “Subsurface Scattering” (SSS) and in the higher densities “Diffuse reflection”.

** Lensing is a term used to describe the effect of a material medium bending light, focusing and dispersing it, and so acting as a lens.

*** Actually all color in dielectric (non metallic) materials is created by Volumetric Absorption.

**** Light isn’t only absorbed as it travels through medium, it’s also scattered.

***** Volumetric shading effects usually use the model original scale (the true mesh scale), so to avoid unexpected results it’s best that the object’s transform scale will be 1.0 (or 100% depending on program annotation)

Related Posts:
>
Cycles Nested Transparencies
>
Arnold for Maya Refractive Caustics
> Arnold for Maya Transmission Scattering
> Understanding Fresnel Reflections
> Advanced Architectural Glazing shader for Blender
> V-Ray Underwater Rendering

Blender – Copy Bone Constraints

Software:
Blender 2.83

To copy bone constraints from one bone to other bones:

  1. In Blender Preferences > Add-ons:
    Find the Interface: Copy Attributes Menu add-on, and enable it.
    Annotation 2019-12-12 165824
  2. In Armature Pose Mode,
    Select one or more bones, and select last the bone that has the constraints you want to copy.
  3. Press Ctrl + C to open the Copy Attributes menu, and select Copy Bone Constraints.

copyconstraints


Related post:

Quickly setup bone constraints

Advanced Procedural Wood for Blender & Cycles

Software:
Blender 2.8 | Cycles

CG-Lion Wood Presets Pack 1.0 is an advanced 3D procedural wood shader I developed for Blender and the Cycles render engine that produces consistent wood pattern on all sides of the model without requiring UV coordinates.
The shader has many tweak-able parameters for easy customization of the wood pattern, and also has built-in varnish coat and paint layers.
CG-Lion Wood Presets Pack 1.0 ships with a ready-to-use material preset library.

CG-Lion Wood Presets Pack 1.0 is available on Blender Market:
https://blendermarket.com/products/cg-lion-wood-presets-pack-1

CGL_Wood_Presets_Pack_1.0_Node_B.jpg

This slideshow requires JavaScript.

CGL_Wood_Presets_Pack_1.0_Previews_Natural

CGL_Wood_Presets_Pack_1.0_Previews_Matte_Varnished

CGL_Wood_Presets_Pack_1.0_Previews_Varnished

Related:
Realistic Spotlights for Blender & Cycles
Optimized Architectural Glazing Shader for Cycles
Customizable Photo-realistic Car-paint shader for Cycles

 

Customizable Photo-realistic Car-paint shader for Cycles

Software:
Blender 2.8 | Cycles Render

CGL Car Paint Presets Pack 1.0 is a highly customizable photo-realistic car-paint shader I developed for Blender & the Cycles render engine.
The shader has built-in realistic effects like color blending, metallic flakes, clear-coat etc.
And ships with 32 ready-to-use real world car paint material presets.

CGL Car Paint Presets Pack 1.0 is available on Blender Market:
https://www.blendermarket.com/products/cg-lion-car-paint-presets-pack-1

CGL_CarPaint.jpg

CGL_Cycles_Car_Paint_Presets_Pack_1.0_No_Numbers

This slideshow requires JavaScript.

Related posts:
Realistic Spotlights for Blender & Cycles
Complex Fresnel texture for Cycles
Optimized Architectural Glazing Shader for Cycles
Procedural Wood Shader for Cycles

Blender – Bake rigid body physics to Keyframes

Software:
Blender 2.82

  • I always forget this, try to do it through the regular animation baking option and get frustrated that it doesn’t work…

When you want to bake an object’s Rigid Body physics simulation to regular Keyframes:

  1. Select the wanted objects.
  2. Press F3 to open the command search floater,
    Begin typing: bake to keyframes to Locate the command:
    Rigid Body: Bake To Keyframes and select it.
    Note:
    The command will appear only if objects with rigid body physics properties are selected.
    Annotation 2020-05-17 154351
  3. Set a frame range for the bake and press OK:
    Annotation 2020-05-17 154413
  4. The physically simulated motion is recorded to keyframes:
  5. Annotation 2020-05-17 154458

 

Related:

  1. Bake NLA animation
  2. Cloth to shape keys