\documentclass{article}

\begin{document}
\begin{flushright} 
        \begin{large}
                \textbf{OSG Depth Peeling} \\
        \end{large}
        \bigskip
        
        Steffen Frey
\end{flushright}
\hrule

\section*{Introduction}
The program is about depth peeling based illustration. The idea behind it is to be able to use normal models and make occluded features visible. This is done by incrementally peeling through the object, which means that the model is rendered iteratively and that has already been rendered is successively thrown away and only the remainder is rendered. This can be useful to generate technical drawings that can be adjusted and rotated interactively by the user, or just to do some fun NPR-stuff.

\section*{Manual}
\subsection*{Getting Started}
In order to run the program, you need at least an ATI X*** or an NVidia 6***. The program doesn't check yet for the needed functionality(I know, this needs to be done).
Prerequesite for compiling and linking the program is \emph{OpenSceneGraph} and a proper setup of these environment variables: \texttt{OPENTHREADS\_INC\_DIR}, \texttt{OPENTHREADS\_LIB\_DIR}, \texttt{PRODUCER\_INC\_DIR}, \texttt{PRODUCER\_LIB\_DIR}, \texttt{OSG\_INC\_DIR} and \texttt{OSG\_LIB\_DIR}.(This can be changed in the \texttt{Makefile}).
For compiling the program just run \texttt{make depend} followed by \texttt{make}.
The program is tested to work with \emph{OpenSceneGraphs} stable version 1.2 and CVS version(as of 5.02.07), although a bit renaming is required in this case(e.g. CameraNode to Camera).

\subsection*{Usage}
\texttt{./DePeeViewer model}. A model can be of any type of format that \emph{OpenSceneGraph} supports. \\
\\
\begin{tabular}{|c|c|}
\hline
a & add depth peeling pass \\
r & remove depth peeling pass \\
c & toggle display of color \\
e & toggle display of edges \\
s & toggle sketchiness \\
y & if sketchiness is enabled, toggle use of crayon \\
SPACE & toggle automatic rotation of object \\
+ & increase sketchiness \\
- & decrease sketchiness \\
\hline
\end{tabular}
\\
\\
Most of these shortcuts can be found in the head up display. Just press a character that is enclosed by brackets.

Furthermore, the object can be rotated by pressing any mouse button and moving the mouse.

\section*{Implementation}
\subsection*{General}
As hinted above, the underlying approach for the application is depth peeling. 
Depending on how deep the user wants to peel into the object, a certain amount of depth peeling passes is needed. A depth peeling pass in this implementation consists of minimally one (even though this wouldn't make much sense, because no real result would be produced) to maximally three render passes(only the last depth peeling pass can have three depth peeling passes).
\begin{description}
\item[Normal and Depth Render Pass] Renders the normals and depth values of the current depth peeling level to a texture.
\item[Edge Render Pass] Uses the current depth and normal map to create an edge map. If there is a previously rendered edge map, new edges are added up with the old ones.  
\item[Color Render Pass] Blends the various color layers. A layer is only used to render if it's depth value is equal or below the corresponding depth value in the depth map. Only one color rendering step is needed, thus only the last depth peeling pass potentially includes a color render pass. 
\end{description}
The amount of depth peeling passes can be changed interactively by the user. The rendering passes are adjusted accordingly in a dynamic fashion.

Additional to the depth peeling passes there is a final pass rendering pass and a post render pass to render the head up display.

The final rendering pass is used to combine edge and color maps and add sketchiness, whereas the the head up display shows status information like the amount of depth peeling passes and the current frame rate.

The total amount of render passes can be calculted by this formula
\begin{displaymath}
  \#depth peeling passes * (1 + isEdgy?) + isColored? + 2
\end{displaymath}

The actual rendering is controlled by \emph{GLSL} shader programs, and in particular by fragment shader programs.
Due to the fact that most of the work in this program is done by the fragment shader of the GPU, performance highly relies on the graphics card. Newer generations of graphics cards, or even the same graphics chip just running with a higher tact rate result in a remarkably higher frame rates. 

For a more detailed description of the implementation please consult the doxygen-generated documentation.

\subsection*{TODO}
\begin{itemize}
\item If a modelled object is textured, using this texture is not enabled. Colormap only uses the attached vertex color.
\item Program doesn't check whether graphics card is capable of executing it correctly
\end{itemize}

\end{document}
