procedural generation
107 subscribers
4.57K photos
1.35K videos
2 files
10K links
Created by @r_channels
Download Telegram
i created a little site with a bunch of free prompts

I am a little older guy and i am absolutely amazed by all that is possible with ai anymore so i tried to make a little website where you can get a bunch of free pretty good prompts i am not trying to spam and the website is kinda janky but check it out it took allot of work for me. www.42ify.com i have a bunch of cool image prompts and it can go straight to chatgpt with a link. the prompts are mainly for inspiration they are not as good as what you guys do yall are way better. i also made a subreddit where you can check out some of the pictures i dont know how to link that

https://redd.it/1ls3nzs
@proceduralgeneration
Procedural Road Generation From Prefabs
https://redd.it/1lslsfh
@proceduralgeneration
Help me please

I'm an almost complete beginner to Godot 4.4 and have not done procedural generation yet how would i go about making a 2d procedurally generated tunnel system

ps. please explain it like I'm five years old or something

https://redd.it/1lt00a2
@proceduralgeneration
This media is not supported in your browser
VIEW IN TELEGRAM
a (maybe ugly) representation of the organic dungeon procedural generation processes I made

https://redd.it/1lt22e6
@proceduralgeneration
I used WFC but result is not good.

https://preview.redd.it/bs08bd71m9bf1.png?width=1040&format=png&auto=webp&s=7ce2a45abd9f4ede87935527f74a84922f93ca8f

In the end it turned out to be some kind of mishmash of objects. Can you help me find out what's wrong?

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Tilemaps;

public class WaveFunction : MonoBehaviour
{
    public int dimensions;
    public Tie tileObjects;
    public List<Cell> gridCompoments;
    public Cell cellObj;

    public float tileSize = 1.0f;

    int iterations = 0;

    void Awake()
    {
        gridCompoments = new List<Cell>();
        InitializeGrid();
    }

    void InitializeGrid()
    {
        for (int z = 0; z < dimensions; z++)
        {
            for (int x = 0; x < dimensions; x++)
            {
                Vector3 pos = new Vector3(x tileSize, 0, z tileSize); // Y = 0
                Cell newCell = Instantiate(cellObj, pos, Quaternion.identity);
                newCell.CreateCell(false, tileObjects);
                gridCompoments.Add(newCell);
            }
        }

        StartCoroutine(CheckEntropy());
    }

    IEnumerator CheckEntropy()
    {
        List<Cell> tempGrid = new List<Cell>(gridCompoments);

        tempGrid.RemoveAll(c => c.collapsed);

        tempGrid.Sort((a, b) => { return a.tileOptions.Length - b.tileOptions.Length; });

        int arrLenght = tempGrid0.tileOptions.Length;
        int stopIndex = default;

        for (int i = 1; i < tempGrid.Count; i++)
        {
            if (tempGridi.tileOptions.Length > arrLenght)
            {
                stopIndex = i;
                break;
            }
        }

        if (stopIndex > 0)
        {
            tempGrid.RemoveRange(stopIndex, tempGrid.Count - stopIndex);
        }

        yield return new WaitForSeconds(0.01f);

        CollapseCell(tempGrid);
    }

    void CollapseCell(List<Cell> tempGrid)
    {
        int randIndex = UnityEngine.Random.Range(0, tempGrid.Count);

        Cell cellToCollapse = tempGridrandIndex;

        cellToCollapse.collapsed = true;
        Tie selectedTile = cellToCollapse.tileOptionsUnityEngine.Random.Range(0, cellToCollapse.tileOptions.Length);
        cellToCollapse.tileOptions = new Tie { selectedTile };

        Tie foundTile = cellToCollapse.tileOptions0;
        Instantiate(foundTile, cellToCollapse.transform.position, Quaternion.identity);

        UpdateGeneration();
    }

    void UpdateGeneration()
    {
        List<Cell> newGenerationCell = new List<Cell>(gridCompoments);

        for (int z = 0; z < dimensions; z++)
        {
            for (int x = 0; x < dimensions; x++)
            {
                int index = GetIndex(x, z);
                Cell currentCell = gridCompomentsindex;

                if (currentCell.collapsed)
                {
                    newGenerationCellindex = currentCell;
                }
                else
                {
                    List<Tie> options = new List<Tie>(tileObjects);

                    // LEFT
                    if (x > 0)
                        ApplyConstraint(x - 1, z, "XP", options);

                    // RIGHT
                    if (x < dimensions - 1)
                        ApplyConstraint(x + 1, z, "XM", options);

                    // FORWARD
                    if (z < dimensions - 1)
                        ApplyConstraint(x, z + 1, "ZM",
I used WFC but result is not good.

https://preview.redd.it/bs08bd71m9bf1.png?width=1040&format=png&auto=webp&s=7ce2a45abd9f4ede87935527f74a84922f93ca8f

In the end it turned out to be some kind of mishmash of objects. Can you help me find out what's wrong?

using System;
using System.Collections;
using System.Collections.Generic;
using System.IO.Compression;
using System.Linq;
using System.Runtime.InteropServices.WindowsRuntime;
using Unity.VisualScripting;
using UnityEngine;
using UnityEngine.Tilemaps;

public class WaveFunction : MonoBehaviour
{
    public int dimensions;
    public Tie[] tileObjects;
    public List<Cell> gridCompoments;
    public Cell cellObj;

    public float tileSize = 1.0f;

    int iterations = 0;

    void Awake()
    {
        gridCompoments = new List<Cell>();
        InitializeGrid();
    }

    void InitializeGrid()
    {
        for (int z = 0; z < dimensions; z++)
        {
            for (int x = 0; x < dimensions; x++)
            {
                Vector3 pos = new Vector3(x * tileSize, 0, z * tileSize); // Y = 0
                Cell newCell = Instantiate(cellObj, pos, Quaternion.identity);
                newCell.CreateCell(false, tileObjects);
                gridCompoments.Add(newCell);
            }
        }

        StartCoroutine(CheckEntropy());
    }

    IEnumerator CheckEntropy()
    {
        List<Cell> tempGrid = new List<Cell>(gridCompoments);

        tempGrid.RemoveAll(c => c.collapsed);

        tempGrid.Sort((a, b) => { return a.tileOptions.Length - b.tileOptions.Length; });

        int arrLenght = tempGrid[0].tileOptions.Length;
        int stopIndex = default;

        for (int i = 1; i < tempGrid.Count; i++)
        {
            if (tempGrid[i].tileOptions.Length > arrLenght)
            {
                stopIndex = i;
                break;
            }
        }

        if (stopIndex > 0)
        {
            tempGrid.RemoveRange(stopIndex, tempGrid.Count - stopIndex);
        }

        yield return new WaitForSeconds(0.01f);

        CollapseCell(tempGrid);
    }

    void CollapseCell(List<Cell> tempGrid)
    {
        int randIndex = UnityEngine.Random.Range(0, tempGrid.Count);

        Cell cellToCollapse = tempGrid[randIndex];

        cellToCollapse.collapsed = true;
        Tie selectedTile = cellToCollapse.tileOptions[UnityEngine.Random.Range(0, cellToCollapse.tileOptions.Length)];
        cellToCollapse.tileOptions = new Tie[] { selectedTile };

        Tie foundTile = cellToCollapse.tileOptions[0];
        Instantiate(foundTile, cellToCollapse.transform.position, Quaternion.identity);

        UpdateGeneration();
    }

    void UpdateGeneration()
    {
        List<Cell> newGenerationCell = new List<Cell>(gridCompoments);

        for (int z = 0; z < dimensions; z++)
        {
            for (int x = 0; x < dimensions; x++)
            {
                int index = GetIndex(x, z);
                Cell currentCell = gridCompoments[index];

                if (currentCell.collapsed)
                {
                    newGenerationCell[index] = currentCell;
                }
                else
                {
                    List<Tie> options = new List<Tie>(tileObjects);

                    // LEFT
                    if (x > 0)
                        ApplyConstraint(x - 1, z, "XP", options);

                    // RIGHT
                    if (x < dimensions - 1)
                        ApplyConstraint(x + 1, z, "XM", options);

                    // FORWARD
                    if (z < dimensions - 1)
                        ApplyConstraint(x, z + 1, "ZM",
options);

                    // BACKWARD
                    if (z > 0)
                        ApplyConstraint(x, z - 1, "ZP", options);

                    Tie[] newTileList = options.ToArray();
                    newGenerationCell[index].RecreateCell(newTileList);
                }
            }
        }

        gridCompoments = newGenerationCell;
        iterations++;

        if (iterations < dimensions * dimensions)
        {
            StartCoroutine(CheckEntropy());
        }
    }

    int GetIndex(int x, int z)
    {
        return x + z * dimensions;
    }

    void ApplyConstraint(int x, int z, string direction, List<Tie> options)
    {
        Cell neighbor = gridCompoments[GetIndex(x, z)];
        List<Tie> validOptions = new List<Tie>();

        foreach (Tie possible in neighbor.tileOptions)
        {
            int idx = Array.FindIndex(tileObjects, obj => obj == possible);

            Tie[] valid = possible.GetNeighbors(direction, neighbor.rotation);

            validOptions = validOptions.Concat(valid).ToList();
        }

        CheckValidity(options, validOptions);
    }

    void CheckValidity(List<Tie> optionsList, List<Tie> validOption)
    {
        for (int x = optionsList.Count - 1; x >= 0; x--)
        {
            var element = optionsList[x];
            if (!validOption.Contains(element))
            {
                optionsList.RemoveAt(x);
            }
        }
    }
}

using UnityEngine;
using UnityEngine.Tilemaps;

public class Cell : MonoBehaviour
{
    public bool collapsed;
    public Tie[] tileOptions;
    public int rotation;

    public void CreateCell(bool collapseState, Tie[] tiles)
    {
        collapsed = collapseState;
        tileOptions = tiles;
    }

    public void RecreateCell(Tie[] tiles)
    {
        tileOptions = tiles;
    }
}


using System;
using UnityEngine;

public enum Direction { North_ZP, South_ZM, East_XP, West_XM }
public class Tie : MonoBehaviour
{
    [Header("BVars:")]
    public string type;
    public Direction[] connections;
    [Header("Other Vars:")]
    public Tie[] ZP_neighbors; //Up
    public Tie[] ZM_neighbors; //Down

    public Tie[] XP_neighbors; //Right
    public Tie[] XM_neighbors; //Left

    public Tie[] GetNeighbors(string direction, int rotation)
    {

        int dirIndex = direction switch
        {
            "XP" => 0,
            "ZP" => 1,
            "XM" => 2,
            "ZM" => 3,
            _ => -1
        };

        int rotatedDirIndex = (dirIndex - rotation + 4) % 4;

        switch(rotatedDirIndex)
        {
            case 0: return XP_neighbors;
            case 1: return ZP_neighbors;
            case 2: return XM_neighbors;
            case 3: return ZM_neighbors;
            default: return Array.Empty<Tie>();
        }
    }
}




https://redd.it/1lt2rfj
@proceduralgeneration
Media is too big
VIEW IN TELEGRAM
I've been cooking also pretty sure this is the first universe sim of its kind ever to fully simulate universal age based on the most popular and real theory of heat death it still needs some baking and i need to add black dwarfs

https://redd.it/1luvg46
@proceduralgeneration
I'm now creating webapp to share seeds (balatro and other procedure generation based games), and I can't stop thinking about this domain. I mean, it's 30$, but I really can't stop thinking about it
https://redd.it/1lv1tdo
@proceduralgeneration
Convert pixel-art-style images from GPT-4o into true pixel resolution assets

GPT-4o has a fantastic image generator and can turn images into a pixel-art-like style. However, the raw output is generally unusable as an asset due to

High noise
High resolution
Inconsistent grid spacing
Random artifacts

Due to these issues, regular down-sampling techniques do not work, and the only options are to either use a down-sampling method that does not produce a result that is faithful to the original image, or manually recreate the art pixel by pixel.

Additionally, these issues make raw outputs very difficult to edit and fine-tune. I created an algorithm that post-processes pixel-art-style images generated by GPT-4o, and outputs the true resolution image as a usable asset. It also works on images of pixel art from screenshots and fixes art corrupted by compression.

The tool is available to use with an explanation of the algorithm on my GitHub here!

P.S. if you are trying to use this and not getting the results you would like feel free to reach out!

https://redd.it/1lvk9wp
@proceduralgeneration
Nova Patria - A Roman Steampunk Colony Sim - now has a Steam page!
https://redd.it/1lvmd4f
@proceduralgeneration