Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## ? - ?

##### Additions :tada:

- Added a `Force Double Sided` toggle to `Cesium3DTileset`. When enabled, all tile primitives are rendered with back-face culling disabled, regardless of the glTF material's `doubleSided` flag or the cull state of a user-supplied `Opaque Material`.

##### Fixes :wrench:

- The native Android library (`libCesiumForUnityNative.so`) is now built with 16 KB ELF segment alignment, enabling compatibility with Android 15+ devices that use 16 KB memory pages.
Expand Down
11 changes: 11 additions & 0 deletions Source/Editor/Cesium3DTilesetEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public class Cesium3DTilesetEditor : Editor
//private SerializedProperty _useLodTransitions;
//private SerializedProperty _lodTransitionLength;
private SerializedProperty _generateSmoothNormals;
private SerializedProperty _forceDoubleSided;

private SerializedProperty _pointCloudShading;

Expand Down Expand Up @@ -85,6 +86,8 @@ private void OnEnable()
// this.serializedObject.FindProperty("_lodTransitionLength");
this._generateSmoothNormals =
this.serializedObject.FindProperty("_generateSmoothNormals");
this._forceDoubleSided =
this.serializedObject.FindProperty("_forceDoubleSided");
this._ignoreKhrMaterialsUnlit = this.serializedObject.FindProperty("_ignoreKhrMaterialsUnlit");

this._pointCloudShading = this.serializedObject.FindProperty("_pointCloudShading");
Expand Down Expand Up @@ -429,6 +432,14 @@ private void DrawRenderProperties()
"rendered with smooth normals instead when the original glTF is missing normals.");
EditorGUILayout.PropertyField(this._generateSmoothNormals, generateSmoothNormalsContent);

GUIContent forceDoubleSidedContent = new GUIContent(
"Force Double Sided",
"Disable back-face culling on every tile material, ignoring the " +
"glTF doubleSided flag. Use this when you assign a custom Opaque " +
"Material with double-sided rendering and don't want Cesium to " +
"overwrite that setting per tile.");
EditorGUILayout.PropertyField(this._forceDoubleSided, forceDoubleSidedContent);

var ignoreKhrMaterialsUnlit = new GUIContent(
"Ignore KHR_materials_unlit",
"Whether to ignore the KHR_materials_unlit extension on the glTF tiles in "+
Expand Down
23 changes: 23 additions & 0 deletions Source/Runtime/Cesium3DTileset.cs
Original file line number Diff line number Diff line change
Expand Up @@ -589,6 +589,29 @@ public bool generateSmoothNormals
}
}

[SerializeField]
private bool _forceDoubleSided = false;

/// <summary>
/// When enabled, all tile primitives are rendered with back-face culling
/// disabled, regardless of the glTF material's doubleSided flag or the
/// settings on a user-supplied opaqueMaterial.
/// </summary>
/// <remarks>
/// Useful when assigning a custom Material whose Render Face is set to
/// Both - Cesium would otherwise overwrite the material's cull state from
/// the glTF on every tile load.
/// </remarks>
public bool forceDoubleSided
{
get => this._forceDoubleSided;
set
{
this._forceDoubleSided = value;
this.RecreateTileset();
}
}

[SerializeField]
private bool _ignoreKhrMaterialsUnlit = false;

Expand Down
1 change: 1 addition & 0 deletions Source/Runtime/ConfigureReinterop.cs
Original file line number Diff line number Diff line change
Expand Up @@ -295,6 +295,7 @@ public void ExposeToCPP()
//tileset.useLodTransitions = tileset.useLodTransitions;
//tileset.lodTransitionLength = tileset.lodTransitionLength;
tileset.generateSmoothNormals = tileset.generateSmoothNormals;
tileset.forceDoubleSided = tileset.forceDoubleSided;
tileset.ignoreKhrMaterialsUnlit = tileset.ignoreKhrMaterialsUnlit;
tileset.createPhysicsMeshes = tileset.createPhysicsMeshes;
tileset.suspendUpdate = tileset.suspendUpdate;
Expand Down
15 changes: 15 additions & 0 deletions native~/src/Runtime/UnityPrepareRendererResources.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1586,6 +1586,21 @@ void* UnityPrepareRendererResources::prepareInMainThread(
materialProperties);
}

if (tilesetComponent.forceDoubleSided()) {
material.SetFloat(
materialProperties.getDoubleSidedEnableID(),
1.0f);
material.SetFloat(
materialProperties.getCullID(),
float(UnityEngine::Rendering::CullMode::Off));
material.SetFloat(
materialProperties.getCullModeID(),
float(UnityEngine::Rendering::CullMode::Off));
material.SetFloat(
materialProperties.getBuiltInCullModeID(),
float(UnityEngine::Rendering::CullMode::Off));
}

if (primitiveInfo.containsPoints) {
CesiumForUnity::CesiumPointCloudRenderer pointCloudRenderer =
primitiveGameObject
Expand Down