Skip to content
Merged
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
47 changes: 27 additions & 20 deletions Explorer/Assets/DCL/Landscape/Settings/LandscapeData.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using DCL.Landscape.Utils;
using Decentraland.Terrain;
using GPUInstancerPro;
using JetBrains.Annotations;
using System;
using UnityEngine;
using UnityEngine.AddressableAssets;
Expand All @@ -9,15 +10,22 @@ namespace DCL.Landscape.Settings
{
public class LandscapeData : ScriptableObject
{
public Action<float>? OnDetailDistanceChanged;
// ReSharper disable InconsistentNaming
public Transform mapChunk = null!;
public TerrainGenerationData terrainData = null!;
public TerrainGenerationData worldsTerrainData = null!;
// ReSharper restore InconsistentNaming

public Transform mapChunk;
public TerrainGenerationData terrainData;
public TerrainGenerationData worldsTerrainData;
[SerializeField] private float detailDistanceValue = 200;

[field: SerializeField] public Material? GroundMaterial { get; private set; }
[field: SerializeField] public int GroundInstanceCapacity { get; set; }
[field: SerializeField] public GrassIndirectRenderer? GrassIndirectRenderer { get; private set; }
[field: SerializeField] [field: EnumIndexedArray(typeof(GroundMeshPiece))]
public Mesh?[] GroundMeshes { get; private set; } = null!;

[field: SerializeField] public GPUIProfile TreesProfile { get; private set; } = null!;

[SerializeField] private float detailDistanceValue = 200;
public float DetailDistance
{
get => detailDistanceValue;
Expand All @@ -29,10 +37,14 @@ public float DetailDistance

detailDistanceValue = value;
ApplyDetailDistanceToTrees(value);
OnDetailDistanceChanged?.Invoke(value);
}
}

public bool RenderGround { get; set; } = true;
public bool RenderTrees { get; set; } = true;
public bool RenderGrass { get; set; } = true;
public bool ShowSatelliteFloor { get; set; } = true;

private void ApplyDetailDistanceToTrees(float distance)
{
TreesProfile.minMaxDistance = new Vector2(0, distance);
Expand All @@ -45,22 +57,11 @@ private void OnEnable()
ApplyDetailDistanceToTrees(detailDistanceValue);
}

public bool RenderGround { get; set; } = true;
public bool RenderTrees { get; set; } = true;
public bool RenderGrass { get; set; } = true;
public bool ShowSatelliteFloor { get; set; } = true;
[field: SerializeField] public Material? GroundMaterial { get; private set; }
[field: SerializeField] public int GroundInstanceCapacity { get; set; }
[field: SerializeField] public GrassIndirectRenderer? GrassIndirectRenderer { get; private set; }

[field: SerializeField] [field: EnumIndexedArray(typeof(GroundMeshPiece))]
public Mesh?[] GroundMeshes { get; private set; } = null!;

private enum GroundMeshPiece
{
Middle,
Edge,
Corner,
[UsedImplicitly] Middle,
[UsedImplicitly] Edge,
[UsedImplicitly] Corner,
}
}

Expand All @@ -69,4 +70,10 @@ public class LandscapeDataRef : AssetReferenceT<LandscapeData>
{
public LandscapeDataRef(string guid) : base(guid) { }
}

[Serializable]
public class GpuiShaderBindingsRef : AssetReferenceT<GPUIShaderBindings>
{
public GpuiShaderBindingsRef(string guid) : base(guid) { }
}
}
7 changes: 7 additions & 0 deletions Explorer/Assets/DCL/PluginSystem/Global/LandscapePlugin.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class LandscapePlugin : IDCLGlobalPlugin<LandscapeSettings>

private RealmPartitionSettingsAsset realmPartitionSettings;
private ProvidedAsset<LandscapeData> landscapeData;
private ProvidedAsset<GPUIShaderBindings> gpuiShaderBindings;
private NativeParallelHashSet<int2> emptyParcels;
private NativeParallelHashSet<int2> ownedParcels;
private SatelliteFloor? floor;
Expand Down Expand Up @@ -79,6 +80,12 @@ public async UniTask InitializeAsync(LandscapeSettings settings, CancellationTok

realmPartitionSettings = settings.realmPartitionSettings;

// Fix ANR: creating the GPUI rendering system loads the shader bindings with Addressables
// WaitForCompletion(), which blocks the main thread until Unity's PreloadManager has finished
// every async load already in flight, not just this one.
Comment thread
lorux0 marked this conversation as resolved.
Comment thread
lorux0 marked this conversation as resolved.
gpuiShaderBindings = await assetsProvisioner.ProvideMainAssetAsync(settings.gpuiShaderBindings, ct);
GPUIShaderBindings.Instance = gpuiShaderBindings.Value;

GPUIProfile treesProfile = landscapeData.Value.TreesProfile;
LandscapeAsset[] treePrototypes = landscapeData.Value.terrainData.treeAssets;
int[] treeRendererKeys = new int[treePrototypes.Length];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ public class LandscapeSettings : IDCLPluginSettings
[field: Header(nameof(LandscapeSettings))] [field: Space]
[field: SerializeField] public RealmPartitionSettingsAsset realmPartitionSettings;
[field: SerializeField] public LandscapeDataRef landscapeData;
[field: SerializeField] public GpuiShaderBindingsRef gpuiShaderBindings;

}
}
Original file line number Diff line number Diff line change
Expand Up @@ -796,6 +796,12 @@ MonoBehaviour:
m_SubObjectType:
m_SubObjectGUID:
m_EditorAssetChanged: 0
gpuiShaderBindings:
m_AssetGUID: 50f997bbd4ff89a469f03b9794ff393f
m_SubObjectName:
m_SubObjectType:
m_SubObjectGUID:
m_EditorAssetChanged: 0
- rid: 3414978285727645698
type: {class: PointerInputAudioPlugin/Settings, ns: DCL.PluginSystem.Global, asm: DCL.Plugins}
data:
Expand Down
Loading