# Self generated 3D tileset terrain, winding order problem

**URL:** <https://community.cesium.com/t/self-generated-3d-tileset-terrain-winding-order-problem/37174>\
**Category:** Cesium for Unreal\
**Created:** [December 8, 2024, 2:48pm UTC](https://community.cesium.com/t/self-generated-3d-tileset-terrain-winding-order-problem/37174 "2024-12-08T14:48:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![yunusyurtturk](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/yunusyurtturk/32/27882_2.png) [@yunusyurtturk](https://community.cesium.com/u/yunusyurtturk)\
**Post date:** [December 8, 2024, 2:48pm UTC](https://community.cesium.com/t/self-generated-3d-tileset-terrain-winding-order-problem/37174/1 "2024-12-08T14:48:16Z")

</div>

Hi.  
I have a winding order/doublesided problem for my local custom generated tileset.

I’m generating 3d tiles from heightmaps locally by my pipeline.  
The process is:  
Read height data =\> Generate mesh =\> Optimize with meshoptimizer =\> Output.

If I reduce indices/triangles too aggressively with meshoptimizer, some hole/torn like artifacts appear on the terrain. I realized that the holes appears because winding order is reversed for those triangles, and ChatGPT said it might happen if the mesh is optimized too aggressively.

By accepting this may happen, the problem is I see those reversed triangles as ‘transparent’, not double sided even though my gltf material is set as doublesided.

This is front facing view:

 ![image](https://global.discourse-cdn.com/cesium/original/3X/d/4/d4a36c5609ce21c88f46df6a2e5c5e86339f0b13.jpeg)

This is back facing view:

 ![image](https://global.discourse-cdn.com/cesium/original/3X/4/3/4337af200a5634d81e92560f90b913793abb5e05.jpeg)

The glTF is ‘doublesided’ so I wouldn’t expect this to happen. UV’s may be a problem for texturing but at least I expect to see some shading at there.

Is there a known issue about the problem, either Cesium or UE related? What can I do to mitigate the problem?

UE: 5.2.1  
Cesium for Unreal: 2.10.0

* * *

```auto
"materials": [
    {
      "alphaMode": "MASK",
      "doubleSided": true,
      "extensions": {
        "KHR_materials_unlit": {}
      },
      "pbrMetallicRoughness": {
        "baseColorTexture": {
          "index": 0
        },
        "metallicFactor": 0.0,
        "roughnessFactor": 0.9679999947547913
      }
    }
  ],

```

```auto
"images": [
    {
      "uri": "./top_strip.jpg"
    }
  ],

```

---

<div class="post-metadata">

**Author:** ![Marco13](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/marco13/32/2757_2.png) [@Marco13](https://community.cesium.com/u/Marco13)\
**Post date:** [December 8, 2024, 3:00pm UTC](https://community.cesium.com/t/self-generated-3d-tileset-terrain-winding-order-problem/37174/2 "2024-12-08T15:00:31Z")

</div>

It’s difficult to see the actual topology from the screenshots. It _might_ be helpful if you could share one of the original _and_ optimized GLB files (if they can be shared). But maybe someone from the Cesium For Unreal core team already has an idea about what might be wrong there, and can give hints about possible caveats when it comes to double-sided materials or the winding order.

---

<div class="post-metadata">

**Author:** ![Kevin\_Ring](https://sea2.discourse-cdn.com/cesium/user_avatar/community.cesium.com/kevin_ring/32/2003_2.png) [@Kevin\_Ring](https://community.cesium.com/u/Kevin_Ring)\
**Post date:** [December 12, 2024, 7:32am UTC](https://community.cesium.com/t/self-generated-3d-tileset-terrain-winding-order-problem/37174/3 "2024-12-12T07:32:20Z")

</div>

Hi @yunusyurtturk,  
It’s unfortunately a known problem that doubleSided materials are not currently supported:

> <https://github.com/CesiumGS/cesium-unreal/issues/31>
>
> https://github.com/KhronosGroup/glTF/tree/master/specification/2.0#materialalpha…mode
> Based on a quick look, Unreal Engine does not support toggling between back-face and front-face culling. It does have a "double-sided" property on materials, though, which is currently enabled for \_all\_ materials. We can switch to front-face culling, when necessary, by flipping the order of the indices.

I think the claim in that issue that double-sided rendering is enabled for all materials is no longer true (it’s a very old issue).

We added support for doubleSided in Cesium for Unity a few months back, so that might be a useful reference for someone trying to add it to Unreal as well:

> <https://github.com/CesiumGS/cesium-unity/pull/491>
>
> As reported here:
> https://community.cesium.com/t/3d-tiles-model-appeared-with-f…ace-orientation-flipped-backface-culling/34155
> 
> We previously weren't supporting glTF's \[doubleSided\](https://registry.khronos.org/glTF/specs/2.0/glTF-2.0.html#double-sided) property. Now we are.
> 
> This was tricky because Unity controls this with a render-pipeline-dependent material property. I also had to add some nodes to our CesiumDefaultTilesetShader to flip the direction of the normal for back faces, as required by the glTF spec.
> 
> This is a draft because it's not quite working well in HDRP yet. For reasons I don't understand, HDRP defies all attempts to dynamically turn on double-sided rendering dynamically. I have some local changes where I turn it on via the UI, and then I'm able to turn it \_off\_ dynamically. But I haven't committed that yet because it seems dodgy. Also, unlike the othe render pipelines, HDRP seems to automatically invert normals for back faces, which means my nodes that do that manually are now making the normals wrong again. I'm not sure yet the best way to deal with that.
> 
> Fixes #370
> Fixes #486
