private void Awake()
        {
            if (singleton)
            {
                Debug.LogError("Render Pipeline should be Singleton!");
                DestroyImmediate(gameObject);
                return;
            }
            data.buffer = new CommandBuffer();
            DontDestroyOnLoad(this);
            singleton            = this;
            data.arrayCollection = new RenderArray(true);
            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.name, i.clusterCount));
            }
            PipelineFunctions.InitBaseBuffer(ref data.baseBuffer, clusterResources, mapResources, clusterCount);
            allEvents = new List <PipelineEvent>(GetComponentsInChildren <PipelineEvent>());
            foreach (var i in allEvents)
            {
                i.InitEvent(resources);
            }
            SceneStreaming.pointerContainer = new NativeList <ulong>(clusterCount, Allocator.Persistent);
            SceneStreaming.commandQueue     = new LoadingCommandQueue();
        }
        private void Awake()
        {
            if (initialized)
            {
                Debug.LogError("Should Be Singleton!");
                Destroy(gameObject);
                return;
            }
            initialized      = true;
            nullValue        = current;
            current          = this;
            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.name, i.clusterCount));
            }
            PipelineFunctions.InitBaseBuffer(baseBuffer, clusterResources, mapResources, clusterCount);
            SceneStreaming.pointerContainer = new NativeList <ulong>(clusterCount, Allocator.Persistent);
            SceneStreaming.commandQueue     = new LoadingCommandQueue();
        }
        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);
            }
        }
Exemple #4
0
        public static void Awake(PipelineResources resources)
        {
            int maximumClusterCount        = 0;
            ClusterMatResources clusterRes = resources.clusterResources;

            if (Application.isPlaying && clusterRes)
            {
                clusterRes.Init(resources);
                maximumClusterCount = clusterRes.maximumClusterCount;
            }
            singletonReady            = true;
            SceneController.resources = resources;
            addList    = new NativeList <ulong>(10, Allocator.Persistent);
            baseBuffer = new PipelineBaseBuffer();
            PipelineFunctions.InitBaseBuffer(baseBuffer, maximumClusterCount);
        }
        public static void Awake(PipelineResources resources, string mapResources)
        {
            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);
        }
        public static void Awake(PipelineResources resources, ClusterMatResources mapResources)
        {
            singletonReady            = true;
            SceneController.resources = resources;
            addList          = new NativeList <ulong>(10, Allocator.Persistent);
            baseBuffer       = new PipelineBaseBuffer();
            clusterResources = mapResources;
            int clusterCount = 0;

            if (clusterResources)
            {
                allScenes = new List <SceneStreaming>(clusterResources.clusterProperties.Count);

                for (int i = 0; i < clusterResources.clusterProperties.Count; ++i)
                {
                    var cur = clusterResources.clusterProperties[i];
                    clusterCount += cur.clusterCount;
                    allScenes.Add(new SceneStreaming(cur, i));
                }
            }
            PipelineFunctions.InitBaseBuffer(baseBuffer, clusterCount);
        }
Exemple #7
0
        public static void Awake(PipelineResources resources, int resolution, int texArrayCapacity, int lightmapResolution, int lightmapCapacity, 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);
            RenderTextureDescriptor desc = new RenderTextureDescriptor
            {
                autoGenerateMips   = false,
                bindMS             = false,
                colorFormat        = RenderTextureFormat.ARGB32,
                depthBufferBits    = 0,
                dimension          = TextureDimension.Tex2DArray,
                enableRandomWrite  = true,
                height             = resolution,
                width              = resolution,
                memoryless         = RenderTextureMemoryless.None,
                msaaSamples        = 1,
                vrUsage            = VRTextureUsage.None,
                volumeDepth        = texArrayCapacity,
                shadowSamplingMode = ShadowSamplingMode.None,
                sRGB      = false,
                useMipMap = false
            };
        }
        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);
            }
Exemple #9
0
 //Initialized In Every Scene
 public void InitScene()
 {
     data.arrayCollection = new RenderArray(true);
     PipelineFunctions.InitBaseBuffer(ref data.baseBuffer);
 }