Example #1
0
        /// <summary>
        /// Initialize the reference volume.
        /// </summary>
        /// <param name ="allocationSize"> Size used for the chunk allocator that handles bricks.</param>
        /// <param name ="memoryBudget">Probe reference volume memory budget.</param>
        /// <param name ="indexDimensions">Dimensions of the index data structure.</param>
        public void InitProbeReferenceVolume(int allocationSize, ProbeVolumeTextureMemoryBudget memoryBudget, Vector3Int indexDimensions)
        {
            if (!m_ProbeReferenceVolumeInit)
            {
                Profiler.BeginSample("Initialize Reference Volume");
                m_Pool  = new ProbeBrickPool(allocationSize, memoryBudget);
                m_Index = new ProbeBrickIndex(indexDimensions);

                m_TmpBricks[0]          = new List <Brick>();
                m_TmpBricks[1]          = new List <Brick>();
                m_TmpBricks[0].Capacity = m_TmpBricks[1].Capacity = 1024;

                // initialize offsets
                m_PositionOffsets[0] = 0.0f;
                float probeDelta = 1.0f / ProbeBrickPool.kBrickCellCount;
                for (int i = 1; i < ProbeBrickPool.kBrickProbeCountPerDim - 1; i++)
                {
                    m_PositionOffsets[i] = i * probeDelta;
                }
                m_PositionOffsets[m_PositionOffsets.Length - 1] = 1.0f;
                Profiler.EndSample();

                m_ProbeReferenceVolumeInit = true;
            }
            m_NeedLoadAsset = true;
        }
        /// <summary>
        /// Initialize the reference volume.
        /// </summary>
        /// <param name ="allocationSize"> Size used for the chunk allocator that handles bricks.</param>
        /// <param name ="memoryBudget">Probe reference volume memory budget.</param>
        /// <param name ="indexDimensions">Dimensions of the index data structure.</param>
        public void InitProbeReferenceVolume(int allocationSize, ProbeVolumeTextureMemoryBudget memoryBudget, Vector3Int indexDimensions)
        {
            if (!m_ProbeReferenceVolumeInit)
            {
                Profiler.BeginSample("Initialize Reference Volume");
                m_Pool  = new ProbeBrickPool(allocationSize, memoryBudget);
                m_Index = new ProbeBrickIndex(indexDimensions);

                m_TmpBricks[0]          = new List <Brick>();
                m_TmpBricks[1]          = new List <Brick>();
                m_TmpBricks[0].Capacity = m_TmpBricks[1].Capacity = 1024;

                // initialize offsets
                m_PositionOffsets[0] = 0.0f;
                float probeDelta = 1.0f / ProbeBrickPool.kBrickCellCount;
                for (int i = 1; i < ProbeBrickPool.kBrickProbeCountPerDim - 1; i++)
                {
                    m_PositionOffsets[i] = i * probeDelta;
                }
                m_PositionOffsets[m_PositionOffsets.Length - 1] = 1.0f;
                Profiler.EndSample();

                m_ProbeReferenceVolumeInit = true;

                // Write constants on init to start with right data.
                m_Index.WriteConstants(ref m_Transform, m_Pool.GetPoolDimensions(), m_NormalBias);
                // Set the normalBiasFromProfile to avoid re-update of the constants up until the next change in profile editor
                normalBiasFromProfile = m_NormalBias;
            }
            m_NeedLoadAsset = true;
        }