How to
Translucency & refraction (PBR)
- Create a translucent, refractive material in UE 5.2
- RMB Content browser > Material
- In details panel
- Material > Blend Mode : Translucent
- Translucency > Lighting Mode : Surface Translucency Volume
- Refraction > Refraction Method : Index Of Refraction
- Then you can use the common texures or paramers to control the material
- Note
- One big gotcha if you want to use a mesh that you apply an emissive material to to emulate a light source and position that behind the refractive material (like if you create a headlight etc) is that the scale of the mesh needs to be set to 1. If the scale is really small and the camera moves to far away from the refractive material Unreal will “cull it” so that the emissive object will no longer be refracted as you would expect.
- Fog/lightshaft artifacts
- I needed to set the Translucency > Advanced > Translucency Pass to Before DOF to get rid of some articats when the refractive material had lightshaft fog in fornt of it
- Tweak the IOR
- I had an issue where the headlight glass did not refract the emitted light the way I artistically wanted, so altough not physically correct but to get the look that I wanted, I lowered the IOR to something like 1.05 or slightly higher.
- Epic docs
PBR
- Base Color
- Real world materials are not darker than 20 srgb or brighter than 240 srgb
- Rough surfaces have a higher minimun, around 50 srgb
- Out of range values will not light correctly, so staying in range is critical
- On a non-metallic material this controls the diffuse
- On a metallic material this controls the specular
- On a metallic material the diffuse is black
- Specular
- A multiplier for the direct and indirect specular lighting
- Defining the reflectivity when looking straight at the surface
- Non-metal surfaces reflects about 4% of the light
- Specular value:
- 0.5 represents 4% reflection
- 1.0 represents 8% reflection (to high for most materials)
- At glancing angles all surfaces are 100 % reflective
- The fresnell term is built into the engine
- Specular maps should mostly be at 0.5
- Only use lower values to mask areas that should not be reflective like crevices
- A crevice map multiplied with 0.5 makes a good specular map.
- Roughness
- Represents the roughness of the surface at a microscopic scale.
- White is rough and black is smooth
- Controls the focus of reflections
- Smooth = tight, sharp reflections
- Rough = blurry, diffuse reflections
- No technical constraints - completely artistic choice
- A roughness map can be used to define the “character” of the surface and show its history
- Metallic
- Switches the shader to metallic mode
- When the metallic is set to 1 (a metallic material)
- Now the base color controls the specular of the material
- Now the specular range is up to 100%
- Most metals are between 60-100% reflective
- Be sure to use real-world measurements for metal “base color”
- Metals have colored reflections
- The values should be around 180 srgb or brighter
- The base color controls the specular
- The specular parameter is ignored (since it is controlled by the base color)
- The diffuse is always black
- Values of either 0 or 1 should be used.
- Values in between should be avoided since that will produce a weird mix of non-metal / metal behaviour
- A few pixles of “inbetween values” where a map transitions from 0 to 1 are ok, but generally the map should be 0 or 1
- Ambient Occlusion
- Only used if we use a baked gloabl illumination solution.
Landscape
- Material Attributes
- on the result node of the material click Details > Material > Use material Attributes : On
Nodes
Math / Misc
- Mask - [math] componentMask
- Selects a specific subset of channels (R, G, B, and/or A)
- Split Components - [Misc] splitComponents
- Can split out components of a vec3. (Can not output alpha vec4)
- Append - [Math] appendVector
- Construct a vector with more channels than the original. You can appen to floats to create a vec2 or one float and a vec2 to cfreate a vec3.
- AppenMany - [Misc] appendMany
- Allows you to append up to 4 scalars in one function
- Swizzle - [Misc] swizzle
- Can rearrange the components of a vector
Textures
- Dropping one resolution step reduces memory 4 times.
- Using 4k textures is very expensive
- Uncompressed textures need to be at a low resolution, otherwise they will require alot of memory.
- Using a alpha channel doubles memory usage, since the alpha channel are stored at a higher quality
- Therefore if you pack channels you should pack the channel that needs the best quality in the alpha.
Compression
- Optimization
- Reduce in game texture size
- texture editor > details tab > compression > advanced
- Set the maximum texture size to the size you want
- Note that a value of 0 will use the original size
- Compress without Alpha
- If your texture has an alpha channel but you do not need it you can make the editor skip the alpha
- This will reduce the size by half
- texture editor > details tab > compression
- enable Compress without alpha
- Reduce in game texture size
Samples
Experiments
Material Functions
MF_UvTransform
Ctrl-C
A material function that is used to transform UVs. Based on Ben Cloward´s work
MF_Hash2to3
Ctrl-C
A material function that generates pseudo random vec3 noise seeded by a vec2. Based on Ben Cloward´s work
MF_UvRandomTransform
Ctrl-C
A material function that generates random UV transform, rotation & scale. Based on Ben Cloward´s work
Requires: ( 2 ) MF_UvTransform, MF_Hash2to3
Requires: ( 2 ) MF_UvTransform, MF_Hash2to3
MF_HexGrid
Ctrl-C
A material function that generates a hex grid that can be used to tile textures without repetition. Based on Ben Cloward´s work. (Note to self, look into the Epic Matrix city demo for a material function called MF_Cellbombing