using System; using HTraceWSGI.Scripts.Globals; using UnityEngine; namespace HTraceWSGI.Scripts.Structs { [Serializable] public class VoxelizationData { public VoxelizationData() { UpdateData(); } public void UpdateData() { ExactData.UpdateData(this); } [SerializeField] internal VoxelizationExactData ExactData = new VoxelizationExactData(); //Voxelization ------------------------------------------------------------------------------------------------ /// /// Exclude objects (on a per-layer basis) from voxelization and has the highest priority over all other layer masks. /// /// More information public LayerMask VoxelizationMask = ~0; /// /// This mode defines how voxel data will be updated. /// /// More information public VoxelizationUpdateMode VoxelizationUpdateMode = VoxelizationUpdateMode.Constant; [SerializeField] private int _updatePeriod = 1; /// /// Update Period /// /// [1;4] /// More information [HExtensions.HRangeAttribute(1, 4)] public int UpdatePeriod { get { return _updatePeriod; } set { if (value == _updatePeriod) return; HExtensions.HRangeAttributeDictionary.TryGetValue(nameof(UpdatePeriod), out HExtensions.HRangeAttributeElement attributeValue); _updatePeriod = Mathf.Clamp(value, attributeValue.minInt, attributeValue.maxInt); } } /// /// Anchor object for the voxelization bound. Voxelization will occur around this object and will follow it when it moves. /// /// More information public Transform AttachTo; /// /// Main shadow-casting Directional light. It is usually set up automatically. /// /// More information public Light DirectionalLight; [SerializeField] private float _expandShadowmap = 1f; /// /// Controls the area covered by the custom directional shadowmap. The shadowmap is used to evaluate direct lighting and shadowing at hit points of world-space rays. /// /// [0.0;3.0] /// More information [HExtensions.HRangeAttribute(1.0f, 3.0f)] public float ExpandShadowmap { get { return _expandShadowmap; } set { if (Mathf.Abs(value - _expandShadowmap) < Mathf.Epsilon) return; HExtensions.HRangeAttributeDictionary.TryGetValue(nameof(ExpandShadowmap), out HExtensions.HRangeAttributeElement attributeValue); _expandShadowmap = Mathf.Clamp(value, attributeValue.minFloat, attributeValue.maxFloat); } } [SerializeField] private int _lodMax = 0; /// /// Maximum LOD level /// /// [0;10] /// More information [HExtensions.HRangeAttribute(0, HConstants.MAX_LOD_LEVEL)] public int LODMax { get { return _lodMax; } set { if (value == _lodMax) return; HExtensions.HRangeAttributeDictionary.TryGetValue(nameof(LODMax), out HExtensions.HRangeAttributeElement attributeValue); _lodMax = Mathf.Clamp(value, attributeValue.minInt, attributeValue.maxInt); } } /// /// /// public LayerMask InstancedTerrains = 0; //Update Options ------------------------------------------------------------------------------------------------ public LayerMask CulledObjectsMask = 0; [SerializeField] private int _expandCullFov = 0; /// /// Expand Cull Fov /// /// [0;20] [HExtensions.HRangeAttribute(0, 20)] public int ExpandCullFov { get { return _expandCullFov; } set { if (value == _expandCullFov) return; HExtensions.HRangeAttributeDictionary.TryGetValue(nameof(ExpandCullFov), out HExtensions.HRangeAttributeElement attributeValue); _expandCullFov = Mathf.Clamp(value, attributeValue.minInt, attributeValue.maxInt); } } [SerializeField] private float _expandCullRadius = 1f; /// /// Expand Cull Radius /// /// [0.0;3.0] [HExtensions.HRangeAttribute(0.0f, 3.0f)] public float ExpandCullRadius { get { return _expandCullRadius; } set { if (Mathf.Abs(value - _expandCullRadius) < Mathf.Epsilon) return; HExtensions.HRangeAttributeDictionary.TryGetValue(nameof(ExpandCullRadius), out HExtensions.HRangeAttributeElement attributeValue); _expandCullRadius = Mathf.Clamp(value, attributeValue.minFloat, attributeValue.maxFloat); } } public LayerMask DynamicObjectsMask = 0; //Voxels parameters ------------------------------------------------------------------------------------------------ [SerializeField] private float _voxelDensity = 0.64f; /// /// Controls the resolution of the voxel volume (3D Texture). Lower values reduce the volume resolution, while higher values provide finer detail. The Voxel Density is limited by /// the Voxel Bounds parameter to ensure voxel sizes remain between 4 and 8 centimeters. /// /// [0.0;1.0] /// More information [HExtensions.HRangeAttribute(0.0f, 1.0f)] public float VoxelDensity { get { return _voxelDensity; } set { if (Mathf.Abs(value - _voxelDensity) < Mathf.Epsilon) return; HExtensions.HRangeAttributeDictionary.TryGetValue(nameof(VoxelDensity), out HExtensions.HRangeAttributeElement attributeValue); _voxelDensity = Mathf.Clamp(value, attributeValue.minFloat, attributeValue.maxFloat); ExactData.UpdateData(this); } } [SerializeField] private int _voxelBounds = 35; /// /// Controls the maximum size (in meters) that the voxelization bound can cover. /// /// [1;80] /// More information [HExtensions.HRangeAttribute(1, HConfig.MAX_VOXEL_BOUNDS)] public int VoxelBounds { get { return _voxelBounds; } set { if (value == _voxelBounds) return; HExtensions.HRangeAttributeDictionary.TryGetValue(nameof(VoxelBounds), out HExtensions.HRangeAttributeElement attributeValue); _voxelBounds = Mathf.Clamp(value, attributeValue.minInt, attributeValue.maxInt); ExactData.UpdateData(this); } } [SerializeField] private bool _overrideBoundsHeightEnable = false; /// /// Enable Bounds height override. /// /// [1;80] /// More information public bool OverrideBoundsHeightEnable { get { return _overrideBoundsHeightEnable; } set { _overrideBoundsHeightEnable = value; } } [SerializeField] private int _overrideBoundsHeight = 10; /// /// The maximum height of the voxelization bound. /// This parameter is particularly useful for "flat" levels with low verticality, where the scene extends along the X and Z axes but has minimal content along the Y axis /// (e.g., indoor scenes where the distance to walls is typically greater than the distance to the floor or ceiling). /// /// [1;200] /// More information [HExtensions.HRangeAttribute(1, 200)] public int OverrideBoundsHeight { get { return _overrideBoundsHeight; } set { if (value == _overrideBoundsHeight) return; HExtensions.HRangeAttributeDictionary.TryGetValue(nameof(OverrideBoundsHeight), out HExtensions.HRangeAttributeElement attributeValue); _overrideBoundsHeight = Mathf.Clamp(value, attributeValue.minInt, attributeValue.maxInt); ExactData.UpdateData(this); } } /// /// Shift Center of voxelization bound /// /// More information public float CenterShift = 0f; /// /// Enable Ground level for voxelization. /// /// More information public bool GroundLevelEnable = false; /// /// Ensures that the voxelization bounds will always remain above this specified level. /// This option is useful when you know the base level of your scene and there is no need to voxelize anything below it. /// /// More information public float GroundLevel = 0f; } }