Pages

Tuesday, March 25, 2014

[Unreal Engine 4] Tangent Spaces Test

A quick test on synced tangents in UE4. I've been using Handplane to generate TS normals from a given low poly mesh and object space normal map.
The test mesh has no hard edges / one smoothing group with several 90° angles so there are plenty of strong gradients in the normal map.






Max preset


Maya preset


Unreal Engine 3 preset



Blender / Mikktspace

Sunday, March 23, 2014

[Unreal Engine 4] Post Processing

Post processing in UE4 is probably going to be very interesting. I haven't done any serious testing for now but having access the whole G-Buffer offers a wide range of opportunities.


Here's a quick example of a fairly simply edge detect / outline shader, no sobel kernel.

Depth Only


Normals Only


Depth + Normals combined

Friday, March 21, 2014

[UE4] Manual Distance Based Tessellation

When using a material with tessellation in unreal engine 4, adaptive tessellation is enabled by default. Whilst this screen-space algorithm is doing a solid job there are situations where you might want to manually set the tessellation factor directly or make it de/increase in intervals rather than constantly changing. 

To make the following materials work you'll need to uncheck 'Enable Adaptive Tessellation' in the material properties.



This is the most simple setup, using 3 parameters - 2 tessellation factors (one for when far away and one for close up) plus the distance in world space.




For a smooth transition between both states divide the distance by an additional parameter, this one is also in world space units:





For a more subtle transition you can scale the amount of displacement by distance as well. Therefore calculate the inverse of the lerp alpha input and multiply that by your World Displacement input.





In case you need more than 2 states of tessellation you can simply add an additional Lerp.


[UE4 Quick Tip] DXT1/DXT5 Normal Maps

By default Unreal Engine 4 uses BC5 compression for normal maps which offers a high level of quality. In case you are fine with some lower quality normals (aka blocky artifacts) you can still use DXT1 compression and therefore save half of the texture memory and 4 shader instructions per material.
Using regular DXT1/DXT5 compression for normal maps also makes it possible to use the blue/alpha channel for storing an additional greyscale texture, e.g. height/displacement maps.


What to do:
1. In the texture properties change the compression setting from TC_NormalMap to TC_Default.
2. In the material, convert your normals from [0...1] to [-1...1] range.