• Stars
    star
    489
  • Rank 89,990 (Top 2 %)
  • Language
    C#
  • License
    MIT License
  • Created over 4 years ago
  • Updated over 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Procedural painting algorithms in Unity 3d with compute shaders based on genetic evolution algorithms

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

This repo contains code for a genetic evolution algorithm implemented 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 automatically, 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 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

More Repositories

1

Compute-Shaders-Fluid-Dynamic-

Fluid Simulation Implementation in Compute Shaders using Unity3D
C#
538
star
2

MatrixVFX

A realtime Matrix VFX Shader in Unity 3D
ShaderLab
481
star
3

TexturePaint

Painting directly in mesh textures in Unity 3d with shaders
C#
350
star
4

Look-At-Transformation-Matrix

A look at transformation matrix in vertex shader for Unity 3d. This animates the mesh without any manual rigging.
C#
143
star
5

Geometry-Grass-Shader

Geometry grass shader for Unity engine
ShaderLab
131
star
6

pointclouds-compute-shaders

A compute shader plus some c# scripts which render a mesh as point clouds
C#
88
star
7

Trees-With-Geometry-Nodes-Blender

Tree generation using geometry nodes in Blender 3D
85
star
8

UnityRaymarching

raymarching experiment in unity
GLSL
81
star
9

BluePrintShader

Blueprint shading with depth peeling in Unity
C#
77
star
10

3D-Moebius-Transformations-Vertex-shader-in-Unity-3D

Moebius Transformations of 3D spaces on 4D sphere in Vertex shader and C# in Unity 3D
C#
74
star
11

Procedural-Sound

Generate procedural sounds / synthesized paino on run time in Unity3d
C#
70
star
12

Interactive-Grass

C#
62
star
13

Mesh-Deformation-With-Compute-Shader-Oculus-Quest-Unity

Mesh deformation using compute shaders on the Oculus Quest/ Andriod in Unity3D
C#
58
star
14

Procedural-Chinese-Landscape-Painting-Blender-3D

Series of geometry nodes creating a chinese landscape painting, the mountains are created with Vornoi noise in Geometry noise
57
star
15

ToyRenderer

my toy renderer used for learning
C++
48
star
16

Cubism-Shader

A shader that creates a cubism effect based on voronoi segmentation in Unity 3d
ShaderLab
45
star
17

Stylized-Sword-Aura

A shader effect for real time animated aura around objects such as swords using shaders
GLSL
34
star
18

Transformation-Matrices-Cheat-Sheet

Collection of fundamental transformation matrices and a setup to easily try new matrices
C#
34
star
19

Unity-Stencil-Portal

An example of Stencil Portal in Unity
ShaderLab
29
star
20

simultaneous-equations-solver

Series of classes to solve simultaneous equations for c# along with an AI example of its use
C#
28
star
21

Day-Night-LUT-Shader

LUT shader for day night transition in Blender 3D
23
star
22

GeometryNodes-Stylized-Scene-Generator

Generating stylized scenes using Blender and geometry nodes. including trees, rocks and landscape
21
star
23

Non-Affine-Transformation-Matrices

Code for the non affine transformation matrices post I made
ShaderLab
12
star
24

equirectangular-Sphere-Mesh

an equirectangular Sphere Mesh used for skyboxes
10
star
25

Procedural-Islamic-Dome-Generator

A blender geometry node and material setup to procedurally generate islamic mosque dome
8
star
26

Tyrol-Church-Photogrammetry-Dataset

This Data Set contains drone images used for photogrammetry. The location is Rein in Taufers, a village in south Tyrol
6
star
27

PI-estimation-with-monte-carlo

Estimating the value of PI with monte carlo sampling of the area of a circle within a square
C#
4
star
28

Raytracer

C++ CPU ray tracer
C++
1
star