UE4 – Quick fix for normal map encoding

Software:
Unreal Engine 4.25 | Photoshop 2020

Quick UE normal map tip:
If you load a normal map into a UE material and the result appears inverted, i.e. holes instead of bumps or the other way:

The quick fix:

  1. In the texture settings, check the Flip Green Channel option and save it:

Annotation 2020-09-06 160838

The deep fix:
* This can be performed an automated action on multiple files

  1. Open the normal map in Photoshop
  2. In the Channels panel, select the Green channel
  3. Press Ctrl + I,
    Or Select Image > Adjustments > Invert
    To invert the green channel.
  4. Save the texture and reload into Unreal Engine.
    Annotation 2020-07-06 233156

Inverted normal map:Annotation 2020-07-06 232554

Fixed normal map:Annotation 2020-07-06 233036

Related:
UE4 Bump map
UE4 – Procedural Bump Normals

UE4 – Basic Material Blending

Software:
Unreal Engine 4.24

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:
Annotation 2019-12-25 232734

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:
annotation-2019-12-26-015532.jpg

> 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)
Annotation 2019-12-26 015717

> 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:
matatts

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:
Annotation 2019-12-26 021435

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.

> Learn how to create Material Functions

The Material Function defining the mud material:
Annotation 2019-12-26 024834.jpg

The Material Function defining the mud-leaves material:
Annotation 2019-12-26 024906.jpg

The Blend material using the Material Function nodes:
Annotation 2019-12-26 025111

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 RemapValueRange node can be used to force a color threshold on the mask texture or value.

Related:
Material Functions
Material Instances
Texture Painting

UE4 – RemapValueRange Node

Software:
Unreal Engine 4.24

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:

  1. Input: The input value
  2. Input Low: Input mapping range minimum
  3. Input High: Input mapping range maximum
  4. Target Low: Output range minimum
  5. Target Height: Output range maximum

Mono Noise examples:

  1. The original noise pattern:0
  2. Mapping input 0 -> 1 to output 0 -> 1 obviously has no effect:1
  3. Mapping input 0 -> 1 to output 0.3 -> 0.7 reduces the pattern contrast:2
  4. Mapping input 0.3 -> 0.7 to output 0 -> 1 increases the pattern contrast:3
  5. Mapping input 0 -> 1 to output 1 -> 0 inverts the pattern:4

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:5

After the value remapping tha value in each channel 0.1 -> 0.9 to 0.0 to 1.0:6

The same operation performed by multiplication by 1.2 and subtracting 0.1:7.jpg

Optimized Architectural Glazing for Blender & Cycles

Software:
Blender 2.8 | Cycles Renderer

CG-Lion Architectural Glazing Presets Pack 1.0 is an custom architectural glazing shader I developed for Cycles render engine, that provides easy setup of real world architectural glazing surfaces, and ships with 40 ready to use material presets.

The shader has architecture-friendly real world parameters like ‘frosted‘, ‘milky‘, ‘smoked‘ glass etc., has convenient built-in inputs for effects like selective sand blasting or selective graphic coating and is internally optimized for transparent shadow casting.

CG-Lion Architectural Glazing Presets Pack 1.0 is available for purchase on Blender Market.

 

Related:
Realistic Spotlights for Blender & Cycles
Customizable Photo-realistic Car-paint shader for Cycles
Procedural Wood Shader for Cycles

UE4 – Bump Map

Software:
Unreal Engine 4.21

To use a ‘Bump Texture’ in UE4, or in more geeky terms, derive Normal data from a supplied height map, use the NormalFromHeightMap Node.

Notes:

  1. The height map textured is supplied via Texture Object node and not Texture Sample, and is connected to the NormalFromHeightMap‘s Height Map input.
  2. A numeric vale is connected to the NormalFromHeightMap‘s Normal Map Intensity input to control the intensity of the resulting Normals/Bump.
  3. UV coordinates for the bump map should be connected to the Coordinates input of the NormalFromHeightMap node.

bump

Related:
UE4 – Procedural Bump Normals
UE4 – fix an inverted normal map
UE4 – Triplanar mapping

VRayMtl’s new metallic goodness

Software:
3ds max 2019 | V-Ray Next | V-Ray next GPU

In V-Ray Next (4) for 3ds max, a new Metalness parameter has been added to the Reflect parameters of the VRayMtl material.
This allows for easy creation of realistic metal materials and also effectively enables a PBR workflow with V-Ray.

When the Metalness parameter is set to 1.0, the material becomes completely reflective, the Diffuse color controls the general reflection color, and the Reflect color (which should generally be set to white) controls the reflection color at grazing incidence angle.

The IOR parameter still controls how fast will the main reflection color (set by the Diffuse color) blend into the Reflection color, and I don’t know whether some form of complex Fresnel has been implemented or if it’s just a dielectric simple Fresnel blended over a reflective surface.

An excellent article on the new Feature from the Chaos Group blog:
https://www.chaosgroup.com/blog/understanding-metalness

VRay_Next_Metalness

Related:

  1. Fresnel Reflections
  2. Complex Fresnel for Blender & Cycles
  3. Metal material in UE4

 

UE4 – Material Fresnel Node

Software:
Unreal Engine 4.18

The UE4 Fresnel node is actually a “Facing Ratio” node (aka Perpendicular / Parallel) with some extra control.
It basically allows controlling material effects according to the incident angle the surface is viewed at, which is a hugely important feature for designing advanced material effects.

Untitled-3

Exponent:
The steepness of the value / angle curve.

Base Reflect Fraction:
The value at perpendicular angle.

Normal:
An option to connect World Space surface normals input to affect the output of the Fresnel node.
* Tangent Space normals must be converted to World Space by using a Transform Vector node.

Note:
A value of 1.0 for the Exponent parameter, and a value of 0.0 for the Base Reflect Fraction will produce a linear “Facing Ratio” (“Perpendicular / Parallel”) falloff blend.

Examples of different values:
Untitled-3
Untitled-4

More info:
https://docs.unrealengine.com/latest/INT/Engine/Rendering/Materials/HowTo/Fresnel/

Related posts:

  1. UE4 – basic architectural glazing material
  2. Understanding Fresnel reflections

Basic architectural glazing material in UE4

Software:
Unreal Engine 4.18

  1. Create a new material, and double click it to edit it.
  2. In the Details panel, under Material, set Blend Mode to Translucent.
  3. In the Details panel, under Translucency, set Lighting Mode to Surface Translucency Volume.
  4. Set Base Color to White.
  5. Set Metallic to 1.
  6. Set Roughness to 0.
  7. Create a Fresnel node and connect it to the Opacity input.
  8. In the Fresnel node, set Base Reflect Fraction to control reflection amount in perpendicular surface viewing angle (front).
    * Note that its connected to Opacity, but since the material is basically a flat mirror, when it’s not purely transparent it will be reflective.
  9. In the Fresnel node, set Exponent to control the reflection amount falloff curve from perpendicular surface viewing angle (front) to parallel surface viewing angle (sides).
    * Higher values will create a steep falloff curve, resulting in less reflection in most viewing angles.

Untitled-3

 

Related:

  1. 3ds max & V-Ray to UE4 Datasmith workflow
  2. UE4 – Material Fresnel Node
  3. Understanding Fresnel Reflections

Material Parameters and Instances in UE4

Software:
Unreal Engine 4.18

Material Parameters and Material instances allow you to create a customizable material template that can be easily reused with variations across the project.
In the Parent Material, you define the parameters that will be exposed for tweaking in the Material Instances.
Changing the Parent Material will affect all its instances.

Defining customizable parameters in the Parent Material:

  1. Create 3Vector Constant. (press 3 and left click the blueprint background)
    * Parameters can also be created with other types of data like a Constant or a Texture Sample and more.
  2. Right click the 3Vector node you created and choose Convert to Parameter.
  3. In the Details Panel, name the parameter.

Untitled-1

Untitled-2

 

Creating the Material Instance:

  1. Right click the Parent Material and choose Create Material Instance.
  2. Name the Material Instance.
  3. Double click the Material Instance to edit it.
  4. In the Details panel, under Parameter Groups you will be able to edit the exposed parameters and create a variation of the material.

Untitled-1

Untitled-2

 

Related:
Material Functions
Blending Materials

Vector Parameters in the UE4 Material Blueprint

Software:
Unreal Engine 4.18

UE4 Material Blueprint Numerical Vector Parameters / Constants and Colors are one and the same, which makes perfects sense, since in computer graphics colors are in fact 3D vectors, RGB quantities being equivalent to XYZ spatial dimensions (4D with an Alpha channel)

But take note that when setting the Vector values in the color picker you can’t set negative values, and when doing so through the Details window in Default Value you can.

* You can create 3D Vector Constants by clicking the background while pressing 3

Untitled-2.jpg