示例#1
0
        protected override void Init(PipelineResources resources)
        {
            cbdr             = PipelineSharedData.Get(renderPath, resources, (a) => new CBDRSharedData(a));
            shadMaskMaterial = new Material(resources.shadowMaskShader);
            for (int i = 0; i < cascadeShadowMapVP.Length; ++i)
            {
                cascadeShadowMapVP[i] = Matrix4x4.identity;
            }

            shadowList = new NativeList <int>(50, Allocator.Persistent);
            cubeBuffer = new CubeCullingBuffer();
            CubeFunction.Init(ref cubeBuffer);
            pointLightMaterial = new Material(resources.pointLightShader);
            cubeDepthMaterial  = new Material(resources.cubeDepthShader);
            Vector3[]             vertices    = resources.sphereMesh.vertices;
            int[]                 triangle    = resources.sphereMesh.triangles;
            NativeArray <Vector3> allVertices = new NativeArray <Vector3>(triangle.Length, Allocator.Temp, NativeArrayOptions.UninitializedMemory);

            for (int i = 0; i < allVertices.Length; ++i)
            {
                allVertices[i] = vertices[triangle[i]];
            }
            sphereBuffer = new ComputeBuffer(allVertices.Length, sizeof(Vector3));
            sphereBuffer.SetData(allVertices);
            allVertices.Dispose();
        }
示例#2
0
 public override void Dispose()
 {
     if (current != this)
     {
         return;
     }
     current = null;
     data.buffer.Dispose();
     foreach (var i in gpurpEvents)
     {
         i.DisposeEvent();
     }
     PipelineSharedData.DisposeAll();
 }
 private void OnDestroy()
 {
     if (current != this)
     {
         return;
     }
     current = null;
     foreach (var i in allEvents)
     {
         i.DisposeEvent();
     }
     allEvents = null;
     data.buffer.Dispose();
     sceneController.OnDestroy();
     PipelineSharedData.DisposeAll();
 }
        protected override void Init(PipelineResources resources)
        {
            randomBuffer = new ComputeBuffer(downSampledSize.x * downSampledSize.y * downSampledSize.z, sizeof(uint));
            NativeArray <uint> randomArray = new NativeArray <uint>(randomBuffer.count, Allocator.Temp, NativeArrayOptions.UninitializedMemory);
            uint *randPtr = randomArray.Ptr();

            rand = new Random((uint)System.Guid.NewGuid().GetHashCode());
            for (int i = 0; i < randomArray.Length; ++i)
            {
                randPtr[i] = (uint)System.Guid.NewGuid().GetHashCode();
            }
            randomBuffer.SetData(randomArray);
            randomArray.Dispose();
            cbdr      = PipelineSharedData.Get(renderPath, resources, (res) => new CBDRSharedData(res));
            volumeMat = new Material(resources.volumetricShader);
        }