All Projects → dbohdan → Unflattener

dbohdan / Unflattener

Licence: bsd-3-clause
Make normal maps for 2D art

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to Unflattener

Deadsimple Pixel Perfect Camera
An exceedingly easy-to-use pixel perfect orthographic camera script for 2D scenes in Unity. Punch in a few specs and you've got a working pixel perfect camera. It's that easy.
Stars: ✭ 186 (+48.8%)
Mutual labels:  game-development, sprites
Fontainebleaudemo
Fontainebleau demo
Stars: ✭ 524 (+319.2%)
Mutual labels:  game-development, lighting
Krita Batch Exporter
A Free Krita plugin to batch export layers and groups with maximum flexibility. Scale, trim, export multiple copies of your layers...
Stars: ✭ 201 (+60.8%)
Mutual labels:  game-development, image-processing
Slate
Pixel Art Editor
Stars: ✭ 723 (+478.4%)
Mutual labels:  game-development, sprites
Pixieditor
PixiEditor is a lightweight pixel art editor made with .NET 5
Stars: ✭ 210 (+68%)
Mutual labels:  game-development, sprites
Pixelvision8
Pixel Vision 8's core philosophy is to teach retro game development with streamlined workflows. PV8 is also a platform that standardizes 8-bit fantasy console limitations built on top of the open-source C# game engine based on MonoGame.
Stars: ✭ 773 (+518.4%)
Mutual labels:  game-development, sprites
Cx
Stars: ✭ 121 (-3.2%)
Mutual labels:  game-development
Openjk
Community effort to maintain and improve Jedi Academy (SP & MP) + Jedi Outcast (SP only) released by Raven Software
Stars: ✭ 1,641 (+1212.8%)
Mutual labels:  game-development
Arcadia
Clojure in Unity
Stars: ✭ 1,596 (+1176.8%)
Mutual labels:  game-development
Mgan
Masking GAN - Image attribute mask generation
Stars: ✭ 120 (-4%)
Mutual labels:  image-processing
Cryengine
CRYENGINE is a powerful real-time game development platform created by Crytek.
Stars: ✭ 580 (+364%)
Mutual labels:  game-development
Triangle
Convert images to computer generated art using delaunay triangulation.
Stars: ✭ 1,838 (+1370.4%)
Mutual labels:  image-processing
Compilepal
A tool to assist in the compiling of source engine maps
Stars: ✭ 122 (-2.4%)
Mutual labels:  game-development
O2
2D Game Engine with visual WYSIWYG editor
Stars: ✭ 121 (-3.2%)
Mutual labels:  game-development
Typefont
The first open-source library that detects the font of a text in a image.
Stars: ✭ 1,575 (+1160%)
Mutual labels:  image-processing
Whatsapp Like Photoeditor
A library module that tries to mimic whatsapp photo editor.
Stars: ✭ 121 (-3.2%)
Mutual labels:  image-processing
Slic Python Implementation
🖼The python implementation to make superpixels by slic.
Stars: ✭ 125 (+0%)
Mutual labels:  image-processing
Angular Rpg
RPG game built with Typescript, Angular, ngrx/store and rxjs
Stars: ✭ 120 (-4%)
Mutual labels:  game-development
Reliablenetcode.net
A pure managed C# socket-agnostic reliability layer inspired by reliable.io and yojimbo
Stars: ✭ 122 (-2.4%)
Mutual labels:  game-development
Jquery Filepond
🔌 A handy FilePond wrapper for jQuery
Stars: ✭ 124 (-0.8%)
Mutual labels:  image-processing

unflattener

Build Status

Unflattener is a free and open source Python module and a command line tool (unflatten) that helps you make normal maps for 2D sprites and other graphics. You can use the normal maps it generates to implement dynamic lighting in video games.

Example

D-lit images and the resulting normal map

Together the diffuse and normal maps create dynamic lighting

Dynamic lighting in gimp-normalmap in motion

How it works

Unflattener takes as input images of your object lit by a light source pointing directly at that object from four directions: top, bottom, left and right (we'll call those images "directionally lit" or "d-lit" for short — like "d-pad"). At least one such image is required; having at least two (one with light coming from the top or the bottom, one with light from the left or the right) is highly recommended.

Unflattener is written in Python and requires the libraries NumPy and Pillow to work. Python programs can access its functionality directly by importing the NormalMap class from the module unflattener.normalmapgen. Right now Unflattener cannot do dynamic lighting previews, so you will need a third-party tool like the gimp-normalmap plugin for GIMP for that.

This project was inspired by Sprite Lamp.

The core algorithm is explained in a rather lengthy comment in the method NormalMap.create_from_images in normalmapgen.py. You will find some tips on how the input artwork should look in the same comment.

The general idea is that in the d-lit images your object should look as if it were

  1. Uniformly matte white with no self-shadowing;
  2. Lit by a very distant light source much larger than itself that creates no highlights.

Installation

Unflattener has been tested to work under Linux (Ubuntu 12.04, Ubuntu 16.04, Fedora 26, Debian 7 and openSUSE Tumbleweed 2017*) and Windows (XP, 7, 8.1 and 10).

You will need Python 2.7 (v2.6 and earlier won't work) or Python 3.2 or later, NumPy and Pillow to run Unflattener. The following instructions are for Python 2.7.

Debian and Ubuntu

You can install the dependencies from the distribution's package repository with

sudo apt install git python-numpy python-imaging python-setuptools

To install gimp-normalmap, run

sudo apt install gimp-normalmap

To install Unflattener, clone this repository, cd into it and run setup.py:

git clone https://github.com/dbohdan/unflattener
cd unflattener
python setup.py install --user

Fedora

You can install the dependencies from the distribution's package repository with

sudo dnf install git numpy python-pillow python-setuptools

To install gimp-normalmap, run

sudo dnf install gimp-normalmap

To install Unflattener, clone this repository, cd into it and run setup.py:

git clone https://github.com/dbohdan/unflattener
cd unflattener
sudo python setup.py install

Windows

On Windows you first need to install Python 2.7 using the official installer from http://python.org/download/. Unflattener has only been tested with the 32-bit versions of Python, NumPy and Pillow (on both 32-bit and 64-bit Windows), so it is recommended that you use those.

Once you have Python installed, download the latest binary packages for NumPy and Pillow from http://www.lfd.uci.edu/~gohlke/pythonlibs/. They will be named, e.g., numpy-1.13.1+mkl-cp27-cp27m-win32.whl and Pillow-4.2.1-cp27-cp27m-win32.whl. Open the Command Prompt in the directory where you downloaded the package files and run

c:\Python27\python.exe -m pip install "numpy-1.13.1+mkl-cp27-cp27m-win32.whl"
c:\Python27\python.exe -m pip install Pillow-4.2.1-cp27-cp27m-win32.whl

To install Unflattener, clone this repository with Git for Windows or download https://github.com/dbohdan/unflattener/archive/master.zip and unzip it, cd into the created directory and do

c:\Python27\python.exe setup.py install

You should then be able to run Unflattener from the Command Prompt with the command unflatten. If you don't have the Python 2.7 scripts directory added to your %PATH%, try

c:\Python27\Scripts\unflatten.exe

Usage

usage: unflatten.py [-h] [--top TOP] [--bottom BOTTOM] [--left LEFT]
                    [--right RIGHT] [--output OUTPUT] [--depth DEPTH]

Generate a normal map for 2D art

optional arguments:
  -h, --help            show this help message and exit
  --top TOP, -t TOP     top image file
  --bottom BOTTOM, -b BOTTOM
                        bottom image file
  --left LEFT, -l LEFT  left image file
  --right RIGHT, -r RIGHT
                        right image file
  --output OUTPUT, -o OUTPUT
                        output file name
  --depth DEPTH, -d DEPTH
                        normal map z_N range

One input file minimum, at least two (one for each axis) highly recommended.
Input files should be 8-bit grayscale PNGs.

Submit your work

If you use Unflattener to create artwork or video game graphics, file an issue to have your work featured here.

License information

Unflattener is distributed under the new (3-clause) BSD license. See the file LICENSE.

Robot sprite originally from the Bits & Bots art pack by MoikMellah. The sprite is licensed under the Creative Commons CC0 license.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].