CFTD [4] HDRP

CFTD [4] HDRP
Production-Grade, P****erformant Crack-Free Tessellation Displacement Shader for Unity 's HDRP


The only crack-free tessellation displacement solution for Unity’s HDRP (as of mid 2020)

Asset Store Link

CFTD [4] HDRP is here. Again, re-written from the ground up!

CFTD 4.0 HDRP (Jun 2020)

  • CFTD supports HDPR 7.3.1 +
  • Lit Variant support only.
  • Tested on DirectX 11 / 12.

CFTD
Crack-Free Tessellation Displacement for the Unity Standard Rendering Path

The only crack-free tessellation displacement solution for Unity. Current version: 2.2

Asset Store Link
Documentation (Standard RP)
Demo Scene (Outdated, Demo Scene was made with CFTD 1.x)

NEW VERSION: CFTD 2.0 has been re-written from the ground up!

New in CFTD 2.2 (Jun 2020)

  • CFTD now supports Vulkan.
  • Improved mesh swimming reduction (displacement miplod).
  • Better support for baked displacement maps.

New in CFTD 2.1 (Jul 2018):

  • OpenGL 4.5 support (the shader might possibly support other platforms as well, such as GLES 3 in Unity 2018); Please note, only OpenGL 4.5 on Windows has been tested.
  • Further performance improvements.

New in CFTD 2.0:

  • Supports PN-AEN Tessellation (adds geometric detail and smooths meshes, while persevering hard edges).
  • Supports GPU Instancing (helps with reducing batches).
  • Full support for Unity’s PBR workflow.
  • Better shader performance.
  • AAA, industry-grade reduction of adaptive tessellation artifacts (an issue known as ‘mesh swimming’).

What exactly is CFTD?
Crack-Free Tessellation Displacement (CFTD) is a set of tessellation shaders designed to patch ‘cracks’ that occur when displacement is applied to a model with UV discontinuities. I.e., if your model’s texture does not tile perfectly, this will result in displacement cracks on the edges where the tiling breaks. That’s because the displacement values at the neighboring texels would be different. Fixing this issue requires extra calculations and an extra buffer to store all the data. Luckily, CFTD does exactly that.

Limitations:

  • CFTD does not support skinned meshes(you can apply the shader, but it will not be crack-free).
  • DirectX 11 /12 PC, OpenGl, Vulkan tested only (Metal has not been tested).
  • Cracks are gone at runtime only.
  • No static / dynamic batching.
  • Tessellation is a somewhat slow technique.

Features and generally good stuff:

  • Unity’s first (and only) crack-free tessellation shader. Patches edges at UV discontinuities.
  • Smooths normals on the edges between smoothing groups (hard edges) in a very neat and unique way (Distance Based).
  • FOV-dependent (Edge Length). I.e. supports camera zooming-in.
  • Shadow caster LOD (as of 2.0 in Deferred Rendering only). You can optimize tessellation on the real time shadow caster.
  • Works with your existing assets.
  • Casts and receives full shadows & Supports Unity’s GI…
  • CFTD includes a static subdivider to imrpove tesselation on very low-poly meshes.

CFTD comes in tow variants (each with or without PN_AEN): Edge Length & Distance Based.

Distance Based:

  • Smooth fading of tessellation and displacement with distance. No popping and strange stuff when far, looks good up close.
  • Smooths normals on the patched edges. This feature is pretty unique. Haven’t seen any other shader do that, even in UE4.


Edge Length (notice the hard edges) / Distance Based (smooth between different smoothing groups)

Edge Length:

  • Tessellate tris based on desired pixel size. Improves “mesh swimming”.
  • Uses its own tessellator. While the technique is close to Unity’s own, it’s a bit faster and incorporates the tessellation culling that the original Unity Edge Length tessellator did not.
  • FOV - dependent: When you zoom in with the camera, tessellation is a applied normally.

Here is an example of the FOV dependence of Distance Based. In this example, the camera is way far from the mesh and has a FOV of 3 (almost orthographic projection).


Distance Based (tessellation and displacement are gone!) / Edge Length (all works fine!)

Please leave a rating and/or a review.
Thank you for viewing! :slight_smile:

4 Likes

Roadmap for CFTD [4] HDRP:

  • add support for Vulkan
  • bug fixes
  • support for layered lit (not planned but might be good to have).

Hi, I’ve purchased your package “Crack Free Tassellation Displacement shader”.it works fine on simple meshes, but on complex meshes I can see my texture stretching alot near the UV seams of my mesh and where your script fills the meshe’s cracks, can you help me to fix it?

Indeed on some meshes this may become an issue with the current version of the shader. I’ve already made some improvements on this but it will take a while before the new version is finished. A temoprary fix would be to lower the uv seam stretching in the shader code to something like 0.05 or lower.

Can you please indicate where in the shader code we should modify this seam streching?

Right. Sorry about the delay. In order to do that, you would need to open the .shader in monodevelop or other editor. Then simply replace:

v.texcoord.xy = lerp(dispCoords, v.texcoord.xy, 1.0 - (_Displacement * 0.2));

with

v.texcoord.xy = lerp(dispCoords, v.texcoord.xy, 1.0 - (_Displacement * 0.05));

There are all together 5 occurrences; simply replace all. Currently the shader just linearly interpolates between the uv islands for the diffuse (and normal) maps. If the uv islands are far apart, the interpolation becomes more noticeable. Like I said, I’m working on better solutions than the one currently incorporated. It’s just that this looked good on most situations where it was tested.

looks great! does/can it support a detail map? I use allot of 1:1 scans with a detail pass for fine normal deets.
Thanks

Detail maps are not implemented (although very much possible). Quite frankly though, that’s a really good idea… Didn’t really think of that.

Anyhow, I’m working on a game right now, once it gets done, the CFTD shader would be the first to get some TLC. Detail maps would be good to have; and pretty easy to do.

1 Like

Alright, I think it’s finally time to update this shader. First things first, it needs better stretching on the edges. This is done by some mumbo-jumbo math in the shader itself and it still needs to be tested.

Here are the results:

Obviously, there is still stretching. Unfortunately, and please trust me on this one, there isn’t much to be done on the issue. The shader will not do any magic. Actually, the test assets only show that the shader works as intended, it shouldn’t really be used under such extreme settings.

Finally here is a test of the same brick wall model with flat tessellation & crack free displacement under UE4. It’s somewhat close to the new approach. I’d imagine it would look similar in CE.

Hi. I have tried your free version and like the Phong/Smooth version.
However it does indeed crack at UV seams.

Does this pack offer the equivalent without cracking?
I can’t see phong/smooth listed in the file listing but I’m hoping one of the listed shaders will do it.

Thanks
TL

EDIT: As of CFTD 2.0, it does!

No, CFTD does not currently offer an equivalent.
A crack free smoothing needs PN-AEN tessellation (Point-Normal Triangles using Adjacent Edge Normals); phong still results in cracks. I’m planing on doing it some day, but really, I cannot give any estimates when PN-AEN is coming to CFTD…

@ginconic Hi I just bought your crack free tessellation shader today. I’m using /Unity 5.4 pro The free version displaces fine in the editor but the crack free shader doesn’t even tessellate/displace (I understand the cracks only disappear at runtime. but normal displacement doesn’t work. I tried contacting you on your website but your captcha code doesn’t display an image so I can’t send you a message there. Please include optimal texture settings if different from the free version.

In the paid version (CFTD), displacement texture must be added to the alpha channel of the Albedo (Diffuse) texture. There is no separate input for displacement texture, in order to save tex resources, since displacement is just grayscale.

If, however, the shader is not tessellating (i.e. you change the tessellation settings, but it does not add triangles), that would be a different issue. You can check this by simply selecting an object in order to see the wireframe (if there are more triangles, it is tessellating, but it is not getting the displacement texture properly).

I am afraid I’m on a holiday right now and will be back mid-next week and I would not be fully able to test the issue on my machine and/or rewrite the shader. CFTD is using it’s own tessellator, so there is a chance it might have broken somewhere; especially if you use other custom shaders. For support it’s usually better to straight- use the support email address on the publisher’s assetstore page :slight_smile: The ‘support website’ in our case is just the old 3d scan store we had.

1 Like

@ginconic thanks for the info! I did manage to get it working although I had to add the normal color texture to the secondary Albedo x2 and do some tweeking to get proper color to show through. I’m still working on setting it up with multiple models so I haven’t seen the crackless results yet… I’m sure it will work. Enjoy your holidays! :slight_smile:

Thanks! There is a slider called ‘diffuse burn/ao’ that affects your color quite a bit if turned up. The shader does need some tweaking and time to get used to. Please note cracks close only if you add the crack free cs script to an object.
A current limitation of the shader is that you need to disable batching on objects that need to have cracks closed. The demo scene provides some more info. You can of course combine objects using some free (and paid) scripts, if you have to, but it has been tested with hundreds of separate objects and performs quite decently. GPU instancing 5.4 has not been tested yet, but should it work, that would improve things quite a bit.

So just a quick note: I used the RDT (Real Displacement Textures) from the Allegorithmic’s webstore

Well, I tested it with their free cobble stone sample and it works out of the box. Here are the results:

Now, as far as files, you only the Color, Depth and Normal maps from their assets. Workflow for me was: insert Depth texture as an alpha in the Color map > save as TGA and import in Unity (no tweaks to the texture / advanced stuff) > then import Normal map as a normal map and add them to the material.

As far as CFTD goes, it always works better with detail maps. In fact, it is better to use smaller main maps (i.e. 4k is just an overkill) and use very small, super- tiling detail maps.

CFTD pimps the material based on the Depth map, it does not need Gloss, Spec, Roughness or AO maps; it creates those values automatically based on the slider settings.

I’ve tried the two included materials but whenever I select a different texture there’s no displacement, is there a way to select the displacement map or should textures be prepared for use with the shader? Not sure what’s going wrong, the readme file doesn’t include instructions on how to do this.

The way it works currently, your height (displacement) map needs to be the alpha channel of the albedo (your diffuse map). New version will have a texture combining plugin, among other things, but for now the only way to combine these is manually in an image editing app.

Hi, I bought your asset and am trying it out right now. Is there a way to adjust tesselation so that if a mesh is not a square shape that it wouldn’t tesselate more in the other direction than in the other. The example brick wall you have is nicely squarish shape, but when I try to apply it to a tall block, it looks something like attached. The shorter the distance, the more it tesselates.

Even manual controls for adjusting it x y z would work well enough.