public override void Update(float dt) { if ((Game1.Instance.last_mouse_state.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Pressed) && (Game1.Instance.current_mouse_state.LeftButton == Microsoft.Xna.Framework.Input.ButtonState.Released)) { for (int i = 0; i < Buttons.Length; i++) { if (Buttons[i].Contains(Game1.Instance.current_mouse_state.X, Game1.Instance.current_mouse_state.Y)) { switch (i) { case 0: { zoom -= 0.05f; m_noiseMap.GeneratePlanar(-1 * zoom, 1 * zoom, -1 * zoom, 1 * zoom); m_textures[3] = m_noiseMap.GetTexture(m_graphics, Gradient.Terrain); } break; case 1: { zoom += 0.05f; m_noiseMap.GeneratePlanar(-1 * zoom, 1 * zoom, -1 * zoom, 1 * zoom); m_textures[3] = m_noiseMap.GetTexture(m_graphics, Gradient.Terrain); } break; } } } } }
public Texture2D GetCloudBase(UnityEngine.Gradient cloudGradient, int size, NoiseType type) { ModuleBase Generator = GetModule(type); //Billow Generator = new Billow( // 1f, // 2f, // 0.5f, // 6, // Random.Range(0, int.MaxValue), // QualityMode.Low); Noise2D map = new Noise2D(size, size / 2, Generator); map.GenerateSpherical( south, north, west, east); var tex = map.GetTexture(cloudGradient); tex.Apply(); return(tex); }
void Generate() { Perlin myPerlin = new Perlin(); ModuleBase myModule = myPerlin; // generates a heightmap to a texture, // and sets the renderer material texture of a cube to the generated texture Noise2D heightMap; heightMap = new Noise2D(mapX, mapY, myModule); heightMap.GeneratePlanar( sampleOffsetX, sampleOffsetX + sampleSizeX, sampleOffsetY, sampleOffsetY + sampleSizeY ); texture = heightMap.GetTexture(GradientPresets.Grayscale); GetComponent <Renderer>().material.mainTexture = texture; }
void GenerateOwnBlend() { ModuleBase perlin = new Perlin(1, 2, .5, 6, 42, QualityMode.Medium); ModuleBase voronoi = new Voronoi(Frequency, Displacement, 42, true); //ModuleBase blend = new Add(perlin, voronoi); Curve curve = new Curve(perlin); foreach (var point in Acurve.keys) { curve.Add(point.time, point.value); } //curve.Add(0d, .1d); //curve.Add(.5d, .5d); //curve.Add(1.9d, .9d); var perlinbuilder = new Noise2D(Size, Size / 2, perlin); perlinbuilder.GeneratePlanar(_left, _right, _top, _bottom); var voronoibuilder = new Noise2D(Size, Size / 2, voronoi); voronoibuilder.GeneratePlanar(_left, _right, _top, _bottom); var blendbuilder = new Noise2D(Size, Size / 2, curve); blendbuilder.GeneratePlanar(_left, _right, _top, _bottom); Perlin.material.SetTexture("_BaseMap", perlinbuilder.GetTexture(_gradient)); Voronoi.material.SetTexture("_BaseMap", voronoibuilder.GetTexture(_gradient)); Mix.material.SetTexture("_BaseMap", blendbuilder.GetTexture(_gradient)); }
public byte[] CreateSphericalPerlinTexture() { /* * Generate a spherical texture2D of perlin noise */ int mapX = 512; int mapY = 256; float south = -90.0f; float north = 90.0f; float west = -180.0f; float east = 180.0f; Perlin myPerlin = new Perlin(); ModuleBase myModule = myPerlin; Noise2D heightMap; heightMap = new Noise2D(mapX, mapY, myModule); heightMap.GenerateSpherical(south, north, west, east); texture = heightMap.GetTexture(LibNoise.Unity.Gradient.Grayscale); byte[] bytes = texture.EncodeToPNG(); return(bytes); }
public void CreateSphericalPerlinTexture(ref byte[] height, ref byte[] normal) { /* * Generate a spherical mapping of a height and normal map */ int mapX = 512; int mapY = 256; float south = -90.0f; float north = 90.0f; float west = -180.0f; float east = 180.0f; Perlin myPerlin = new Perlin(); Texture2D heightTexture, normalTexture; ModuleBase myModule = myPerlin; Noise2D heightMap; heightMap = new Noise2D(mapX, mapY, myModule); heightMap.GenerateSpherical(south, north, west, east); /* Get the heightMap, which is just a grayscale of the texture */ heightTexture = heightMap.GetTexture(LibNoise.Unity.Gradient.Grayscale); height = heightTexture.EncodeToPNG(); /* Get the normal map. */ normalTexture = heightMap.GetNormalMap(0); normal = normalTexture.EncodeToPNG(); //SAVE THE PICTURE SaveTexture(heightTexture); }
// Other Functions // ---------------------------------------------------------------------------- void Generate() { Perlin myPerlin = new Perlin(); ModuleBase myModule = myPerlin; // ------------------------------------------------------------------------------------------ // - Generate - // this part generates the heightmap to a texture, // and sets the renderer material texture of a cube to the generated texture Noise2D heightMap; heightMap = new Noise2D(mapSizeX, mapSizeY, myModule); heightMap.GeneratePlanar( sampleOffsetX, sampleOffsetX + sampleSizeX, sampleOffsetY, sampleOffsetY + sampleSizeY ); texture = heightMap.GetTexture(grad); texture.Apply(); cubeRenderer.material.SetTexture("_BaseMap", texture); }
public void Generate(PlanetProfile profile) { Noise2D noise = new Noise2D( mapSize, mapSize / 2, profile.graph.GetGenerator(profile.GetArguments())); noise.GenerateSpherical( south, north, west, east); ColorMap = new Texture2D( mapSize, (int)(mapSize / 2f)); ColorMap = noise.GetTexture(profile.ColorGradient); ColorMap.Apply(); HeightMap = noise.GetTexture(profile.ElevationGradient); HeightMap.Apply(); ////mapSize = 32; //imgs = new List<Texture2D>(); //List<ModuleBase> generators = new List<ModuleBase>(); //generators.Add(GetModule(profile)); //// TODO USE A HEIGHTMAP THAT HAS THE SAME AMOUNT OF PXL THAN VERTICES //// e.g : 80 * 80 //// if the map is 512 -> we get to have 6.4 planet's heightmap for the cost of a single map //Noise2D map = new Noise2D(mapSize, mapSize / 2, generators[0]); //map.GenerateSpherical( // south, // north, // west, // east); //ColorMap = map.GetTexture(profile.ColorMap); //ColorMap.Apply(); //HeightMap = map.GetTexture(profile.ElevationMap); //HeightMap.Apply(); }
void RenderAndSetImage(ModuleBase generator) { var heightMapBuilder = new Noise2D(256, 256, generator); heightMapBuilder.GeneratePlanar(_left, _right, _top, _bottom); var image = heightMapBuilder.GetTexture(_gradient); renderer.material.mainTexture = image; }
private void UpdateTexture() { texture.Resize(resolution.x, resolution.y); texture.wrapModeU = wrapModeU; texture.wrapModeV = wrapModeV; texture.alphaIsTransparency = true; texture.name = "Noise_" + name; if (seed == 0) { seed = Random.Range(int.MinValue, int.MaxValue); } ModuleBase noiseGenerator; switch (noiseType) { case NoiseType.Billow: Billow billow = new Billow(frequency, lacunarity, persistence, octaves, seed, QualityMode.High); noiseGenerator = billow; break; case NoiseType.RidgedMultifractal: RidgedMultifractal ridgedMultifractal = new RidgedMultifractal(frequency, lacunarity, octaves, seed, QualityMode.High); noiseGenerator = ridgedMultifractal; break; case NoiseType.Voronoi: Voronoi voronoi = new Voronoi(frequency, displacement, seed, distance); noiseGenerator = voronoi; break; default: //Default to perlin so the compiled doesn't complain Perlin perlin = new Perlin(frequency, lacunarity, persistence, octaves, seed, QualityMode.High); noiseGenerator = perlin; break; } Noise2D noiseMap = new Noise2D(resolution.x, resolution.y, noiseGenerator); noiseMap.GeneratePlanar( offset.x + -1 * 1 / zoom.x, offset.x + offset.x + 1 * 1 / zoom.x, offset.y + -1 * 1 / zoom.y, offset.y + 1 * 1 / zoom.y, isSeamless ); Texture2D noiseTexture = noiseMap.GetTexture(colorGradient); Color32[] colorArray = noiseTexture.GetPixels32(); texture.SetPixels32(0, 0, texture.width, texture.height, colorArray); texture.Apply(); AssetDatabase.ImportAsset(AssetDatabase.GetAssetPath(texture)); EditorUtility.SetDirty(this); }
// Other Functions // ---------------------------------------------------------------------------- void Generate() { Perlin myPerlin = new Perlin(); ModuleBase myModule = myPerlin; // ------------------------------------------------------------------------------------------ // - Generate - // this part generates the heightmap to a texture, // and sets the renderer material texture of a cube to the generated texture Noise2D heightMap; heightMap = new Noise2D(mapSizeX, mapSizeY, myModule); heightMap.GeneratePlanar( sampleOffsetX, sampleOffsetX + sampleSizeX, sampleOffsetY, sampleOffsetY + sampleSizeY ); //Debug.Log(cubeRenderer.material.mainTexture.name); texture = heightMap.GetTexture(LibNoise.Unity.Gradient.Grayscale); cubeRenderer.material.mainTexture = texture; //cubeRenderer.material.SetTexture("MainTexture", texture); texture.name = "noise"; asteroidMaterial.mainTexture = texture; GetComponent <Renderer>().material.mainTexture = texture; GetComponent <Renderer>().material.SetTexture("_MainTexture", texture); /* * * mat.mainTexture = tex; * cubeRenderer.material = mat; * * * cubeRenderer.material.mainTexture = tex; * cubeRenderer.material.mainTexture.wrapMode = TextureWrapMode.Clamp; * tex.wrapMode = TextureWrapMode.Clamp; * * Color[] pixels = tex.GetPixels(); * * * * cubeRenderer.material = asteroidMaterial; * asteroidMaterial.SetTexture("_MainTex", texture);*/ }
void RenderAndSetImage(ModuleBase generator) { var heightMapBuilder = new Noise2D(Width, Height, generator); heightMapBuilder.GeneratePlanar(Noise2D.Left, Noise2D.Right, Noise2D.Top, Noise2D.Bottom); // heightMapBuilder.GenerateSpherical(90, -90, -180, 180); // heightMapBuilder.GenerateCylindrical(-180, 180, -1, 1); var image = heightMapBuilder.GetTexture(); GetComponent <Renderer>().material.mainTexture = image; }
void Start() { var perlin = new Perlin(); var heightMapBuilder = new Noise2D(512, 256, perlin); heightMapBuilder.GenerateSpherical(_south, _north, _west, _east); var image = heightMapBuilder.GetTexture(_gradient); renderer.material.mainTexture = image; }
void DrawSelectedNodeDetails(NodeBase node) { if (previewNeedsUpdate || lastSelected != node) { preview = new Texture2D(230, 230); if (node.Module != null && previewCalculation == null) { previewCalculation = new NoiseCalculation(node.Module, 230, 230); } previewNeedsUpdate = false; lastSelected = node; } if (previewCalculation != null && previewCalculation.Done) { preview = previewCalculation.Noise.GetTexture(); previewCalculation = null; } var state = mainEditorState as NoiseDesignerState; EditorGUILayout.Space(); EditorGUILayout.LabelField("Selected Node:"); GUILayout.Box(preview); EditorGUILayout.Space(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Apply to terrain:"); terrain = EditorGUILayout.ObjectField("TerrainData", terrain, typeof(TerrainData), false) as TerrainData; if (GUILayout.Button("Apply")) { Noise2D noise = new Noise2D(terrain.heightmapWidth, terrain.heightmapHeight, node.Module); noise.GeneratePlanar(4.0f, 10.0f, 1.0f, 5.0f); terrain.SetHeights(0, 0, noise.GetNormalizedData()); } EditorGUILayout.Space(); EditorGUILayout.Separator(); EditorGUILayout.LabelField("Export as texture:"); state.textureSize = EditorGUILayout.Vector2Field("Texture Size", state.textureSize); if (GUILayout.Button("Save as PNG")) { var path = EditorUtility.SaveFilePanelInProject("Save as PNG", "noise", "png", ""); if (!string.IsNullOrEmpty(path)) { Noise2D noise = new Noise2D((int)state.textureSize.x, (int)state.textureSize.y, node.Module); noise.GeneratePlanar(4.0f, 10.0f, 1.0f, 5.0f); var texture = noise.GetTexture(); File.WriteAllBytes(path, texture.EncodeToPNG()); AssetDatabase.Refresh(); } } }
void RenderAndSetImage(ModuleBase generator) { var heightMapBuilder = new Noise2D(Noise.Width, Noise.Height, generator); heightMapBuilder.GeneratePlanar(Noise.xOrg, Noise.xOrg + 5, Noise.yOrg, Noise.yOrg + 5); var image = heightMapBuilder.GetTexture(Noise.Gradient); image.Apply(); image.filterMode = FilterMode.Point; Sprite sprite = Sprite.Create(image, new Rect(0, 0, 64, 64), Vector2.zero, 32, 1); transform.GetComponent <SpriteRenderer>().sprite = sprite; }
void Generate() { var generator = graph.GetGenerator(); Noise2D map = new Noise2D(size, size / 2, generator); map.GenerateSpherical( south, north, west, east); ColorMap = map.GetTexture(); ColorMap.Apply(); }
public override void Initialise(GraphicsDevice device, ContentManager content) { m_graphics = device; m_spriteBatch = new SpriteBatch(device); m_content = content; // Create the module network add = new Add(perlin, rigged); // Initialize the noise map m_noiseMap = new Noise2D(256, 256, add); m_noiseMap.GeneratePlanar(-1, 1, -1, 1); // Generate the textures m_textures[0] = m_noiseMap.GetTexture(m_graphics, Gradient.Grayscale); m_textures[1] = m_noiseMap.GetTexture(m_graphics, Gradient.Terrain); m_textures[2] = m_noiseMap.GetNormalMap(m_graphics, 3.0f); // Zoom in or out do something like this. m_noiseMap.GeneratePlanar(-1 * zoom, 1 * zoom, -1 * zoom, 1 * zoom); m_textures[3] = m_noiseMap.GetTexture(m_graphics, Gradient.Terrain); }
void Generate() { billowModule = new Billow(); offsetModule = new Translate(0, 1, 0, billowModule); myModule = new Turbulence(1, offsetModule); Noise2D heightMapBuilder = new Noise2D(terrain.Width, terrain.Height, myModule); heightMapBuilder.GenerateSpherical(-90, 90, -180, 180); weatherImage = heightMapBuilder.GetTexture(); weatherImage.Apply(); GetComponent <LODMaterial>().OurMaterial.SetTexture("_Weather", weatherImage); }
void GenerateOwnTests() { ModuleBase perlin = new Perlin(1, 2, .5, 6, seed, QualityMode.Medium); ModuleBase voronoi = new Voronoi(Frequency, Displacement, seed, true); ModuleBase add = new Add(perlin, voronoi); Terrace terrace = new Terrace(false, add); terrace.Add(0f); terrace.Add(one); terrace.Add(two); var perlinbuilder = new Noise2D(Size, Size / 2, perlin); perlinbuilder.GeneratePlanar(_left, _right, _top, _bottom); var voronoibuilder = new Noise2D(Size, Size / 2, voronoi); voronoibuilder.GeneratePlanar(_left, _right, _top, _bottom); var addbuilder = new Noise2D(Size, Size / 2, add); addbuilder.GeneratePlanar(_left, _right, _top, _bottom); var terracebuilder = new Noise2D(Size, Size / 2, terrace); terracebuilder.GeneratePlanar(_left, _right, _top, _bottom); var perlintex = perlinbuilder.GetTexture(_gradient); var voronoitex = voronoibuilder.GetTexture(_gradient); var addtex = addbuilder.GetTexture(_gradient); var terracetex = terracebuilder.GetTexture(_gradient); perlintex.Apply(); voronoitex.Apply(); addtex.Apply(); terracetex.Apply(); Perlin.material.SetTexture("_BaseMap", perlintex); Voronoi.material.SetTexture("_BaseMap", voronoitex); Mix.material.SetTexture("_BaseMap", addtex); Terrace.material.SetTexture("_BaseMap", terracetex); //Perlin.material.SetTexture("_BaseMap", perlinbuilder.GetTexture(_gradient)); //Voronoi.material.SetTexture("_BaseMap", voronoibuilder.GetTexture(_gradient)); //Mix.material.SetTexture("_BaseMap", addbuilder.GetTexture(_gradient)); //Terrace.material.SetTexture("_BaseMap", terracebuilder.GetTexture(_gradient)); }
void RenderAndSetImage(ModuleBase generator, MeshRenderer rend) { var heightMapBuilder = new Noise2D(256, 256, generator); heightMapBuilder.GeneratePlanar(_left, _right, _top, _bottom); //heightMapBuilder.GenerateSpherical( // south, // north, // west, // east); var image = heightMapBuilder.GetTexture(_gradient); rend.material.SetTexture("_BaseMap", image); }
void Update() { transform.Rotate(Vector3.down * Time.deltaTime); transform.Rotate(Vector3.left * Time.deltaTime * 1.8f); transform.Rotate(Vector3.back * Time.deltaTime * strengthAdjustment * 100); if (updatedNoiseMapAvailable) { meshRenderer.sharedMaterial.mainTexture = noiseMapTransfer.GetTexture(); ftorus.GenerateFractalTorus(modBaseTransfer, strengthAdjustment); updatedNoiseMapAvailable = false; } else if (!threadRunning) { threadRunning = true; } }
public void cavegen() { mapWidth = 64; mapHeight = 64; Vector2 centre = new Vector2(mapWidth / 2, mapHeight / 2); tiles = new TileType[mapWidth, mapHeight]; var perlin = new Perlin(); perlin.OctaveCount = _octaveCount; perlin.Frequency = _frecuency; perlin.Persistence = _persistence; perlin.Seed = UnityEngine.Random.seed; var heightMapBuilder = new Noise2D(mapHeight, mapWidth, perlin); heightMapBuilder.GeneratePlanar(_west, _east, _north, _south); var image = heightMapBuilder.GetTexture(_gradient); for (int y = 0; y < mapHeight; y++) //Starts an itteration for all y coordinates { for (int x = 0; x < mapHeight; x++) //Starts an itteration of all x coordinates for the given y coordinate { //Creates a tile at the given location double e = image.GetPixel(x, y).grayscale; tiles[x, y] = CaveTileSelector(e, x, y, mapWidth, centre); } } setWallTiles(64, 64); tiles[mapWidth / 2, mapHeight / 2] = TileType.Entrance; placeTiles(64, 64); enemyCountRange = new IntRange(0, 4); createEnemies(); mainGameLoc = new Vector2(32, 32); CurrentCamera.transform.position = new Vector3(32 * 1.28f, 32 * 1.28f, -10); nextCameraLoc = CurrentCamera.transform.position; }
private void SetWorldMap() { worldMap = new Texture2D(planarNoiseMap.Width, planarNoiseMap.Height); MapDisplay display = FindObjectOfType <MapDisplay> (); if (renderType == RenderType.Greyscale) { worldMap = planarNoiseMap.GetTexture(LibNoise.Unity.Gradient.Grayscale); } else { worldMap.SetPixels(ColorMapCreation(planarNoiseMap)); } worldMap.Apply(); display.DrawPlane(worldMap); //display.DrawPlanetMesh (OctahedronCreator.CreatePlanet (planetLOD, planetRadius, module, 0f, regions), worldMap); display.DrawMesh(planarNoiseMap, worldMap, heightMultiplier, heightCurve, editorPreviewLOD); }
public MakePerlin(float seed) { perlin = new Texture2D(256, 256); ModuleBase moduleBase; moduleBase = new Perlin(m_frequency, m_lacunarity, m_persistence, m_octaveCount, (int)seed, m_quality); noiseMap = new Noise2D(perlin.width, perlin.height, moduleBase); float zoom = 1f; float offset = 0f; noiseMap.GeneratePlanar( offset + -1 * 1 / zoom, offset + offset + 1 * 1 / zoom, offset + -1 * 1 / zoom, offset + 1 * 1 / zoom); perlin = noiseMap.GetTexture(); }
//function to create a new world. public void NewWorld() { //Sets up the perlin instance as defined above. var perlin = new Perlin(); //Creates a new instance of perlin noise perlin.OctaveCount = _octaveCount; //Sets the octave count perlin.Frequency = _frecuency; //Sets the frquency perlin.Persistence = _persistence; //Sets the persistence perlin.Seed = GetLevelSeed(); //Sets the seed for the world. //If the seed entry was left blank generate a random seed. if (perlin.Seed == 0) { perlin.Seed = UnityEngine.Random.seed; //Gets and sets the random seed. } var heightMapBuilder = new Noise2D(mapHeight, mapWidth, perlin); //Screates an instance of the heightmap builder from the perlin noise heightMapBuilder.GeneratePlanar(_west, _east, _north, _south); //Generates a planar image. var image = heightMapBuilder.GetTexture(_gradient); //Makes the colour range of the heighmap too be grayscale and exports it as an image //Will assign a sprite to each x and y value for (int y = 0; y < mapHeight; y++) //Starts an itteration for all y coordinates { for (int x = 0; x < mapHeight; x++) //Starts an itteration of all x coordinates for the given y coordinate { //Creates a tile at the given location double e = image.GetPixel(x, y).grayscale; //Gets the greyscale value of the given pixel map[x, y] = TileSelector(e, x, y, mapWidth, centre); //Selects a tile based upon the height value of the pixel } } mainGameLoc = new Vector2(128, 128); //Sets the main game location to be the centre of the map. CurrentCamera.transform.position = new Vector3(128 * 1.28f, 128 * 1.28f, -10); //Sets the camera lcoation to be the centre of the map. nextCameraLoc = CurrentCamera.transform.position; //Sets the next loaction of the camera to be the current as it is not moving. SaveWorld(); //Saves the newly generated world. }
private Texture2D GetMapTexture(RenderType typeIn, Noise2D noiseIn) { Texture2D mapReturned; Color[] colorMap = new Color[noiseIn.Width * noiseIn.Height]; mapReturned = new Texture2D(noiseIn.Width, noiseIn.Height); if (typeIn == RenderType.Greyscale) { mapReturned = noiseIn.GetTexture(); } else { for (int y = 0; y < noiseIn.Height; y++) { for (int x = 0; x < noiseIn.Width; x++) { float currentHeight = noiseIn[x, y]; for (int i = 0; i < regions.Length; i++) { if (currentHeight <= regions[i].height) { if ((i == 0) || (i == regions.Length - 1)) { colorMap[y * noiseIn.Width + x] = regions[i].color; break; } else { colorMap[y * noiseIn.Width + x] = Color.Lerp(regions[i - 1].color, regions[i].color, (float)(currentHeight - regions[i].height) / (float)(regions[i + 1].height - regions[i].height)); break; } } } } } mapReturned.SetPixels(colorMap); } mapReturned.Apply(); mapReturned.filterMode = FilterMode.Point; return(mapReturned); }
void Start() { var perlin = new Perlin(); // Unlike on the base LibNoise tutorial, we don't have a separate heightMap target // to set - we will instead build it after. We also initialize the resulting size // on the constructor instead of passing a separate destination size. var heightMapBuilder = new Noise2D(256, 256, perlin); heightMapBuilder.GeneratePlanar(_left, _right, _top, _bottom); // Get the image var image = heightMapBuilder.GetTexture(_gradient); // Set it. It may appear inverted from the example on the LibNoise site depending // on the angle at which the object is rotated/viewed. GetComponent <Renderer>().material.mainTexture = image; // We don't do the light changes for the texture, since that's beyond the scope of // this port }
// Other Functions // ---------------------------------------------------------------------------- void Generate() { //Perlin mySphere = new Perlin(); // ------------------------------------------------------------------------------------------ // - Compiled Terrain - ModuleBase myModule; myModule = Generator.LibnoiseModualGen.GetRTSGenerator(1); // ------------------------------------------------------------------------------------------ // - Generate - // this part generates the heightmap to a texture, // and sets the renderer material texture of a sphere to the generated texture Noise2D heightMap; heightMap = new Noise2D(mapSizeX, mapSizeY, myModule); heightMap.GenerateSpherical(south, north, west, east); texture = heightMap.GetTexture(GradientPresets.Grayscale); /// #if !UNITY_WEBPLAYER byte[] bytes = texture.EncodeToPNG(); File.WriteAllBytes(Application.dataPath + "/Terain/TextureGenOutput/sphere/" + TextureName + ".png", bytes); #endif /// sphereRenderer.material.mainTexture = texture; }
private void GenerateTexture() { if (!_node) { return; } var noise = _node.GetResult(); if (noise == null) { return; } var noiseRenderer = new Noise2D(PreviewSize, noise); noiseRenderer.GeneratePlanar(-1, 1, -1, 1); var texture = noiseRenderer.GetTexture(); var renderer = GetComponentInChildren <Renderer>(); renderer.material.SetTexture("_MainTex", texture); }
public void Generate() { ModuleBase myModule = new Perlin(frequency, lacunarity, persistence, octaves, seed, quality); Noise2D heightMapBuilder = new Noise2D(width, height, myModule); heightMapBuilder.GenerateSpherical(south, north, west, east); LibNoiseGradient g = new LibNoiseGradient(gradient.colorKeys[0].color); foreach (var col in gradient.colorKeys) { g[col.time] = col.color; } image = heightMapBuilder.GetTexture(g); image.filterMode = imageFilterMode; image.wrapMode = imageWrapMode; image.Apply(); GetComponent <LODMaterial>().OurMaterial.mainTexture = image; }