Tuesday, November 25, 2014

[UE4 Quick Tip] Increase Tessellation Limit

By default UE4 limits the tessellation factor to 8. This has been done for performance reasons since certain GPUs struggle a lot with high amounts of subdivision and owning an old AMD DX11 graphics card myself I can completely see where they are coming from.
If you want to increase the tessellation factor anyway take a look at these shader files

\Unreal Engine\4.x\Engine\Shaders\Tessellation.usf
\Unreal Engine\4.x\Engine\Shaders\PNTriangles.usf

and search for  the 'MaxTessFactor' variable.

//@todo: This should be vectorized and done in the MainHull shader.
float4 CompositeTessellationFactors = TessellationMultipliers * CalculateCompositeTessellationFactors(WorldPostion0,WorldPostion1,WorldPostion2);

// Limit the tessellation factor to <= 8. The multiplies and saturates handle any potential NANs/INFs in CompositeTessellationFactors.
float4 MaxTessFactor = 8.0f;
float4 InvMaxTessFactor = 1.0f / MaxTessFactor;
       
// clamp at 1 to prevent triangle to disappear with
CompositeTessellationFactors = max(1, MaxTessFactor * saturate(CompositeTessellationFactors * InvMaxTessFactor));

Changing this value will cause a full (material) shader recompilation so it'll take some time when you open the editor the first time.

No comments:

Post a Comment