Exemplo n.º 1
0
    private Texture2D RenderNorm(IModule module)
    {
        RendererNormal render = new RendererNormal();

        switch ((MAPTYPE)popMapTypes)
        {
        case MAPTYPE.Cylindirical:
            NoiseMapBuilderCylinder buildCylindirical = new NoiseMapBuilderCylinder(textureWidth, textureHeight);
            buildCylindirical.SetBounds(lowerXBound, upperXBound, lowerZBound, upperZBound);
            buildCylindirical.Build(module);
            render.SourceNoiseMap = buildCylindirical.Map;
            break;

        case MAPTYPE.Spherical:
            NoiseMapBuilderSphere buildSpherical = new NoiseMapBuilderSphere(textureWidth, textureHeight);
            buildSpherical.SetBounds(lowerXBound, upperXBound, lowerZBound, upperZBound);
            buildSpherical.Build(module);
            render.SourceNoiseMap = buildSpherical.Map;
            break;

        case MAPTYPE.Planar:
            NoiseMapBuilderPlane buildPlanar = new NoiseMapBuilderPlane(textureWidth, textureHeight);
            buildPlanar.SetBounds(lowerXBound, upperXBound, lowerZBound, upperZBound);
            buildPlanar.Build(module);
            render.SourceNoiseMap = buildPlanar.Map;
            break;

        default:
            break;
        }

        render.BumpHeight = bumpHeight;
        render.Render();
        return(render.GetTexture());
    }
Exemplo n.º 2
0
    // Use this for initialization
    void Start()
    {
        IModule module = new Perlin();
        NoiseMapBuilderSphere heightMap = new NoiseMapBuilderSphere(512, 256);

        heightMap.SetBounds(-90.0, 90.0, -180.0, 180.0);
        heightMap.Build(module);
        RendererImage render = new RendererImage();

        render.SourceNoiseMap = heightMap.Map;
        render.ClearGradient();
        render.AddGradientPoint(-1.0000, new Color32(0, 0, 128, 255));      // deeps
        render.AddGradientPoint(-0.2500, new Color32(0, 0, 255, 255));      // shallow
        render.AddGradientPoint(0.0000, new Color32(0, 128, 255, 255));     // shore
        render.AddGradientPoint(0.0625, new Color32(240, 240, 64, 255));    // sand
        render.AddGradientPoint(0.1250, new Color32(32, 160, 0, 255));      // grass
        render.AddGradientPoint(0.3750, new Color32(224, 224, 0, 255));     // dirt
        render.AddGradientPoint(0.7500, new Color32(128, 128, 128, 255));   // rock
        render.AddGradientPoint(1.0000, new Color32(255, 255, 255, 255));   // snow
        render.IsLightEnabled  = true;
        render.LightContrast   = 3.0;
        render.LightBrightness = 2.0;
        render.Render();
        tex = render.GetTexture();
    }
Exemplo n.º 3
0
    private Texture2D RenderTex(IModule module)
    {
        switch ((MAPTYPE)popMapTypes)
        {
        case MAPTYPE.Cylindirical:
            NoiseMapBuilderCylinder buildCylindirical = new NoiseMapBuilderCylinder(textureWidth, textureHeight);
            buildCylindirical.SetBounds(lowerXBound, upperXBound, lowerZBound, upperZBound);
            buildCylindirical.Build(module);
            render.SourceNoiseMap = buildCylindirical.Map;
            break;

        case MAPTYPE.Spherical:
            NoiseMapBuilderSphere buildSpherical = new NoiseMapBuilderSphere(textureWidth, textureHeight);
            buildSpherical.SetBounds(lowerXBound, upperXBound, lowerZBound, upperZBound);
            buildSpherical.Build(module);
            render.SourceNoiseMap = buildSpherical.Map;
            break;

        case MAPTYPE.Planar:
            NoiseMapBuilderPlane buildPlanar = new NoiseMapBuilderPlane(textureWidth, textureHeight);
            buildPlanar.SetBounds(lowerXBound, upperXBound, lowerZBound, upperZBound);
            buildPlanar.IsSeamless = seamlessEnabled;
            buildPlanar.Build(module);
            render.SourceNoiseMap = buildPlanar.Map;
            break;

        default:
            break;
        }

        ImageMap backMap = null;

        if (backgroundTexture != null)
        {
            backMap = new ImageMap(backgroundTexture, Color.gray);
        }

        if (backMap != null)
        {
            render.BackgroundImage = backMap;
        }

        render.IsWrapEnabled   = wrapEnabled;
        render.IsLightEnabled  = lightEnabled;
        render.LightContrast   = lightContrast;
        render.LightAzimuth    = lightAzimuth;
        render.LightBrightness = lightBrightness;
        render.LightColor      = lightColor;
        render.LightContrast   = lightContrast;
        render.LightElev       = lightElevation;
        render.LightIntensity  = lightIntensity;
        render.Render();
        return(render.GetTexture());
    }