public override Texture2D GenerateTexture() { if (!IsShaderInit) { return(Texture2D.whiteTexture); } if (!Dirty) { return(HasTexture ? Texture : GenerateTexture()); } NoiseNode inputNoise = GetInputValue <NoiseNode>("input"); if (inputNoise == null) { return(Texture2D.whiteTexture); } Texture2D inputTexture = inputNoise.Texture == null?inputNoise.GenerateTexture() : inputNoise.Texture; Material noiseMaterial = new Material(shader); noiseMaterial.SetTexture("_Texture", inputTexture); noiseMaterial.SetFloat("_Threshold", threshold); Texture = TextureMaker.Generate(GetGraph.mapSize, noiseMaterial); GetPort(nameof(output))?.GetConnections()?.ForEach(f => ((NoiseNode)f.node)?.SetTextureDirty()); Dirty = false; return(Texture); }
public override Texture2D GenerateTexture() { if (!IsShaderInit) { return(Texture2D.whiteTexture); } if (!Dirty) { return(HasTexture ? Texture : GenerateTexture()); } Material noiseMaterial = new Material(shader); noiseMaterial.SetFloat("_X", offset.x); noiseMaterial.SetFloat("_Y", offset.y); noiseMaterial.SetFloat("_Scale", scale); noiseMaterial.SetInt("_Fractal", fractal); noiseMaterial.SetFloat("_Ratio", GetGraph.Ratio); Texture = TextureMaker.Generate(GetGraph.mapSize, noiseMaterial); GetPort(nameof(output))?.GetConnections()?.ForEach(f => ((NoiseNode)f.node)?.SetTextureDirty()); Dirty = false; return(Texture); }
public static void Wish(Match match = null) { Utilities.Logger.Log("Wish invoked: Fliptile"); var player = IComponent <GameObject> .ThePlayer; if (player != null && player.pPhysics != null) { try { Cell cell = player.pPhysics.PickDestinationCell( Range: 999, Vis: AllowVis.OnlyExplored, Locked: false, Style: PickTarget.PickStyle.EmptyCell); if (cell != null) { GameObject target = cell.GetHighestRenderLayerObject(); if (target == null) { Popup.Show("There's no object in that spot."); return; } TextureMaker.FlipGameObjectTexture(target); } } catch (Exception ex) { QudUX.Utilities.Logger.Log($"(Error) Failed to process Fliptile wish.\nException Details:\n{ex.ToString()}"); } } }
public override Texture2D GetTexture() { shader = Shader.Find("Noise/Invert"); Material noiseMaterial = new Material(shader); noiseMaterial.SetTexture("_Texture", ((NoiseNode)GetPort(nameof(input)).Connection.node).GetTexture()); return(TextureMaker.Generate(GetGraph.mapSize, noiseMaterial)); }
public override Texture2D GetTexture() { shader = Shader.Find("Noise/Gradient"); Material noiseMaterial = new Material(shader); noiseMaterial.SetVector("_Pos", new Vector4(start.x, start.y, end.x, end.y)); noiseMaterial.SetInt("_Mode", (int)mode); return(TextureMaker.Generate(GetGraph.mapSize, noiseMaterial)); }
public static void Wish(Match match = null) { Utilities.Logger.Log("Attempting to remove QudUX object parts to prepare for safe uninstall..."); var player = XRLCore.Core?.Game?.Player?.Body; if (player != null) { try { Zone parentZone = player.CurrentCell.ParentZone; for (int i = 0; i < parentZone.Width; i++) { for (int j = 0; j < parentZone.Height; j++) { foreach (GameObject thing in parentZone.GetCell(i, j).GetObjectsWithPart("Physics")) { if (thing.HasPart(typeof(QudUX_AutogetHelper))) { thing.RemovePart <QudUX_AutogetHelper>(); } if (thing.HasPart(typeof(QudUX_CommandListener))) { thing.RemovePart <QudUX_CommandListener>(); } if (thing.HasPart(typeof(QudUX_ConversationHelper))) { thing.RemovePart <QudUX_ConversationHelper>(); } if (thing.HasPart(typeof(QudUX_InventoryScreenState))) { thing.RemovePart <QudUX_InventoryScreenState>(); } if (thing.HasPart(typeof(QudUX_LegendaryInteractionListener))) { thing.RemovePart <QudUX_LegendaryInteractionListener>(); } if (thing.HasEffect <QudUX_QuestGiverVision>()) { thing.RemoveEffect(typeof(QudUX_QuestGiverVision)); } TextureMaker.UnflipGameObjectTexture(thing); } } } Utilities.Logger.Log("Finished removing QudUX parts from all creatures in the current zone."); Popup.Show("All QudUX parts and effects have been removed from creatures in the current zone.\n\n" + "It's now safe to save your game, close Caves of Qud, and uninstall QudUX.\n\n" + "If all worked right, you should be able to reload this save without QudUX installed.", LogMessage: false); } catch (Exception ex) { Utilities.Logger.Log($"Encountered an exception while trying to remove QudUX parts from creatures in the current zone. [{ex}]"); Popup.Show($"There was an error trying to remove QudUX parts and effects from creatures in the current zone.\n\n{ex}", LogMessage: false); } } }
static void Postfix(string Path, ref exTextureInfo __result) { //This postfix assumes that it is always running on the UI (Unity) thread. if (__result == null && Path.EndsWith(Constants.FlippedTileSuffix)) { if (TextureMaker.MakeFlippedTexture(Path, out exTextureInfo result)) { __result = result; } } }
public override Texture2D GetTexture() { shader = Shader.Find("Noise/Mix"); Material noiseMaterial = new Material(shader); noiseMaterial.SetTexture("_Texture1", ((NoiseNode)GetPort(nameof(input1)).Connection.node).GetTexture()); noiseMaterial.SetTexture("_Texture2", ((NoiseNode)GetPort(nameof(input2)).Connection.node).GetTexture()); noiseMaterial.SetInt("_Mode", (int)mixType); return(TextureMaker.Generate(GetGraph.mapSize, noiseMaterial)); }
/// <summary> /// Generates a noise texture for the currently attached InputSocket /// </summary> /// <returns>If an error occured while retrieving the generator, /// null is returned. Otherwise the Texture is returned.</returns> public void UpdateTexture() { AbsGeneratorNode g = GetInputValue <AbsGeneratorNode>("Input"); if (g != null && g.GetGenerator() != null) { PreviewTexture = TextureMaker.MonochromeTexture(100, 100, g.GetGenerator()); } TextureNeedsUpdating = false; }
public override Texture2D GetTexture() { shader = Shader.Find("Noise/Perlin"); Material noiseMaterial = new Material(shader); noiseMaterial.SetFloat("_X", offset.x); noiseMaterial.SetFloat("_Y", offset.y); noiseMaterial.SetFloat("_Scale", scale); noiseMaterial.SetInt("_Fractal", fractal); noiseMaterial.SetFloat("_Ratio", GetGraph.Ratio); return(TextureMaker.Generate(GetGraph.mapSize, noiseMaterial)); }
public override Texture2D GetTexture() { shader = Shader.Find("Noise/Terrain"); Material noiseMaterial = new Material(shader); noiseMaterial.SetFloat("_X", x); noiseMaterial.SetFloat("_Height", height); noiseMaterial.SetFloat("_Scale", scale); noiseMaterial.SetInt("_Fractal", fractal); noiseMaterial.SetFloat("_Ratio", GetGraph.Ratio); noiseMaterial.SetFloat("_Smooth", smooth); return(TextureMaker.Generate(GetGraph.mapSize, noiseMaterial)); }
public void Generate() { if (randomize) { seed = Random.Range(0, Mathf.Abs(Random.seed)); Debug.Log("Using " + seed + " to make skybox"); } noise = GetNoise(seed); System.Func <float, float, Color> func = GetColor; tex = TextureMaker.Make(size, size, func, TextureFormat.RGB24); image.texture = tex; }
public override Texture2D GetTexture() { shader = Shader.Find("Noise/RidgedMulti"); Material noiseMaterial = new Material(shader); noiseMaterial.SetFloat("_X", offset.x); noiseMaterial.SetFloat("_Y", offset.y); noiseMaterial.SetFloat("_RidgedOffset", ridgedOffset); noiseMaterial.SetFloat("_Lacunarity", lacunarity); noiseMaterial.SetFloat("_Gain", gain); noiseMaterial.SetFloat("_Scale", scale); noiseMaterial.SetInt("_Fractal", fractal); noiseMaterial.SetFloat("_Ratio", GetGraph.Ratio); return(TextureMaker.Generate(GetGraph.mapSize, noiseMaterial)); }
public override Texture2D GenerateTexture() { if (!IsShaderInit) { return(Texture2D.whiteTexture); } if (!GetInputPort(nameof(input1)).IsConnected || !GetInputPort(nameof(input2)).IsConnected) { return(Texture2D.whiteTexture); } if (!Dirty) { return(HasTexture ? Texture : GenerateTexture()); } NoiseNode input1Noise = GetInputValue <NoiseNode>("input1"); NoiseNode input2Noise = GetInputValue <NoiseNode>("input2"); if (input1Noise == null) { return(Texture2D.whiteTexture); } if (input2Noise == null) { return(Texture2D.whiteTexture); } Texture2D input1Texture = input1Noise.Texture == null?input1Noise.GenerateTexture() : input1Noise.Texture; Texture2D input2Texture = input2Noise.Texture == null?input2Noise.GenerateTexture() : input2Noise.Texture; Texture = new Texture2D(GetGraph.mapSize.x, GetGraph.mapSize.y, TextureFormat.RGBA32, false); Material noiseMaterial = new Material(shader); noiseMaterial.SetTexture("_Texture1", input1Texture); noiseMaterial.SetTexture("_Texture2", input2Texture); noiseMaterial.SetInt("_Mode", (int)mixType); Texture = TextureMaker.Generate(GetGraph.mapSize, noiseMaterial); GetPort(nameof(output))?.GetConnections()?.ForEach(f => ((NoiseNode)f.node)?.SetTextureDirty()); Dirty = false; return(Texture); }
public void GenerateMap() { int minSize = Mathf.Min(mapWidth, mapHeight); //Get the smaller size for the FalloffGenerator float[,] noiseMap = PerlinNoise.GenerateNoiseMap(mapWidth, mapHeight, seed, noiseScale, octaves, persistance, lacunarity, offset); Color[] colourMap = new Color[mapWidth * mapHeight]; falloffMap = FalloffGenerator.GenerateFalloffMap(minSize); //Loop through the map and apply heights for (int x = 0; x < mapWidth; x++) { for (int y = 0; y < mapHeight; y++) { if (useFalloff) //If using Falloff to create islands, subtract the falloff map and clamp between 0-1 values { noiseMap[x, y] = Mathf.Clamp(noiseMap[x, y] - falloffMap[x, y], 0, 1); } float height = noiseMap[x, y]; //Loop through the Biomes for (int i = 0; i < biomes.Length; i++) { if (height <= biomes[i].height) { colourMap[y * mapWidth + x] = biomes[i].colour; break; } } } } if (renderMode == RenderMode.Noise) { terrainMap.RenderMap(TextureMaker.TextureFromHeightMap(noiseMap)); } else if (renderMode == RenderMode.Colour) { terrainMap.RenderMap(TextureMaker.TextureFromColourMap(colourMap, mapWidth, mapHeight)); } else if (renderMode == RenderMode.Mesh) { terrainMap.RenderMesh(TerrainMeshGenerator.GenerateTerrainMesh(noiseMap, heightMultiplier), TextureMaker.TextureFromColourMap(colourMap, mapWidth, mapHeight)); } GeneratePlants(800); }
public override Texture2D GetTexture() { Texture2D texture = ((NoiseNode)GetPort(nameof(input)).Connection.node).GetTexture(); Vector2Int size = new Vector2Int(texture.width, texture.height); Texture = TextureMaker.Generate(texture); Color[] colors = Texture.GetPixels(); List <List <Vector2Int> > regions = new List <List <Vector2Int> >(); HashSet <int> visited = new HashSet <int>(); for (int i = 0; i < colors.Length; i++) { if (GetDenoiseCondition(colors[i])) { continue; } Vector2Int coord = new Vector2Int(i % size.x, i / size.x); if (visited.Contains(i)) { continue; } List <Vector2Int> region = CheckRegion(colors, coord, size, ref visited); if (region.Count > 0) { regions.Add(region); } } foreach (List <Vector2Int> region in regions) { if (region.Count > minRoomSize) { continue; } foreach (Vector2Int coord in region) { colors[coord.x + coord.y * size.x] = GetDenoiseColor(); } } Texture.SetPixels(colors); Texture.Apply(); return(Texture); }
protected override void Initialize() { ScreenWidth = 1024; ScreenHeight = 768; _graphics.PreferredBackBufferWidth = ScreenWidth; _graphics.PreferredBackBufferHeight = ScreenHeight; _graphics.ApplyChanges(); Window.IsBorderless = false; Window.AllowUserResizing = true; Window.ClientSizeChanged += Window_ClientSizeChanged; Window.Title = "Ark Demo"; TextureMaker = new TextureMaker(_graphics.GraphicsDevice); base.Initialize(); }
public override Texture2D GenerateTexture() { if (!IsShaderInit) { return(Texture2D.whiteTexture); } if (!Dirty) { return(HasTexture ? Texture : GenerateTexture()); } Material noiseMaterial = new Material(shader); noiseMaterial.SetVector("_Pos", new Vector4(start.x, start.y, end.x, end.y)); noiseMaterial.SetInt("_Mode", (int)mode); Texture = TextureMaker.Generate(GetGraph.mapSize, noiseMaterial); GetPort(nameof(output))?.GetConnections()?.ForEach(f => ((NoiseNode)f.node)?.SetTextureDirty()); Dirty = false; return(Texture); }
void Awake() { _maker = GetComponent <TextureMaker>(); }
public override Texture2D GenerateTexture() { if (!Dirty) { return(HasTexture ? Texture : GenerateTexture()); } NoiseNode inputNoise = GetInputValue <NoiseNode>("input"); if (inputNoise == null) { return(Texture2D.whiteTexture); } Texture2D inputTexture = !inputNoise.HasTexture ? inputNoise.GenerateTexture() : inputNoise.Texture; Vector2Int size = new Vector2Int(inputTexture.width, inputTexture.height); Texture = TextureMaker.Generate(inputTexture); Color[] colors = Texture.GetPixels(); List <List <Vector2Int> > regions = new List <List <Vector2Int> >(); HashSet <int> visited = new HashSet <int>(); for (int i = 0; i < colors.Length; i++) { if (GetDenoiseCondition(colors[i])) { continue; } Vector2Int coord = new Vector2Int(i % size.x, i / size.x); if (visited.Contains(i)) { continue; } List <Vector2Int> region = CheckRegion(colors, coord, size, ref visited); if (region.Count > 0) { regions.Add(region); } } foreach (List <Vector2Int> region in regions) { if (region.Count > minRoomSize) { continue; } foreach (Vector2Int coord in region) { colors[coord.x + coord.y * size.x] = GetDenoiseColor(); } } Texture.SetPixels(colors); Texture.Apply(); GetPort(nameof(output))?.GetConnections()?.ForEach(f => ((NoiseNode)f.node)?.SetTextureDirty()); Dirty = false; return(Texture); }