Draw glTF with DoubleSided material?

Hi, I’ve got a 3D Tile with glTF material containing doubleSided=true, in CesiumJS it looks like (https://bertt.github.io/cesium_issues/doublesided/double_sided_true/):

When loading this tileset into Cesium for Unity 1.6.2 (with url https://bertt.github.io/cesium_issues/doublesided/double_sided_true/tileset.json , viewer at 51.9585143,5.6481455) only the eastern part is drawn:

This looks similar as the same model with doubleSided=false (the default) in CesiumJS (https://bertt.github.io/cesium_issues/doublesided/double_sided_false/)

So the question is:How can we draw glTF models with doubleSided = true correctly in Unity3D (like in CesiumJS?).

Hi @bertt,

I think this is something we’d have to investigate further… I can see that there’s a Render Face option with the ability to render both front + back faces in the Material Editor.

But from a glance at Unity’s Material API, there’s no direct setting to control this. It looks like in a custom shader, you could set a Cull flag manually. But we avoid handwriting shaders because the necessary code can differ between the three render pipelines. Shader Graph is ideal for us because it abstracts that away.

Maybe the double-sided behavior can be controlled in Shader Graph by setting some keyword, but I don’t know what that keyword is. In the worst case scenario, it might be possible to simulate double-sided behavior from the material by adding shader graph code to flip the normal if it is facing away from the camera. And then to add a keyword to only enable this if the material is double-sided.

I’ve written this down to a Github issue but since we’re not 100% confident how to go about it, I can’t commit to a solution or give an time estimate for its completion. But if any of the ideas I listed make sense to you, feel free to try them out in your own project!

2 Likes

ok thanks!