예제 #1
0
파일: ShadowMap.cs 프로젝트: will3/vox
        private void CalculateShadowChunk(Vector2Int origin)
        {
            PerformanceLogger.Push("Shadow Map");
            // Clear
            var texture = new int[DataSize * DataSize];

            for (var i = 0; i < DataSize; i++)
            {
                for (var j = 0; j < DataSize; j++)
                {
                    var index = i * DataSize + j;
                    var v     = CalcShadow(new Vector3Int(i + origin.x, 0, j + origin.y));
                    texture[index] = v;
                }
            }

            if (!_buffers.ContainsKey(origin))
            {
                _buffers[origin] = new ComputeBuffer(DataSize * DataSize, sizeof(int));
            }

            _buffers[origin].SetData(texture);
            PerformanceLogger.Pop();
        }