protected override void Init(PipelineResources resources) { block = new MaterialPropertyBlock(); 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(); sphereIndirectBuffer = new ComputeBuffer(5, 4, ComputeBufferType.IndirectArguments); NativeArray <uint> indirect = new NativeArray <uint>(5, Allocator.Temp, NativeArrayOptions.ClearMemory); indirect[0] = (uint)sphereBuffer.count; indirect[1] = 1; sphereIndirectBuffer.SetData(indirect); indirect.Dispose(); }
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(); }