diff --git a/Explorer/Assets/DCL/AvatarRendering/AvatarShape/AvatarShape.asmdef b/Explorer/Assets/DCL/AvatarRendering/AvatarShape/AvatarShape.asmdef index 1901760d3b..ccd9065cfc 100644 --- a/Explorer/Assets/DCL/AvatarRendering/AvatarShape/AvatarShape.asmdef +++ b/Explorer/Assets/DCL/AvatarRendering/AvatarShape/AvatarShape.asmdef @@ -27,7 +27,9 @@ "GUID:e25ef972de004615a22937e739de2def", "GUID:543b8f091a5947a3880b7f2bca2358bd", "GUID:d832748739a186646b8656bdbd447ad0", - "GUID:8e25e34dc0eb4a7b93392a4dc25366bd" + "GUID:8e25e34dc0eb4a7b93392a4dc25366bd", + "GUID:09c5cab4669b047398fa5d42a2f64f5b", + "GUID:15fc0a57446b3144c949da3e2b9737a9" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Components/AvatarShapeComponent.cs b/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Components/AvatarShapeComponent.cs index 79179c93ee..a2d4d4e58b 100644 --- a/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Components/AvatarShapeComponent.cs +++ b/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Components/AvatarShapeComponent.cs @@ -23,6 +23,7 @@ public struct AvatarShapeComponent public string Name; public readonly List InstantiatedWearables; + public readonly List OutlineCompatibleRenderers; public AvatarShapeComponent(string name, string id, BodyShape bodyShape, WearablePromise wearablePromise, Color skinColor, Color hairColor, Color eyesColor) @@ -33,6 +34,7 @@ public AvatarShapeComponent(string name, string id, BodyShape bodyShape, Wearabl IsDirty = true; WearablePromise = wearablePromise; InstantiatedWearables = new List(); + OutlineCompatibleRenderers = new List(); SkinColor = skinColor; HairColor = hairColor; EyesColor = eyesColor; @@ -40,11 +42,27 @@ public AvatarShapeComponent(string name, string id, BodyShape bodyShape, Wearabl HiddenByModifierArea = false; } + public void CreateOutlineCompatibilityList() + { + foreach (var wearable in InstantiatedWearables) + { + if (wearable.OutlineCompatible) + { + foreach (var rend in wearable.Renderers) + { + if (rend.sharedMaterial.renderQueue >= 2000 && rend.sharedMaterial.renderQueue < 3000) + OutlineCompatibleRenderers.Add(rend); + } + } + } + } + public AvatarShapeComponent(string name, string id) : this() { ID = id; Name = name; InstantiatedWearables = new List(); + OutlineCompatibleRenderers = new List(); IsVisible = true; } } diff --git a/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Helpers/ReleaseAvatar.cs b/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Helpers/ReleaseAvatar.cs index f46dd71344..cfb6ad44f0 100644 --- a/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Helpers/ReleaseAvatar.cs +++ b/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Helpers/ReleaseAvatar.cs @@ -21,7 +21,10 @@ public static void Execute(FixedComputeBufferHandler vertOutBuffer, IAttachments jobWrapper.ReleaseAvatar(ref avatarTransformMatrixComponent); if (avatarShapeComponent.WearablePromise.IsConsumed) + { + avatarShapeComponent.OutlineCompatibleRenderers.Clear(); wearableAssetsCache.ReleaseAssets(avatarShapeComponent.InstantiatedWearables); + } else avatarShapeComponent.Dereference(); } diff --git a/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Systems/AvatarInstantiatorSystem.cs b/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Systems/AvatarInstantiatorSystem.cs index b0f266ba0b..f4be1d47cf 100644 --- a/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Systems/AvatarInstantiatorSystem.cs +++ b/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Systems/AvatarInstantiatorSystem.cs @@ -208,6 +208,7 @@ private AvatarCustomSkinningComponent InstantiateAvatar(ref AvatarShapeComponent skinningStrategy.SetVertOutRegion(vertOutBuffer.Rent(skinningComponent.vertCount), ref skinningComponent); avatarBase.gameObject.SetActive(true); + avatarShapeComponent.CreateOutlineCompatibilityList(); wearableIntention.Dispose(); if (wearablesResult.Succeeded) diff --git a/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Systems/AvatarShapeVisibilitySystem.cs b/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Systems/AvatarShapeVisibilitySystem.cs index b359cc3c83..af2973b68d 100644 --- a/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Systems/AvatarShapeVisibilitySystem.cs +++ b/Explorer/Assets/DCL/AvatarRendering/AvatarShape/Systems/AvatarShapeVisibilitySystem.cs @@ -6,6 +6,7 @@ using DCL.Character.Components; using DCL.CharacterCamera; using DCL.ECSComponents; +using DCL.Quality; using DCL.Rendering.Avatar; using ECS.Abstract; using System.Runtime.CompilerServices; @@ -16,9 +17,13 @@ namespace DCL.AvatarRendering.AvatarShape.Systems [UpdateInGroup(typeof(CameraGroup))] public partial class AvatarShapeVisibilitySystem : BaseUnityLoopSystem { + private readonly OutlineRendererFeature? outlineFeature; private SingleInstanceEntity camera; - public AvatarShapeVisibilitySystem(World world) : base(world) { } + public AvatarShapeVisibilitySystem(World world, IRendererFeaturesCache outlineFeature) : base(world) + { + this.outlineFeature = outlineFeature.GetRendererFeature(); + } public override void Initialize() { @@ -42,27 +47,19 @@ public bool IsVisibleInCamera(Camera camera, Bounds bounds) return GeometryUtility.TestPlanesAABB(planes, bounds); } - public bool IsWithinCameraDistance(Camera camera, Transform objectTransform, float maxDistance) + public bool IsWithinCameraDistance(Camera camera, Transform objectTransform, float maxDistancesquared) { - float distance = Vector3.Distance(camera.transform.position, objectTransform.position); - return distance <= maxDistance; + var diff = camera.transform.position - objectTransform.position; + float distance = diff.sqrMagnitude; + return distance <= maxDistancesquared; } [Query] - private void GetAvatarsVisibleWithOutline(in AvatarBase avatarBase, ref AvatarShapeComponent avatarShape, ref AvatarCachedVisibilityComponent avatarCachedVisibility) + private void GetAvatarsVisibleWithOutline(in AvatarBase avatarBase, ref AvatarShapeComponent avatarShape) { - if (IsWithinCameraDistance(camera.GetCameraComponent(World).Camera, avatarBase.HeadAnchorPoint, 8.0f) && IsVisibleInCamera(camera.GetCameraComponent(World).Camera, avatarBase.AvatarSkinnedMeshRenderer.bounds)) + if (outlineFeature != null && outlineFeature.isActive && IsWithinCameraDistance(camera.GetCameraComponent(World).Camera, avatarBase.HeadAnchorPoint, 64.0f) && IsVisibleInCamera(camera.GetCameraComponent(World).Camera, avatarBase.AvatarSkinnedMeshRenderer.bounds)) { - foreach (var avs in avatarShape.InstantiatedWearables) - { - if (avs.OutlineCompatible) - { - foreach (var rend in avs.Renderers) - { - OutlineRendererFeature.m_OutlineRenderers.Add(rend); - } - } - } + OutlineRendererFeature.m_OutlineRenderers.AddRange(avatarShape.OutlineCompatibleRenderers); } } @@ -115,6 +112,7 @@ private void UpdateVisibilityState(ref AvatarShapeComponent avatarShape, ref Ava Hide(ref avatarShape); else Show(ref avatarShape); + avatarCachedVisibility.IsVisible = shouldBeHidden; } diff --git a/Explorer/Assets/DCL/Editor/DCL.Editor.asmdef b/Explorer/Assets/DCL/Editor/DCL.Editor.asmdef index f6c057ec95..1b8442b772 100644 --- a/Explorer/Assets/DCL/Editor/DCL.Editor.asmdef +++ b/Explorer/Assets/DCL/Editor/DCL.Editor.asmdef @@ -23,7 +23,8 @@ "GUID:286980af24684da6acc1caa413039811", "GUID:1d2c76eb8b48e0b40940e8b31a679ce1", "GUID:fc37ca6521833154cab08ec51af097d9", - "GUID:fdc035e0abb695e408d8ccf2c3bd63a5" + "GUID:fdc035e0abb695e408d8ccf2c3bd63a5", + "Quality.RenderFeatures" ], "includePlatforms": [ "Editor" diff --git a/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef b/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef index 4f705413ec..3f09d762f3 100644 --- a/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef +++ b/Explorer/Assets/DCL/PluginSystem/DCL.Plugins.asmdef @@ -153,7 +153,8 @@ "GUID:fdc035e0abb695e408d8ccf2c3bd63a5", "GUID:ead265f036164eb7899edc341131f4d5", "GUID:e9db755bba99425db4ca5d30e48b7429", - "GUID:5462d37de7d4344df8aade58a45b403e" + "GUID:5462d37de7d4344df8aade58a45b403e", + "GUID:09c5cab4669b047398fa5d42a2f64f5b" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Explorer/Assets/DCL/PluginSystem/Global/AvatarPlugin.cs b/Explorer/Assets/DCL/PluginSystem/Global/AvatarPlugin.cs index 5981ffe253..8363accbf0 100644 --- a/Explorer/Assets/DCL/PluginSystem/Global/AvatarPlugin.cs +++ b/Explorer/Assets/DCL/PluginSystem/Global/AvatarPlugin.cs @@ -26,7 +26,7 @@ using DCL.AvatarRendering.AvatarShape.Helpers; using DCL.Multiplayer.Profiles.Entities; using DCL.AvatarRendering.Loading.Assets; -using DCL.Multiplayer.Profiles.Tables; +using DCL.Quality; using UnityEngine; using UnityEngine.AddressableAssets; using UnityEngine.Pool; @@ -51,6 +51,7 @@ public class AvatarPlugin : IDCLGlobalPlugin private readonly IPerformanceBudget frameTimeCapBudget; private readonly ObjectProxy mainPlayerAvatarBaseProxy; private readonly IPerformanceBudget memoryBudget; + private readonly IRendererFeaturesCache rendererFeaturesCache; private readonly IRealmData realmData; private readonly AttachmentsAssetsCache attachmentsAssetsCache; @@ -84,6 +85,7 @@ public AvatarPlugin( IAssetsProvisioner assetsProvisioner, IPerformanceBudget frameTimeCapBudget, IPerformanceBudget memoryBudget, + IRendererFeaturesCache rendererFeaturesCache, IRealmData realmData, ObjectProxy mainPlayerAvatarBaseProxy, IDebugContainerBuilder debugContainerBuilder, @@ -106,6 +108,7 @@ ExposedTransform playerTransform this.chatEntryConfiguration = chatEntryConfiguration; this.defaultFaceFeaturesHandler = defaultFaceFeaturesHandler; this.memoryBudget = memoryBudget; + this.rendererFeaturesCache = rendererFeaturesCache; this.nametagsData = nametagsData; this.textureArrayContainerFactory = textureArrayContainerFactory; this.remoteEntities = remoteEntities; @@ -166,7 +169,7 @@ public void InjectToWorld(ref ArchSystemsWorldBuilder builder, FinishAvatarMatricesCalculationSystem.InjectToWorld(ref builder, skinningStrategy, avatarTransformMatrixJobWrapper); - AvatarShapeVisibilitySystem.InjectToWorld(ref builder); + AvatarShapeVisibilitySystem.InjectToWorld(ref builder, rendererFeaturesCache); AvatarCleanUpSystem.InjectToWorld(ref builder, frameTimeCapBudget, vertOutBuffer, avatarMaterialPoolHandler, avatarPoolRegistry, computeShaderPool, attachmentsAssetsCache, mainPlayerAvatarBaseProxy, avatarTransformMatrixJobWrapper); diff --git a/Explorer/Assets/DCL/Quality/Container/csc.rsp b/Explorer/Assets/DCL/Quality/Container/csc.rsp new file mode 100644 index 0000000000..2d66b0292b --- /dev/null +++ b/Explorer/Assets/DCL/Quality/Container/csc.rsp @@ -0,0 +1 @@ +-nullable:enable diff --git a/Explorer/Assets/DCL/Quality/Container/csc.rsp.meta b/Explorer/Assets/DCL/Quality/Container/csc.rsp.meta new file mode 100644 index 0000000000..54af153edc --- /dev/null +++ b/Explorer/Assets/DCL/Quality/Container/csc.rsp.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 49681f3ab5d449acadf1f0e7c9125572 +timeCreated: 1737540608 \ No newline at end of file diff --git a/Explorer/Assets/DCL/Quality/DCL.Quality.asmdef b/Explorer/Assets/DCL/Quality/DCL.Quality.asmdef index f18cd2276d..2585827bed 100644 --- a/Explorer/Assets/DCL/Quality/DCL.Quality.asmdef +++ b/Explorer/Assets/DCL/Quality/DCL.Quality.asmdef @@ -11,7 +11,8 @@ "GUID:4794e238ed0f65142a4aea5848b513e5", "GUID:a29f69b42fb1815409464ac7b05381d0", "GUID:21c2e77c042a2d34d8cfbf58f8217053", - "GUID:fc37ca6521833154cab08ec51af097d9" + "GUID:fc37ca6521833154cab08ec51af097d9", + "GUID:09c5cab4669b047398fa5d42a2f64f5b" ], "includePlatforms": [], "excludePlatforms": [], diff --git a/Explorer/Assets/DCL/Quality/Editor/QualitySettingsEditorListener.cs b/Explorer/Assets/DCL/Quality/Editor/QualitySettingsEditorListener.cs index 58c3a15d5d..8700e1e95b 100644 --- a/Explorer/Assets/DCL/Quality/Editor/QualitySettingsEditorListener.cs +++ b/Explorer/Assets/DCL/Quality/Editor/QualitySettingsEditorListener.cs @@ -1,8 +1,6 @@ using DCL.Quality.Runtime; -using System; using System.Linq; using UnityEditor; -using UnityEditor.Callbacks; using UnityEditor.Compilation; namespace DCL.Quality diff --git a/Explorer/Assets/DCL/Quality/RenderFeatures.meta b/Explorer/Assets/DCL/Quality/RenderFeatures.meta new file mode 100644 index 0000000000..61faaa4179 --- /dev/null +++ b/Explorer/Assets/DCL/Quality/RenderFeatures.meta @@ -0,0 +1,3 @@ +fileFormatVersion: 2 +guid: 6bfc3d89cf4c41928ac7540c14dff38d +timeCreated: 1737540001 \ No newline at end of file diff --git a/Explorer/Assets/DCL/Quality/IRendererFeaturesCache.cs b/Explorer/Assets/DCL/Quality/RenderFeatures/IRendererFeaturesCache.cs similarity index 100% rename from Explorer/Assets/DCL/Quality/IRendererFeaturesCache.cs rename to Explorer/Assets/DCL/Quality/RenderFeatures/IRendererFeaturesCache.cs diff --git a/Explorer/Assets/DCL/Quality/IRendererFeaturesCache.cs.meta b/Explorer/Assets/DCL/Quality/RenderFeatures/IRendererFeaturesCache.cs.meta similarity index 100% rename from Explorer/Assets/DCL/Quality/IRendererFeaturesCache.cs.meta rename to Explorer/Assets/DCL/Quality/RenderFeatures/IRendererFeaturesCache.cs.meta diff --git a/Explorer/Assets/DCL/Quality/RenderFeatures/Quality.RenderFeatures.asmdef b/Explorer/Assets/DCL/Quality/RenderFeatures/Quality.RenderFeatures.asmdef new file mode 100644 index 0000000000..4a6c5bbde0 --- /dev/null +++ b/Explorer/Assets/DCL/Quality/RenderFeatures/Quality.RenderFeatures.asmdef @@ -0,0 +1,16 @@ +{ + "name": "Quality.RenderFeatures", + "rootNamespace": "", + "references": [ + "GUID:15fc0a57446b3144c949da3e2b9737a9" + ], + "includePlatforms": [], + "excludePlatforms": [], + "allowUnsafeCode": false, + "overrideReferences": false, + "precompiledReferences": [], + "autoReferenced": true, + "defineConstraints": [], + "versionDefines": [], + "noEngineReferences": false +} \ No newline at end of file diff --git a/Explorer/Assets/DCL/Quality/RenderFeatures/Quality.RenderFeatures.asmdef.meta b/Explorer/Assets/DCL/Quality/RenderFeatures/Quality.RenderFeatures.asmdef.meta new file mode 100644 index 0000000000..0d2c685eb8 --- /dev/null +++ b/Explorer/Assets/DCL/Quality/RenderFeatures/Quality.RenderFeatures.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 09c5cab4669b047398fa5d42a2f64f5b +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Explorer/Assets/DCL/Quality/RendererFeaturesCache.cs b/Explorer/Assets/DCL/Quality/RenderFeatures/RendererFeaturesCache.cs similarity index 100% rename from Explorer/Assets/DCL/Quality/RendererFeaturesCache.cs rename to Explorer/Assets/DCL/Quality/RenderFeatures/RendererFeaturesCache.cs diff --git a/Explorer/Assets/DCL/Quality/RendererFeaturesCache.cs.meta b/Explorer/Assets/DCL/Quality/RenderFeatures/RendererFeaturesCache.cs.meta similarity index 100% rename from Explorer/Assets/DCL/Quality/RendererFeaturesCache.cs.meta rename to Explorer/Assets/DCL/Quality/RenderFeatures/RendererFeaturesCache.cs.meta diff --git a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs index ce04dc2b79..1c04a53e4c 100644 --- a/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs +++ b/Explorer/Assets/Scripts/Global/Dynamic/DynamicWorldContainer.cs @@ -621,6 +621,7 @@ static IMultiPool MultiPoolFactory() => assetsProvisioner, staticContainer.SingletonSharedDependencies.FrameTimeBudget, staticContainer.SingletonSharedDependencies.MemoryBudget, + staticContainer.QualityContainer.RendererFeaturesCache, staticContainer.RealmData, staticContainer.MainPlayerAvatarBaseProxy, debugBuilder,