public static void Awake(PipelineResources resources, int resolution, int texArrayCapacity, int propertyCapacity, string mapResources) { SceneController.resolution = resolution; singletonReady = true; SceneController.resources = resources; addList = new NativeList<ulong>(10, Allocator.Persistent); baseBuffer = new PipelineBaseBuffer(); clusterResources = Resources.Load<ClusterMatResources>("MapMat/" + mapResources); int clusterCount = 0; allScenes = new List<SceneStreaming>(clusterResources.clusterProperties.Count); foreach (var i in clusterResources.clusterProperties) { clusterCount += i.clusterCount; allScenes.Add(new SceneStreaming(i)); } PipelineFunctions.InitBaseBuffer(baseBuffer, clusterResources, mapResources, clusterCount); pointerContainer = new NativeList<ulong>(clusterCount, Allocator.Persistent); commandQueue = new LoadingCommandQueue(); RenderTextureDescriptor desc = new RenderTextureDescriptor { autoGenerateMips = false, bindMS = false, colorFormat = RenderTextureFormat.ARGB32, depthBufferBits = 0, dimension = TextureDimension.Tex2DArray, enableRandomWrite = false, height = resolution, width = resolution, memoryless = RenderTextureMemoryless.None, msaaSamples = 1, vrUsage = VRTextureUsage.None, volumeDepth = texArrayCapacity, shadowSamplingMode = ShadowSamplingMode.None, sRGB = false, useMipMap = false }; commonData = new SceneCommonData { texDict = new Dictionary<string, SceneCommonData.TextureIdentifier>(), avaiableProperties = new NativeList<int>(propertyCapacity, Allocator.Persistent), avaiableTexs = new NativeList<int>(texArrayCapacity, Allocator.Persistent), texCopyBuffer = new ComputeBuffer(resolution * resolution, sizeof(int)), propertyBuffer = new ComputeBuffer(propertyCapacity, sizeof(PropertyValue)), copyTextureMat = new Material(resources.shaders.copyShader), texArray = new RenderTexture(desc), clusterMaterial = new Material(resources.shaders.clusterRenderShader), terrainMaterial = new Material(resources.shaders.terrainShader), terrainDrawStreaming = new TerrainDrawStreaming(100, 16, resources.shaders.terrainCompute) }; for (int i = 0; i < propertyCapacity; ++i) { commonData.avaiableProperties.Add(i); } for (int i = 0; i < texArrayCapacity; ++i) { commonData.avaiableTexs.Add(i); } }
public void Awake(MonoBehaviour behavior) { current = this; addList = new NativeList <ulong>(10, Allocator.Persistent); this.behavior = behavior; baseBuffer = new PipelineBaseBuffer(); clusterResources = Resources.Load <ClusterMatResources>("MapMat/" + mapResources); int clusterCount = 0; allScenes = new List <SceneStreaming>(clusterResources.clusterProperties.Count); foreach (var i in clusterResources.clusterProperties) { clusterCount += i.clusterCount; allScenes.Add(new SceneStreaming(i)); } PipelineFunctions.InitBaseBuffer(baseBuffer, clusterResources, mapResources, clusterCount); pointerContainer = new NativeList <ulong>(clusterCount, Allocator.Persistent); commandQueue = new LoadingCommandQueue(); RenderTextureDescriptor desc = new RenderTextureDescriptor { autoGenerateMips = false, bindMS = false, colorFormat = RenderTextureFormat.ARGB32, depthBufferBits = 0, dimension = TextureDimension.Tex2DArray, enableRandomWrite = false, height = resolution, width = resolution, memoryless = RenderTextureMemoryless.None, msaaSamples = 1, vrUsage = VRTextureUsage.None, volumeDepth = texArrayCapacity, shadowSamplingMode = ShadowSamplingMode.None, sRGB = false, useMipMap = false }; commonData = new SceneCommonData { texDict = new Dictionary <string, SceneCommonData.TextureIdentifier>(), avaiableProperties = new NativeList <int>(propertyCapacity, Allocator.Persistent), avaiableTexs = new NativeList <int>(texArrayCapacity, Allocator.Persistent), texCopyBuffer = new ComputeBuffer(resolution * resolution, sizeof(int)), propertyBuffer = new ComputeBuffer(propertyCapacity, sizeof(PropertyValue)), copyTextureMat = new Material(RenderPipeline.current.resources.copyShader), texArray = new RenderTexture(desc), clusterMaterial = new Material(RenderPipeline.current.resources.clusterRenderShader), terrainMaterial = new Material(RenderPipeline.current.resources.terrainShader), terrainDrawStreaming = new TerrainDrawStreaming(100, 16, RenderPipeline.current.resources.terrainCompute) }; commonData.clusterMaterial.SetBuffer(ShaderIDs._PropertiesBuffer, commonData.propertyBuffer); commonData.clusterMaterial.SetTexture(ShaderIDs._MainTex, commonData.texArray); commonData.copyTextureMat.SetVector("_TextureSize", new Vector4(resolution, resolution)); commonData.copyTextureMat.SetBuffer("_TextureBuffer", commonData.texCopyBuffer); for (int i = 0; i < propertyCapacity; ++i) { commonData.avaiableProperties.Add(i); } for (int i = 0; i < texArrayCapacity; ++i) { commonData.avaiableTexs.Add(i); } testNodeArray = new NativeList <ulong>(terrainTransforms.Length, Allocator.Persistent); foreach (var i in terrainTransforms) { TerrainQuadTree.QuadTreeNode *testNode = (TerrainQuadTree.QuadTreeNode *)UnsafeUtility.Malloc(sizeof(TerrainQuadTree.QuadTreeNode), 16, Allocator.Persistent); testNode->listPosition = -1; ref TerrainPanel panel = ref testNode->panel; if (i.localScale.x > 1.1f) { panel.edgeFlag = 0; } else { panel.edgeFlag = 15; } panel.extent = i.localScale * 0.5f; panel.position = i.position; panel.textureIndex = 0; panel.heightMapIndex = 0; testNodeArray.Add((ulong)testNode); }