Skip to content

Add Force Double Sided toggle to Cesium3DTileset#695

Draft
triktron wants to merge 1 commit into
CesiumGS:mainfrom
triktron:force-double-sided-toggle
Draft

Add Force Double Sided toggle to Cesium3DTileset#695
triktron wants to merge 1 commit into
CesiumGS:mainfrom
triktron:force-double-sided-toggle

Conversation

@triktron
Copy link
Copy Markdown

@triktron triktron commented May 22, 2026

Description

Adds an opt-in Force Double Sided boolean to Cesium3DTileset. When enabled, every per-primitive material has _DoubleSidedEnable = 1 and _Cull / _CullMode / _BUILTIN_CullMode = Off, applied after the per-primitive glTF material values are written.

This makes it possible to assign a custom Opaque Material with Render Face = Both (URP) or its built-in / HDRP equivalent and have that setting actually stick. Currently, the cull state on every cloned material is overwritten on each tile load from gltfMaterial.doubleSided (see #491 for why that override exists), so user-supplied materials with double-sided rendering silently revert to back-face culling.

Default is false, so the existing glTF-spec-driven behavior introduced in #491 is unchanged for anyone who doesn't opt in.

Where the override is applied (native): outside the existing if (pMaterial) { setGltfMaterialParameterValues(...); } block in UnityPrepareRendererResources.cpp, so it runs after the glTF write and also covers primitives that have no glTF material attached.

How the C# property reaches native code: standard Reinterop wiring — _forceDoubleSided field + forceDoubleSided property on Cesium3DTileset, an exposure line in ConfigureReinterop.cs, and tilesetComponent.forceDoubleSided() at the native call site. No header changes — Reinterop generates the binding.

Issue number or link

No tracking issue — small additive feature. Happy to open one if preferred.

Author checklist

  • I have submitted a Contributor License Agreement (only needed once).
  • I have updated CHANGES.md with a short summary of my change (for user-facing changes).
  • I have added or updated unit tests to ensure consistent code coverage as necessary.
  • I have done a full self-review of my code.
  • I have updated the documentation as necessary.

Testing plan

Manual, in both URP and Built-in (have not yet verified HDRP, where the original #491 had quirks).

  1. Fresh scene, Cesium3DTileset with Opaque Material = None, Force Double Sided = false — default behavior preserved:
    • Tiles whose glTF has doubleSided = false are back-face culled.
    • Tiles whose glTF has doubleSided = true render from both sides.
  2. Same scene, flip Force Double Sided = true — every tile renders both sides. Runtime per-primitive material has _Cull == 0, _CullMode == 0, _DoubleSidedEnable == 1.
  3. Duplicate CesiumDefaultTilesetMaterial, set Render Face = Back so _Cull = 2, assign to Opaque Material, toggle Force Double Sided = true — Cesium still renders double-sided (verifies the toggle wins over the source material as well).
  4. Same custom material, Force Double Sided = false — cull state matches the glTF (original behavior).
  5. Inspector: the new "Force Double Sided" entry appears in the Render section between "Generate Smooth Normals" and "Ignore KHR_materials_unlit", with the tooltip on hover.

Adds an opt-in boolean on Cesium3DTileset that disables back-face
culling on every per-primitive material, regardless of the glTF
material's doubleSided flag or the cull state of a user-supplied
Opaque Material. Default is off, so existing scenes are unaffected.

This makes it possible to assign a custom Opaque Material with
Render Face = Both and have that setting actually take effect -
previously Cesium would overwrite the material's _Cull /
_DoubleSidedEnable from the glTF on every tile load.
@triktron triktron marked this pull request as ready for review May 22, 2026 20:34
@triktron
Copy link
Copy Markdown
Author

thinking about the problem, perhaps its better if we don't force double-sided on, but instead add a toggle that forced the material properties over the gltf. I'll modify the code later this week.

@triktron triktron marked this pull request as draft June 1, 2026 07:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants