# How to control Landscape Tessellation with distance?

**URL:** <https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884>\
**Category:** Rendering\
**Tags:** distance, unreal-engine, Landscape, tessellation, UE4, question\
**Created:** [April 13, 2015, 1:20pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884 "2015-04-13T13:20:34Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tireless](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tireless](https://forums.unrealengine.com/u/Tireless)\
**Post date:** [April 13, 2015, 1:20pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/1 "2015-04-13T13:20:34Z")

</div>

Hello,

Is there a way to control the tessellation of a landscape based on distance from camera? I have tried a setup that uses Camera Position and Object Position and shown in this video:

The material setup: http://s1.anyimg.com/img/1bo6qic/DaveTheFreak\_DistanceBasedTesselation.jpg

Unfortunately the landscape is treated as one object and therefore this wont work. Can i use another node that can detect how far each vertex or pixel is from the camera and tessellate based on that distance?

Thanks.

---

<div class="post-metadata">

**Author:** ![Emomilol1213](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emomilol1213](https://forums.unrealengine.com/u/Emomilol1213)\
**Post date:** [April 21, 2015, 9:45pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/2 "2015-04-21T21:45:25Z")

</div>

I´m having the exact problem. I´ve got a huge 4x4km map and want tesselation only near the player. The object position node does not work, let me know if you find something else.

---

<div class="post-metadata">

**Author:** ![Tireless](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tireless](https://forums.unrealengine.com/u/Tireless)\
**Post date:** [April 22, 2015, 4:54pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/3 "2015-04-22T16:54:48Z")

</div>

Hi Emomilol,

I did an experiment that makes me believe this is impossible in UE4. Check out my new thread about this, maybe someone out there knows a way to make it work:

> **[Tessellation "Off" same fps as "On" (Landscape with 0/1 constant)](https://forums.unrealengine.com/questions/216111/tessellation-off-same-fps-as-on-landscape-with-01.html)**
>
> Hello, I am trying to optimize tessellation for my landscape. The idea is to project a white circle at the player/camera position and use that info to tessellate the area close to the player. When I activate Flat Tessellation and put in a constant 0...

---

<div class="post-metadata">

**Author:** ![Emomilol1213](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emomilol1213](https://forums.unrealengine.com/u/Emomilol1213)\
**Post date:** [April 22, 2015, 6:31pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/4 "2015-04-22T18:31:36Z")

</div>

I thought that to, then I found this video

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/4/5/f/45f4c216962f47abdfc05ce1f4b73b4300b299a0.jpeg "Overview | UE4 Adv. Tess. Disp. Landscape Material") ](https://www.youtube.com/watch?v=e9GbZJmP6fE)

It´s a displacement pack on marketplace and there he clearly have depth fade tesselation. I did find somewhere that you should use the “Pixel Depth” node, but I get these errors that the node cant be used in that material.

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [April 22, 2015, 7:04pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/5 "2015-04-22T19:04:03Z")

</div>

try using a material function called “CameraDepthFade”

that has a boolean input called “For Vertex Shader” that should work. it re-creates depth using worldposition data when that box is checked.

---

<div class="post-metadata">

**Author:** ![Emomilol1213](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emomilol1213](https://forums.unrealengine.com/u/Emomilol1213)\
**Post date:** [April 22, 2015, 7:17pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/6 "2015-04-22T19:17:31Z")

</div>

That dont work either, getting “view space is only supported for vertex or pixel shader”. And then the engine crashed ☹

---

<div class="post-metadata">

**Author:** ![Emomilol1213](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Emomilol1213](https://forums.unrealengine.com/u/Emomilol1213)\
**Post date:** [April 22, 2015, 7:22pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/7 "2015-04-22T19:22:18Z")

</div>

![39756-cameradepthfade.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/a/b/5/ab572e108de5d749fed454f33d33db46bc4d73c8.jpeg)

Here you see my setup.

---

<div class="post-metadata">

**Author:** ![Tireless](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tireless](https://forums.unrealengine.com/u/Tireless)\
**Post date:** [April 22, 2015, 7:33pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/8 "2015-04-22T19:33:35Z")

</div>

Awesome that we get some help from you RyanB and good that you are so eager to solve this Emomilol! I’m not sure but maybe it could work if you change object position to absoluteworldposition and plug in two constants into fade length and offset? I will try this out myself tomorrow!

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [April 22, 2015, 7:44pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/9 "2015-04-22T19:44:17Z")

</div>

Ah I forgot that function also does the view transform which straightens out the 3d world distance to be a scene depth (which is a flat distance from the view plane not the camera itself). That part isn’t supported.

Try just this:

 ![39759-scenedepth_for_displacement.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/0/0/8/0085cecade6e9e10784060e6d8cdd18b3052f301.jpeg)

Note that this distance will be “rounded” and not a straight distance to the camera viewplane (aka camera Y axis).

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [April 22, 2015, 7:49pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/10 "2015-04-22T19:49:22Z")

</div>

Also, if you want to make the depth based on the view plane and not cameraposition, you could do the dot product with a CameraX axis that is supplied somewhere in either globalParameters or MID and have your character/camera blueprint supply the vector.

---

<div class="post-metadata">

**Author:** ![Tireless](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tireless](https://forums.unrealengine.com/u/Tireless)\
**Post date:** [April 22, 2015, 8:03pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/11 "2015-04-22T20:03:57Z")

</div>

I tried your setup and got it working with base color (White circle around camera) Though the tessellation don’t care about that input 🙂

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/4/d/54d7f55d1a4b12aeb2360d8d4aefc9a3bb31492b.jpeg) ](https://i.imgur.com/Dd5fDDh.jpg)

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/c/a/6/ca6a42461001ffbbe804f236ebbbf95cfc21e4b4.jpeg) ](https://i.imgur.com/PupqKTW.jpg)

---

<div class="post-metadata">

**Author:** ![Tireless](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tireless](https://forums.unrealengine.com/u/Tireless)\
**Post date:** [April 22, 2015, 8:09pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/12 "2015-04-22T20:09:45Z")

</div>

Aaaaah nevermind got it working! I only had it plugged in to world displacement before.

[![](https://d3kjluh73b9h9o.cloudfront.net/original/4X/f/e/2/fe2f8f2cf253d4c134c5cd3a3477361c46fa6026.jpeg) ](https://i.imgur.com/svWLJSV.jpg)

This is amazing! Thank you RyanB!!!

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [April 22, 2015, 8:16pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/13 "2015-04-22T20:16:32Z")

</div>

Glad it worked out 🙂

You can also mask in addition by certain landscape layers if you want to. Here is a test I did for the GDC kite demo where a tiling rock pile layer was used with displacement and the layer was used to mask tessellation to only where the rocks were:

 ![39765-tess_03_c_32x.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/1/5/1/1518c1a28295e0a23c051e502b1876d346a1de58.jpeg)

 ![39767-wireframe.jpg](https://d3kjluh73b9h9o.cloudfront.net/original/4X/5/5/8/5584bb37afccd058be9dbba2abbd6e1ee39f49ce.jpeg)

The one issue is you sometimes need to “boost” your layer alpha before using it to mask or it can create cracks. I multiplied the layer alpha by 5 or so then clamped to 1 and it worked. The wireframe screenshot kinda sucks (different angle) but you can tell how it sort of meaders to match the rocks. No rock meshes all displacement here.

---

<div class="post-metadata">

**Author:** ![Tireless](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tireless](https://forums.unrealengine.com/u/Tireless)\
**Post date:** [April 22, 2015, 8:17pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/14 "2015-04-22T20:17:34Z")

</div>

Even though I can control the tessellation the FPS is 15 with both very high distance and 0 distance/tessellation… Back at square one 🙂

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [April 22, 2015, 8:19pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/15 "2015-04-22T20:19:58Z")

</div>

Yes there is a fairly high fixed cost to using tessellation on landscape. Still though that sounds puzzling that there is no difference at all. It may be that the shader does almost the same amount of work or something weird.

I will enter a Jira ticket to investigate this further.

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [April 22, 2015, 8:23pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/16 "2015-04-22T20:23:30Z")

</div>

the most recent screenshot you posted showed that the midground area had high enough tessellation to form a solid wireframe. That might mean there are so many verts to process that the tessellation shader is too slow even before tessellating. Can you try changing the LOD distance factor on the landscape and see if any level of detail causes a performance change with tessellation? Jira bug is logged here to investigate this further.

---

<div class="post-metadata">

**Author:** ![Tireless](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tireless](https://forums.unrealengine.com/u/Tireless)\
**Post date:** [April 22, 2015, 8:39pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/17 "2015-04-22T20:39:46Z")

</div>

Wow you worked on the kite demo?! 😮 It is beautiful! I use it as reference and inspiration for my scene 😃

I tried changing to LODfalloff to 10 and Max LODLevel to 5. There are the results:

Fadelength: 5000 Offset: 5000 FPS=21  
Fadelength: 400 Offset: 200 FPS=24

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [April 22, 2015, 8:50pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/18 "2015-04-22T20:50:30Z")

</div>

Ok thanks for the information. That indicates that the setting IS working but the cost is being dwarfed by some fixed cost of simply running the tessellation shader.

FWIW we didn’t end up using tessellation on the landscape for the kite demo. We were already pretty much maxing out with 30million triangle scenes even without any tessellation so we just never got the bandwidth to look into optimizing it fully. I will try to track the issue and keep the pressure on it.

---

<div class="post-metadata">

**Author:** ![RyanB](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@RyanB](https://forums.unrealengine.com/u/RyanB)\
**Post date:** [May 18, 2015, 10:36pm UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/19 "2015-05-18T22:36:30Z")

</div>

(converting answer to comment since it was a comment not an answer)

Here is a promising new idea that I haven’t had time to try yet but will work in 4.8:

you could try using the new landscape grass system to spawn small meshes that are designed to work with tessellation. You could use world aligned textures for them (including displacement) so the meshes could appear to just add detail to the landscape. but you’d be stick with positive displacement (ie no easy way to lower the terrain) and of course no collision support, but tessellation in general has no collision support. This approach should be much faster and should be able to get similar results.

---

<div class="post-metadata">

**Author:** ![Tireless](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@Tireless](https://forums.unrealengine.com/u/Tireless)\
**Post date:** [May 19, 2015, 6:26am UTC](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884/20 "2015-05-19T06:26:30Z")

</div>

Hi Ryan, great to hear from you again!

This sounds good but if I get you right this is a way to use tessellated landscape grass?

[Next page](https://forums.unrealengine.com/t/how-to-control-landscape-tessellation-with-distance/314884.md?page=2)
