protected override void CreateMap()
        {
            m_currentType = m_landformType;

            Texture2D landformMap = new Texture2D(m_width, m_height);

            for (int y = 0; y < m_height; y++)
            {
                for (int x = 0; x < m_width; x++)
                {
                    Vector2 d1;
                    Vector3 d2;
                    GetDerivatives(x, y, out d1, out d2);

                    float landform = 0;
                    Color color    = Color.white;

                    switch (m_landformType)
                    {
                    case LANDFORM_TYPE.GAUSSIAN:
                        landform = GaussianLandform(d1.x, d1.y, d2.x, d2.y, d2.z);
                        color    = Colorize(landform, 0, true);
                        break;

                    case LANDFORM_TYPE.SHAPE_INDEX:
                        landform = ShapeIndexLandform(d1.x, d1.y, d2.x, d2.y, d2.z);
                        color    = Colorize(landform, 0, true);
                        break;

                    case LANDFORM_TYPE.ACCUMULATION:
                        landform = AccumulationLandform(d1.x, d1.y, d2.x, d2.y, d2.z);
                        color    = Colorize(landform, 0, true);
                        break;
                    }
                    ;


                    landformMap.SetPixel(x, y, color);
                }
            }

            landformMap.Apply();
            m_material.mainTexture = landformMap;
        }
Exemplo n.º 2
0
        public override float4[] CreateMap()
        {
            m_currentType = m_landformType;

            float4[] map = new float4[width * height];

            for (int y = 0; y < height; y++)
            {
                for (int x = 0; x < width; x++)
                {
                    float2 d1;
                    float3 d2;
                    GetDerivatives(x, y, out d1, out d2);

                    float  landform = 0;
                    float4 color    = white;

                    switch (m_landformType)
                    {
                    case LANDFORM_TYPE.GAUSSIAN:
                        landform = GaussianLandform(d1.x, d1.y, d2.x, d2.y, d2.z);
                        color    = Colorize(landform, 0, true);
                        break;

                    case LANDFORM_TYPE.SHAPE_INDEX:
                        landform = ShapeIndexLandform(d1.x, d1.y, d2.x, d2.y, d2.z);
                        color    = Colorize(landform, 0, true);
                        break;

                    case LANDFORM_TYPE.ACCUMULATION:
                        landform = AccumulationLandform(d1.x, d1.y, d2.x, d2.y, d2.z);
                        color    = Colorize(landform, 0, true);
                        break;
                    }
                    ;

                    map[x + y * width] = color;
                }
            }

            return(map);
        }