%\newcommand{\CLASSINPUTtoptextmargin}{1.5cm}
\newcommand{\CLASSINPUTbottomtextmargin}{2.5cm}
\documentclass[conference, a4paper, hidelinks]{IEEEtran}

% BEGIN: DO NOT CHANGE HERE!
    \pagenumbering{gobble}
    \makeatletter
    \def\@maketitle{%
    \newpage
    \null
    \begin{center}%
        {\LARGE \textsf \@title \par} % Adjust the font size and style of the title
        \vskip 0.5em % Adjust the vertical spacing after the title
        {\small \textsf{Proseminar Differentiable Programming} \par}
        \vskip 0.5em % Adjust the vertical spacing after the subtitle
        {\small \textsf \@author \par }
        \vskip 0.5em % Adjust the vertical spacing after the author
        {\small \textsf \@date \par} % Adjust the font size and style of the date
    \end{center}%
    \par
    \vskip -1em % Adjust the vertical spacing after the title block
    }
    \makeatother
% END: DO NOT CHANGE HERE!

\title{Differentiable Monte Carlo Ray Tracing through Edge Sampling}
\author{Clemens Dautermann}
\date{\today} % Put the date of your talk here

% Bibliography setup
\usepackage[citestyle=numeric,bibstyle=numeric,hyperref,backend=biber]{biblatex}
\addbibresource{bibliography.bib}

\usepackage[english]{babel}
\usepackage{csquotes}
\usepackage{amsmath}

\usepackage{tikz}
\usetikzlibrary{calc,patterns,angles,quotes,shapes,arrows, positioning,overlay-beamer-styles}

\usepackage{xcolor}
\usepackage{graphicx}

\usepackage{hyperref}
% Do not add anything here
\begin{document}

\maketitle

\begin{abstract}
    Differentiable Programming is a technique frequently used to solve optimization problems by minimizing some kind of error function. To do this though the error function needs to be differentiable with respect to the parameters that are to be optimized. This is usually not the case with ray tracing. This report will explain why this problem occurs and present the method to tackle it developed in \cite{ACM:diffable_raytracing}.
\end{abstract}

\section{Introduction}

One of the main tasks in Computer Graphics is image synthesis. This means ``given a 3D scene, output an image depicting the scene``. Often it is required for the image to be as realistic as possible, meaning as close to a picture of the scene as if it was set in the real world as possible. This is most commonly achieved using the ray tracing algorithm and is a well studied problem. Doing this in a differentiable way however is much less trivial. This stems from the fact that the rendering integral (equation \ref{eq:rendering_integral}) is not differentiable in certain well defined places. Because being able to ray trace an image differentiably has numerous applications a solution to this problem has been proposed in \cite{ACM:diffable_raytracing}. This report will go into how exactly this problem arises, how it can be mitigated and what some of the applications of differentiable ray tracing are.

\section{Ray Tracing}
To formalize the problem of photo realistic image synthesis, an equation has been proposed by Kajiya in 1986 \cite{ACM:rendering_equation}. This equation captures physical light transport for a scene and if solved yields the color for a given point in the scene accounting for most physical light transport phenomena.
\begin{figure}[h]
    \centering
    \begin{equation}
        I(x,x^{\prime})=
        g(x,x')
        \left[
        \epsilon(x,x')+\int_S \rho(x,x',x'')I(x',x'')dx''
        \right]
        \notag
    \label{eq:rendering_integral}
    \end{equation}
    \caption{The rendering equation capturing physical light transport. It assigns  a value to the the Intensity of light transported from a point $x$ to a point $x^\prime$. The geometry term $g$ will be discussed later. The term $\epsilon$ accounts for the emissivity of the point $x$. The integral term represents all light scattered from any other point in the scene towards the point $x$. The integral domain $S$ contains all points in the scene.}
\end{figure}
This equation (equation \ref{eq:rendering_integral}) is now widely recognized as ``the rendering integral``. It is not analytically solvable and is thus most commonly solved using Monte-Carlo integration - i.e. ray tracing. Ray tracing works by backtracking light rays from the light sources in the scene and thus simulate physically realistic lighting.\\
To do this, rays are cast from the camera, through each pixel in the camera frustum. The intersection point with the scene geometry $x$ is calculated for each ray and material properties (e.g. color, emissivity etc.) are taken into account to calculate the pixel color. From this point more rays are drawn towards each light source. If the light source is visible, its light contributes to the pixel color as well. To account for indirect lighting the ray ``bounces around``, yielding a color for some of the points scattering lights towards $x$. This approximates the integral term in equation \ref{eq:rendering_integral}.\\
Differentiable ray tracing is the task of calculating the gradient of this process with respect to \emph{any} scene parameter.

\section{Problems with differentiability}
The geometry term $g(x,x^\prime)$ in equation \ref{eq:rendering_integral} is the main problem when it comes do differentiating the rendering integral. This term is 1 iff $x$ is visible from $x^\prime$, 0 otherwise.
\begin{figure}
    \centering
    \include{handout/diagrams/diagramm_occlusion}
    \caption{Caption}
    \label{fig:enter-label}
\end{figure}

% BIBLIOGRAPHY
\nocite{*} % List all entries of the .bib file, even those not cited in the main body
\printbibliography


\end{document}