Add Force Double Sided toggle to Cesium3DTileset#695
Draft
triktron wants to merge 1 commit into
Draft
Conversation
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.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Adds an opt-in
Force Double Sidedboolean toCesium3DTileset. When enabled, every per-primitive material has_DoubleSidedEnable = 1and_Cull / _CullMode / _BUILTIN_CullMode = Off, applied after the per-primitive glTF material values are written.This makes it possible to assign a custom
Opaque MaterialwithRender 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 fromgltfMaterial.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 inUnityPrepareRendererResources.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 —
_forceDoubleSidedfield +forceDoubleSidedproperty onCesium3DTileset, an exposure line inConfigureReinterop.cs, andtilesetComponent.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
CHANGES.mdwith a short summary of my change (for user-facing changes).Testing plan
Manual, in both URP and Built-in (have not yet verified HDRP, where the original #491 had quirks).
Cesium3DTilesetwithOpaque Material = None,Force Double Sided = false— default behavior preserved:doubleSided = falseare back-face culled.doubleSided = truerender from both sides.Force Double Sided = true— every tile renders both sides. Runtime per-primitive material has_Cull == 0,_CullMode == 0,_DoubleSidedEnable == 1.CesiumDefaultTilesetMaterial, setRender Face = Backso_Cull = 2, assign toOpaque Material, toggleForce Double Sided = true— Cesium still renders double-sided (verifies the toggle wins over the source material as well).Force Double Sided = false— cull state matches the glTF (original behavior).