Code Monkey home page Code Monkey logo

abstract-art-generator's Introduction

Abstract Art Generator

The Abstract Art Generator does exactly what it sounds like - it's designed to generate random abstract images through a Blender script. Assets in the /assets/ folder are imported into Blender, given random values for position, rotation and material, and then are rendered at a random camera position and focal length.

Here's what one render might look like:

Example Abstract Art Generated Render

Why?

The Abstract Art Generator project is linked to our efforts at UW Reality Labs to research and build immersive VR/XR experiences. One key challenge in computerized displays and optics is the vergence-accommodation conflict. This occurs when a user perceives an object in VR to be a certain distance away, but the user's eyes are focused at a different distance, due to the lenses in the VR headset only being able to show one fixed focal distance (the distance between the user and the object of focus). This focal distance is said to be at around 2m for most consumer VR headsets today, meaning that any object closer than or further than 2m away in a virtual scene will look blurry and be unable to focus on naturally.

Varifocal optics are a proposed solution to this problem. It uses eye tracking in the headset to figure out where the user is looking and which in-game object they are attempting to focus on. Then, through the game API, the focal distance to that object could be found and then stepper motors within the headset would move the lenses accordingly, to set the lenses to that focal distance. However, while this fixed the image to be sharp at all distances, it remained that everywhere in the image was sharp, which is unlike how the eye works by blurring everything surrounding the point of focus.

The idea of DeepFocus was to create a convolutional neural network that could add natural blur mimicking the focal properties of a focused human eye to frames generated by a game engine in real time with minimal performance penalty in comparison to traditional photorealistic (eye-realistic) blurring methods.

The method they used to generate training data for the neural network was (relatively) simple - generate random photorealistic images with varying properties (different objects, different colours, different specular properties, different sizes, placed at different distances) through a script that could be run on a computer (a render farm in the cloud) with a powerful enough GPU to render hundreds/thousands of them. These images would have natural focused-eye-like blur set at random diopters.

This is what we are working on replicating with Abstract Art Generator - a script to generate a user-specified amount of images that are diverse and will prove as sufficiently high-quality training data for a neural network to be trained from.

Setting up the environment

Clone the repository.

Install Blender

Download and install Blender from the official Blender website: Blender Download

We used the Blender 3.6 LTS version. In the render.py file, the example directories for "blender_python_path" MUST be changed if you are using a different version or have installed in a different directory.

Open Visual Studio Code

If you don't have Visual Studio Code installed, download and install it from the official website: Visual Studio Code Download

Install the "Blender Development" extension for Visual Studio Code. Open the Extensions view (Ctrl+Shift+X) and search for "Blender Development." Install the extension.

Blender Development Extension

Locate Blender Python Interpreter

Find the path to Blender's Python interpreter, typically located within the Blender application package (e.g. on macOS, /Applications/Blender.app/Contents/Resources/3.10/python/bin/python3.10).

Configure Python Interpreter in Visual Studio Code

Open Visual Studio Code, go to the command palette (Ctrl+Shift+P), and run the command "Python: Select Interpreter." Choose the Blender Python interpreter path.

Restart Visual Studio Code

Restart Visual Studio Code to apply the changes.

Add Blender to your PATH environment

Windows

  1. Find the path to your Blender installation (usually C:\Program Files\Blender Foundation\Blender 3.6).

  2. Copy the path to the Blender directory. Don't copy the executable path, just the file directory.

  3. Hit the Windows key and search for 'env'. You should see "Edit the system environment variables".

  4. Click or select it by pressing Enter. This should open the Advanced tab of System Properties.

  5. Click the "Environment Variables..." button in the lower right.

  6. In the "System variables" section, scroll down and find the "Path" variable. Select it and click "Edit."

  7. Click "New" and paste the path to the Blender directory.

  8. Click "OK" to close each window.

  9. Open a new command prompt and type blender to verify that Blender launches.

macOS and Linux

  1. Open a terminal.

  2. Find the path to your Blender installation (e.g., /Applications/Blender.app/Contents/MacOS on macOS or /opt/blender/blender [version]/ on Linux).

  3. Open your shell profile file (~/.bashrc, ~/.bash_profile, ~/.zshrc, etc.) using a text editor like nano, vim, or gedit.

    nano ~/.bashrc
  4. Add the following line to the end of the file, replacing /path/to/blender with the actual path to your Blender installation:

    export PATH=$PATH:/path/to/blender
  5. Save the file and exit the text editor.

  6. In the terminal, type source ~/.bashrc (or the corresponding command for your shell) to apply the changes to the current session.

  7. Open a new terminal and type blender to verify that Blender launches.

Keep in mind that the exact steps may vary depending on your system configuration and the specific shell you're using.

Run the script

You should now be able to run the python script using blender -b art.blend -P scripts/render.py. This command should be run inside the cloned repository folder. Alternatively, if the steps above did not work for you, you can run the script inside of Blender's built-in script editor.

abstract-art-generator's People

Contributors

antgenix avatar itsanantk avatar kennynahh avatar

Stargazers

 avatar

Watchers

 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.