# Filtering Solid Gabor Noise
Code

## Notes and Disclaimers

Our code requires a fast graphics card, it may run very slowly on old graphics cards.

Our code was designed for brevity and clarity, it can be significantly optimized.

## Annotated Source Code

The annotated source code of our new noise is completely contained in the file `paper_0049_code/src/filtering_solid_gabor_noise.frag`. This fragment shader has comments which refer to the equations in the paper. All other files are supporting code.

## Pre-Compiled Binaries

Our code includes pre-compiled binaries in the directory `paper_0049_code/precompiled`.

If these binaries do not work on your system (which is likely for Linux and Mac OS X), or if you simply do not want to run these binaries, please compile from source code as explained below.

See the Program Manual below for instructions on how to use the program.

## Compiling from Source

### Windows

Preliminaries:

- Developer Tools
- OpenGL (preferably >= 3.2, at least 2.1)
  - Update your graphics card drivers if needed.
- GLUT
  - If our package cannot find GLUT on your system, it will attempt to use a GLUT distribution included in our package.
- CMake (command line tools)
  - Download the Win32 installer from the CMake website (at the time of writing `cmake-2.8.3-win32-x86.exe`).
  - Install CMake. When prompted to "Install Command Line Tools" click the button "Install Comand Line Links".

Configuring, building, installing and running the program using the Visual Studio compiler:

Use the Visual Studio Command Prompt:

- Open the Visual Studio Command Prompt (Start Menu->"Microsoft Visual Studio XXX" -> Visual Studio Tools -> Visual Studio XXX Command Prompt ) and navigate to the directory `paper_0049_code`.
- Type the following commands in the Command Prompt:
  - `cd build`
  - `cmake ../src`
  - `devenv /build release "Filtering Solid Gabor Noise.sln"`
  - `devenv /build release /project INSTALL "Filtering Solid Gabor Noise.sln"`
  - `cd ../bin`
  - `filtering_solid_gabor_noise.exe`

### Linux

Preliminaries:

- Developer Tools
  - Check if you have the developer tools by opening a terminal (e.g., in Ubuntu: Applications -> Accesoires -> Terminal) and typing the command `g++`.
  - If you do not have the developer tools, install them (e.g., in Ubuntu: Applications -> Ubuntu Software Center -> enter "g++" -> install the package called "g++".)
- OpenGL
  - Check if you have OpenGL (preferably >= 3.2, at least 2.1) by opening a terminal (e.g., in Ubuntu: Applications -> Accesoires -> Terminal) and typing the command `glxinfo | grep OpenGL`.
  - If needed, install or update the drivers of your graphics card.
- GLUT
  - If you do not have GLUT, install it (e.g., in Ubuntu: Applications -> Ubuntu Software Center -> enter "freeglut" -> install the packages called "freeglut3" and "freeglut3-dev".)
- CMake (command line tools)
  - Check if you have the CMake command line tools by opening a terminal (e.g., in Ubuntu: Applications -> Accesoires -> Terminal) and typing the command `cmake`.
  - If you do not have CMake, install it (e.g., in Ubuntu: Applications -> Ubuntu Software Center -> enter "cmake" -> install the package called "cmake".)

Configuring, building, installing and running the program:

- Open a terminal (e.g., in Ubuntu: Applications -> Accesoires -> Terminal) and navigate to the directory `paper_0049_code`.
- Type the following commands in the terminal:
  - `cd build`
  - `cmake ../src`
  - `make`
  - `make install`
  - `cd ../bin`
  - `./filtering_solid_gabor_noise`

### Mac OS X

Preliminaries:

- Developer Tools
  - Check if you have the developer tools by checking if you have the Xcode application (e.g. using Spotlight).
  - If you do not have the developer tools, install them (Xcode is on the installation DVD supplied with your Mac, and can be downloaded as well).
- OpenGL
  - Check if you have OpenGL (preferably >= 3.2 (at the time of writing not supported by Mac OS X), at least 2.1) using this table.
  - If needed, perform a software update (Apple Logo -> Software Update)
- CMake (command line tools)
  - Check if you have the CMake command line tools by opening a terminal (e.g., Utilities -> Terminal.app) and typing the command `cmake`.
  - If you do not have CMake, download the .dmg installer from the CMake website (at the time of writing `cmake-2.8.3-Darwin-universal.dmg`), and install CMake. When prompted to "Install Command Line Tools" click the button "Install Comand Line Links".

Configuring, building, installing and running the program:

- Open a terminal (e.g., Utilities -> Terminal.app) and navigate to the directory `paper_0049_code`.
- Type the following commands in the terminal:
  - `cd build`
  - `cmake ../src`
  - `make`
  - `make install`
  - `cd ../bin`
  - `./filtering_solid_gabor_noise`

### If The Above Fails

Compiling our program is relatively simple for an active developer:

- Build the program `filtering_solid_gabor_noise.cpp` against OpenGL, GLUT, GLEW and AntTweakBar.
- Run the program in the same directory as the files `filtering_solid_gabor_noise.frag` and `filtering_solid_gabor_noise.vert`.

## Program Manual

### Menu

- Camera
  - tumble
    Rotates the point of view around the origin.
    (Expand the menu item by clicking on it and drag the sphere.)
  - dolly
    Moves the camera in and out.
    (Enter a value using the keyboard, decrease or increase the value by clicking the - or +, or (recommended) using the "rotoslider" by dragging the dot.)
- Geometry
  - type
    Controls the geometry (plane, cube, sphere, teapot).
- Noise
  - type
    Controls the type of noise (anisotropic, isotropic, hybrid).
  - frequency
    Controls the magnitude of the frequency vector omega.
  - orientation
    Controls the orientation of the frequency vector omega.
    (Expand the menu item by clicking on it and drag the arrow.)
  - omega[0], omega[1], omega[2]
    Displays omega, the frequency vector, which is controlled using the parameters above.
  - bandwidth
    Controls the bandwidth a of the noise.
    The value of this parameter corresponds to the bandwidth of the noise in log2 frequency space.
    Manipulating this parameter is more intuitive than manipulating a directly.
  - a
    Displays a, the bandwidth, which is controlled using the parameter above.
  - truncate
    Controls the radius of the kernels r.
    The value of this parameter corresponds to the relative magnitude of the Gaussian of the Gabor kernel where the kernel is truncated.
    Manipulating this parameter is more intuitive than manipulating r directly.
  - r
    Displays r, the radius of the kernels.
  - impulses
    Controls the impulse density lambda.
    The value of this parameter corresponds to the number of impulses in an an area the size of the truncated kernel.
    Manipulating this parameter is more intuitive than manipulating lambda directly.
  - lambda
    Displays lambda.
  - seed
    Controls the seed.
  - filter
    Controls filtering (off, on).

### Speed vs. Quality

For faster (but lower-quality) noise:

- Set the noise type to anisotropic.
- Lower the number of noise impulses.
- Disable filtering.

Also lower the number of shaded pixels by moving the camera out using the camera tumble and setting the geometry type to plane.

For higher-quality (but slower) noise, do the inverse.

## Reproducing our Results

### Filtering

- Restart the program to reset all parameters.
- Set the noise frequency to 0.25.
- Rotate the cube almost 90 degrees to the right using the camera tumble.
- Observe severe aliasing artifacts at the right face of the cube.
- Enable noise filtering.
- Observe that the aliasing artifacts disappear.
- Use this as a starting point to explore other parameter settings.

### Continuity over Sharp edges

- Restart the program to reset all parameters.
- Set the noise type to isotropic.
- Set the noise frequency to 0.01.
- Rotate the cube and observe the continuity of the noise over the sharp edges.
- Use this as a starting point to explore other parameter settings.