Code Monkey home page Code Monkey logo

procedural-painting's Introduction

Procedural Painting Using Genetic Evolution Algorithmen in Unity 3D with compute shaders

This repo contains code for a genetic evolution algorithm implmented in compute shaders in Unity 3D. If you are interested in using the project to generate your own paintings, have a look at the later section of this document or the Quick Start Page. For more information on the algorithm and the project itself, read my blog post on medium: https://medium.com/@shahriyarshahrabi/procedural-paintings-with-genetic-evolution-algorithm-6838a6e64703

In the post I go more indepth about the different sections of the pipeline and explain the major parts of the technique. As for information on the source code, the code is well documented.

screenshot

screenshot


Copy of the Quick Start Page

Getting Started with the Project

If you wish to use this project to generate some paintings of your photos, all you have to do is download the content of this repository, download Unity, drag your photo in the inspector and press play.

Unity Version and Platform

I am using Unity 2019.1.14f1 on Windows (DirectX11). I have now ported the code on OpenGL 4.5 as well, but also tested only on windows. I would recommend you open the project with the same version. If you are on a different platform and using OpenGl, it can be that there are further platform differences I am not aware of which cause issues. Just make sure that Unity is used OpenGL and not Vulkan or Metal. (per default it is chosen automaticly, you can change this in Player Settings). Let me know if that is the case, we might find a fix.

Control Center

After you download the the project, open the Main scene in Assets/Scenes. There is a Manager Gameobject, if you click on that, in your Inspector, you will see a Evolution Manager attached as a component to this Game Object. This component is the control center of the whole project.

screenshot

Importing your own Images

You can drag and drop your image in the Image to Reproduce property. If it is black and white, check the black and white bool.

To use your own images first use a image editing software to make sure the image is square and has power of two dimensions (for example 1024 in 1024). I am not quite sure what will happen if you give it a non square, non power of two image. Depending on your platform, it might work or it might not. I might fix this in the future so that it takes any size.

Once you have your image in square format import your image somewhere in Unity. Then click on the image and in its property section make sure the maximum image size is set to 1024 (for performance reasons) and wrap mode is set to clamp.

screenshot

Once these steps are done, drag and drop your image in the Image to Reproduce panel.

Chose a Run Setting

The last property you need to be aware of is the Run Setting. This setting determines how long the painting will take and how detailed it will be. I have prepared 4 presets in the Assets/Settings folder which you can use. The settings are named after how long they take to finish the painting on my Nvidia 2070 graphic card. If you are experiencing performance issues, either reduce the image size, or head to the settings and reduce on each Stage Series the Population Pool Number.

Here is a visual example of how an image looks on 15, 30 and 2 and half hour run with different settings. If you wish to create your own Settings, have a look at the Create You Own Settings Page. This will give you the ability to do things like Create Your Own Brushes.

screenshot

Run the Painting

To start the painting, once you have selected your desired settings press Play in the editor. If all is set correctly, the painting will start and you can view the progress in the Game Window.

If you open your Console, you will see information being printed about the process in real time. The most relevant info there is the Current Stage. Once this value hits 0, that means your painting is finished.

screenshot

procedural-painting's People

Contributors

ircss avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.