Skip to content

frasalt/PhotoGENius

Repository files navigation

PhotoGENius - Your wish, my duty

Photorealistic images generator

release OS license build Top Language

A basic library for generating photorealistic images, developed for the course Numerical techniques for photorealistic image generation held by professor Maurizio Tomasi (University of Milan, 2021-2022).

Main contributors: Francesca Salteri (owner), Teresa Lamorte, Martino Zanetti.

Features

This library is meant to 🌅 create photorealistic images, given an input txt file containing user instructions. The user can assemble different images to generate short animations, thanks to a simple bash script.

Besides that, it's also possible to 🔄 convert HDR images to LDR (from PFM format to PNG).

Image rendering can be performed via four different backwords raytracing algorithms (onoff, flat, pathtracer, pointlight tracer). The user can add three types of geometric shapes to the scene (sphere, plane and cylinder), set their color properties and camera position, orientation and projection (orthogonal or perspective).

For further information, see the Application Program Interface info file.

Usage

Extremely easy basic usage.

Go to PhotoGENius/PhotoGENius directory.

  • To 🔄 convert file, type
dotnet run -- pfm2png --pfm-input [PFM_FILE_PATH] {options}

Pay attention that if your computer is set on Italian language, you may need to write floating-point parameters with a comma instead of a dot (e.g. 1,3 instead of 1.3).

  • To 🌅 create an image (pfm/png/jpeg), type
dotnet run -- render {options}

In this case, the scene content is set in an input txt file, like this self-explained one in the scene files directory. Here you can also find our compiler grammar, in EBNF format.

Type -? as option to show further usage information.

The command line interface is built using the argument parsing library System.CommandLine.

Examples

PFM to PNG convertion

Luminosity factor =10 and gamma compression =0.1 (copy and paste to command line without comments, or in a bash script):

dotnet run -- pfm2png    --lum-fac 10   --gamma-fac 0.1   --png-output ../Media/Readme_imgs/memorial1.png

For a less saturated result: luminosity factor =0.01 and gamma compression =2 (copy and paste as above):

dotnet run -- pfm2png    --lum-fac 0.01    --gamma-fac 2    --png-output ../Media/Readme_imgs/memorial2.png

Photorealistic image generation

Generate a demo image (copy and paste as above):

dotnet run -- render    --file-name ../InputSceneFiles/DEFAULT_INPUT.txt    --output ../Media/Readme_imgs/my_first_image.png  --sample-per-pixel 9

Generate a brief animation

To generate frames, in PhotoGENius/BashScripts directory, run this script:

./generate-frames.sh

It takes in input a series of input scene files which must be located in InputSceneFiles/serial, and be named inputNNN.txt where NNN stands for a 3 digits integer.
Automatic generation of the scene files can be done e.g. via a python program similar to this one (or write them by hand, if you prefer...).

You can quite easily adapt the script to your needs and make it executable if necessary (chmod +x on Linux and MacOS).

To assemble video, after installing ffmpeg, type

./generate-video.sh

The result is a video like the following: bouncing PhotoGENius' logo

Installation

Requirements

PhotoGENius can be used on Windows, Linux and MacOS systems.

A dotnet installation is needed for running the code:

If you want to assemble animations, you need to install ffmpeg (note that it's not mandatory for running the raytracing code):

  • FFmpeg (version 4.4 or higher)

Download latest release

You can download the latest stable release here (version 1.0.0) and then unpack it running in the command line (Linux):

tar -xvf PhotoGENius-1.0.0.tar

The command is tar xopf for MacOS.

Clone from git repository

You can also clone this repository through the command:

git clone https://github.com/frasalt/PhotoGENius.git

Code testing

The code is tested at every push, and this flag build should warn the user if something is not working.

Potentialities

Some examples of what your creativity can lead to, using PhotoGENius in its full potential. Here the link to the joke that inspired us.

Eye reflected in a sphere mirror:

Documentation

The complete documentation of the library is available here.

If you find anything not clear in it, please let us know: any suggestion is appreciated and certainly useful for other users.

Contributing

Please open pull requests or use the issue tracker to suggest any code implementations or report bugs. Any contributions are welcome!

License

The code is released under the terms of the GPU General Public License v3.0.
Read the whole licence here.