CesiumGS / cesium-unity

Bringing the 3D geospatial ecosystem to Unity
https://cesium.com/platform/cesium-for-unity/
Apache License 2.0
358 stars 83 forks source link

Support double-sided materials #370

Closed j9liu closed 2 months ago

j9liu commented 1 year ago

As reported on the forum. We don't support double-sided glTF materials, but marking a Unity material double-sided doesn't seem to be easy from script. I'm copy pasting my thoughts from the community forum:

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.