Exemple #1
0
        protected override void Start()
        {
            base.Start();

            int tileSize = Cache.GetStorage(0).TileSize;

            if (m_orthoCPUProducer != null && m_orthoCPUProducer.GetTileSize(0) != tileSize)
            {
                throw new InvalidParameterException("ortho CPU tile size must match ortho tile size");
            }

            GPUTileStorage storage = Cache.GetStorage(0) as GPUTileStorage;

            if (storage == null)
            {
                throw new InvalidStorageException("Storage must be a GPUTileStorage");
            }

            m_uniforms = new OrthoUniforms();

            m_noise = new PerlinNoise(m_seed);

            m_residueTex            = new Texture2D(tileSize, tileSize, TextureFormat.ARGB32, false);
            m_residueTex.wrapMode   = TextureWrapMode.Clamp;
            m_residueTex.filterMode = FilterMode.Point;

            CreateOrthoNoise();
        }
        protected override void Start()
        {
            base.Start();

            m_uniforms = new NormalUniforms();

            int tileSize          = Cache.GetStorage(0).TileSize;
            int elevationTileSize = m_elevationProducer.Cache.GetStorage(0).TileSize;

            if (tileSize != elevationTileSize)
            {
                throw new InvalidParameterException("Tile size must equal elevation tile size");
            }

            if (Border != m_elevationProducer.Border)
            {
                throw new InvalidParameterException("Border size must be equal to elevation border size");
            }

            GPUTileStorage storage = Cache.GetStorage(0) as GPUTileStorage;

            if (storage == null)
            {
                throw new InvalidStorageException("Storage must be a GPUTileStorage");
            }
        }
        protected override void Start()
        {
            base.Start();

            int tileSize = Cache.GetStorage(0).TileSize;

            if ((tileSize - Border * 2 - 1) % (World.GridResolution - 1) != 0)
            {
                throw new InvalidParameterException("Tile size - border*2 - 1 must be divisible by grid mesh resolution - 1");
            }

            if (m_residualProducer != null && m_residualProducer.GetTileSize(0) != tileSize)
            {
                throw new InvalidParameterException("Residual tile size must match elevation tile size");
            }

            GPUTileStorage storage = Cache.GetStorage(0) as GPUTileStorage;

            if (storage == null)
            {
                throw new InvalidStorageException("Storage must be a GPUTileStorage");
            }

            if (storage.FilterMode != FilterMode.Point)
            {
                throw new InvalidParameterException("GPUTileStorage filter must be point. There will be seams in the terrain otherwise");
            }

            if (m_residualProducer != null)
            {
                m_residualTex                   = new RenderTexture(tileSize, tileSize, 0, RenderTextureFormat.RFloat);
                m_residualTex.wrapMode          = TextureWrapMode.Clamp;
                m_residualTex.filterMode        = FilterMode.Point;
                m_residualTex.enableRandomWrite = true;
                m_residualTex.Create();

                m_residualBuffer = new ComputeBuffer(tileSize * tileSize, sizeof(float));
            }

            m_uniforms = new ElevationUniforms();
            m_noise    = new PerlinNoise(m_seed);

            CreateDemNoise();
        }