Skip to content

huilchen/paintercpp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PainterApp

Authors: Qixiang Chen (u7227010) & Huilin Chen (u7326198)

Overview

PainterApp is a C++ application for 3D scene rendering and image painting using various shading techniques. The application is divided into two main components:

  1. Painter: The stroke drawing algorithm that applies brush strokes to an image based on user-defined parameters.
  2. Painter3D: The 3D scene renderer that uses bump and displacement mapping techniques to render the painted image.

The algorithm is developed based on the papers: Painterly Rendering with Curved Brush Strokes of Multiple Sizes and Fast Paint Texture. Some of the code follows the pseudocode provided in these papers, while other parts are our own implementation, this cpp file is mainly built from scratch. The 3D rendering is based on the CLab2 of COMP4610, and the displacement mapping is based on the paper Displacement Mapping on the GPU — State of the Art.

Features

  • Painterly Rendering: By using the curved brush strokes, the algorithm can simulate the painting effect for the input image based on customizeable brushes and parameters.
  • Height Map Generation: Generate proper height maps based on the generated brush strokes, which can be used for bump mapping or displacement mapping.
  • 3D Scene Rendering: Load and render the painted image on a 3D model with bump or displacement mapping.

Dependencies

  • OpenCV - For image processing and display.
  • Eigen3 - For linear algebra operations.
  • OBJ Loader - For loading OBJ files.

Installation

Prerequisites

  • C++17 compatible compiler (e.g., g++)
  • CMake 3.10 or higher
  • OpenCV library
  • Eigen3 library

Build Instructions

  1. Clone the repository:

    git clone https://github.com/HuilinChen943/paintercpp
    cd PainterApp
  2. Create a build directory and navigate to it:

    mkdir build
    cd build
  3. Run CMake to configure and build the project:

     cmake ..
     make

Usage

  1. Run the PainterApp:

    ./Painter
  2. Follow the prompts to input parameters or use the default values:

    >>> Welcome to the Painter Application! <<<
    
    Type in a new shader (0: Bump, 1: Displacement) or press [Enter] to 
    keep the default value: [0]
    
    Press [Enter] to skip the parameter configuration or enter anything to start:
    ...

    or otherwise you can customize the behavior of the Painter application by modifying the Parameters struct in painter.cpp:

    struct Parameters {
    string image = "../images/huanshan.jpg";
    string height_map_path = "../src/height.jpg";
    string opacity_map_path = "../src/opacity.jpg";
    string texture_map_path = "../src/origin_UV_map.png";
    string shader = "bump";
    int maxLength = 16;
    int minLength = 4;
    vector<int> resize = {}; // H x W
    float threshold = 0.1;
    vector<int> brush_sizes = {8, 4, 2};
    float blur_fac = 0.5;
    float grid_fac = 1;
    float length_fac = 1;
    float filter_fac = 0.95;
    float stroke_opacity = 0.7;
    };

File Structure

PainterApp/
├── include/
│   ├── OBJ_Loader.h
│   ├── Shader.hpp
│   ├── Texture.hpp
│   ├── Triangle.hpp
│   ├── global.hpp
|   ├── mesh.hpp
│   ├── rasterizer.hpp
│   ├── rasterizer.cpp
│   ├── Texture.cpp
│   ├── Triangle.cpp
|   ├── mesh.cpp
├── src/
│   ├── height.jpg
│   ├── opacity.jpg
│   ├── origin_UV_map.png
│   ├── UV_map_paint.png
│   ├── UV_map_height.png
├── images/
│   ├── huanshan.jpg
│   ├── chicago.jpg
│   ├── lizard1.jpg
│   ├── tomato83.jpg
├── models/
│   ├── plane.obj
│   ├── plane.mtl
├── painter.cpp
├── painter3D.cpp
├── render.hpp
├── CMakeLists.txt
└── README.md

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors