\section{This Method}
% \begin{frame}
%     \centering
%     \Huge
%     This Method
% \end{frame}
\subsection{Edge Sampling}
\begin{frame}{Edge Sampling}
    \setbeamercovered{transparent}
    \begin{block}{Assumptions}
        \begin{itemize}
            \item Continuous parameter set
            \item Triangle meshes
            \item No interpenetrating triangles
            \item No point lights, no perfectly specular surfaces
            \item Ignore time domain
        \end{itemize}
    \end{block}
        \pause{}
    \begin{block}{Idea}
        \begin{itemize}
            \item Traditional sampling for continuous regions
            \item Edge sampling for the discontinuous part
        \end{itemize}
    \end{block}
\end{frame}

\begin{frame}{Edge Sampling~-~Illustration}
    \centering
    \input{diagrams/edge_sampling}
\end{frame}

\begin{frame}{Edge Sampling~-~Half Spaces}
    \begin{minipage}{0.5\linewidth}
        \input{diagrams/halfspaces}
    \end{minipage}
    \begin{minipage}{0.45\linewidth}
        \begin{block}{Principle}
            \begin{itemize}
                \item Edge divides scene into two halfspaces
                \item Calculate color in either halfspace
                \item Calculate gradient based on color difference
                \item Occlusion $\implies$ No color difference $\implies\nabla=0$
            \end{itemize}
        \end{block}
    \end{minipage}
\end{frame}

\begin{frame}[t]{Edge Sampling~-~Math Background}
        Color:
        \only<1>{
        \[
            I = \underbrace{\iint}_{\text{Screen space domain}}
            \underbrace{f(x,y;\Phi)}_{\text{Scene function; Parameter set } \Phi}dxdy
        \]
        }

        \only<2-> {
        \[
            I = \iint f(x,y;\Phi)dxdy
        \]
        }

        \only<2> {
        Use half spaces to rewrite integral:
        \[
            \sum_i\iint
            \underbrace{\theta(}_{\text{Step function}}
            \underbrace{\alpha_i(x,y)}_{\text{Edge equation formed by the triangle edge}})
            \underbrace{f_i(x,y)}_{\text{Half space (may contain Heaviside step functions itself)}}
        \]
        }
    
        \only<3->{
        Use half spaces to rewrite integral:
        \[
            \sum_i\iint\theta(\alpha_i(x,y))f_i(x,y)
        \]

        Calculate gradient:
        \[
            \nabla\iint\theta(\alpha_i(x,y))f_i(x,y)dxdy = 
            \underbrace{\iint\delta(\alpha_i(x,y))\nabla\alpha_i(x,y)f_i(x,y)dxdy}_{\text{Edges (can be differentiated)}} + 
            \underbrace{\iint\nabla f_i(x,y)\theta(\alpha_i(x,y))dxdy}_{\text{Original pixel integral}}
        \]
        }
        
\end{frame}

\begin{frame}{Inverse Rendering~-~Results in this Paper}
    \begin{block}{Inverse rendering here}
        \begin{itemize}
            \item Parameters: Camera pose, material parameters, light source intensity
            \item Scene: Strong indirect illumination and non lambertian materials
            \item Initial guess: Almost all objects white, arbitrary camera pose
            \item 177 parameters
            \item Loss function: Absolute difference
            \item ADAM optimizer
            \item Start resolution of $64\times 64$, linearly increase to $512\times 512$ in 8 steps\\
            $\implies$ Avoid local minima of the loss function
        \end{itemize}
    \end{block}
\end{frame}

\begin{frame}{Inverse Rendering~-~Results in this Paper}
\begin{center}
    \begin{minipage}{0.25\linewidth}
    \begin{figure}
        \centering
        \includegraphics[width=\linewidth]{img/results/guess.png}
        \caption{Initial guess}\label{fig:results-guess}
    \end{figure}
    \end{minipage}
    \hspace{2mm}
    \begin{minipage}{0.25\linewidth}
    \begin{figure}
        \centering
        \includegraphics[width=\linewidth]{img/results/photo.png}
        \caption{Target (photograph)}\label{fig:results-target}
    \end{figure}
    \end{minipage}
    \hspace{2mm}
    \begin{minipage}{0.25\linewidth}
    \begin{figure}
        \centering
        \includegraphics[width=\linewidth]{img/results/result.png}
        \caption{Optimized image}\label{fig:results-optimized}
    \end{figure}
    \end{minipage}
\end{center}
\end{frame}

\begin{frame}
    \begin{figure}
        \centering
    \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/triangles/img-027.png}
    \end{minipage}
    \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/shade/img-028.png}
    \end{minipage}
    \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/glossy/img-029.png}
    \end{minipage}
    \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/glossy_recv/img-030.png}
    \end{minipage}
        \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/specular/img-031.png}
    \end{minipage}
        \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/global_illumination/img-032.png}
    \end{minipage}
    \begin{minipage}{0.1\linewidth}
        \caption{initial guess}\label{fig:grid_init_guess}
    \end{minipage}
    \end{figure}
%%%%%%%%%%%%%%%%%%%%%%%%% second row %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \begin{figure}
    \centering
    \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/triangles/img-033.png}
    \end{minipage}
    \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/shade/img-034.png}
    \end{minipage}
    \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/glossy/img-035.png}
    \end{minipage}
    \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/glossy_recv/img-036.png}
    \end{minipage}
        \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/specular/img-037.png}
    \end{minipage}
        \begin{minipage}{0.14\linewidth}
        \includegraphics[width=\linewidth]{img/render_optimization/global_illumination/img-038.png}
    \end{minipage}
    \begin{minipage}{0.1\linewidth}
        \caption{target images}\label{fig:grid_target}
    \end{minipage}
    \end{figure}
    %%%%%%%%%%%%%%%%%%%%%%%%% third row %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \begin{figure}
    \centering
    \begin{minipage}{0.15\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/render_optimization/triangles/img-039.png}
            \caption{primary occlusion}
        \end{figure}
    \end{minipage}
    \begin{minipage}{0.14\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/render_optimization/shade/img-040.png}
            \caption{shadow}
        \end{figure}
    \end{minipage}
    \begin{minipage}{0.14\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/render_optimization/glossy/img-041.png}
             \caption{glossy}
        \end{figure}
    \end{minipage}
    \begin{minipage}{0.14\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/render_optimization/glossy_recv/img-042.png}
            \caption{glossy receiver}
        \end{figure}
    \end{minipage}
    \begin{minipage}{0.14\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/render_optimization/specular/img-043.png}
            \caption{near-specular}
        \end{figure}
    \end{minipage}
        \begin{minipage}{0.15\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/render_optimization/global_illumination/img-044.png}
            \caption{global illumination}
        \end{figure}
    \end{minipage}
    \begin{minipage}{0.08\linewidth}
        \caption{optimized result}\label{fig:grid_optimized}
    \end{minipage}
    \end{figure}
\end{frame}

\begin{frame}{Inverse Rendering~-~Example from this Paper}
    \centering
    \begin{minipage}{0.19\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/teapot_video/teapot_init.png}
            \vspace{0mm}
            \caption{initial guess}\label{fig:teapot_init}
        \end{figure}
    \end{minipage}
        \begin{minipage}{0.19\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/teapot_video/teapot_init_diff.png}
            \caption{difference\\
            initial $\leftrightarrow$ target}\label{fig:teapot_init_diff}
        \end{figure}
    \end{minipage}
        \begin{minipage}{0.19\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/teapot_video/teapot_target.png}
            \vspace{0mm}
            \caption{target image}\label{fig:teapot_target}
        \end{figure}
    \end{minipage}
        \begin{minipage}{0.19\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/teapot_video/teapot_final_diff.png}
            \caption{difference\\
            final $\leftrightarrow$ target}\label{fig:teapot_final_diff}
        \end{figure}
    \end{minipage}
    \begin{minipage}{0.19\linewidth}
        \begin{figure}
            \centering
            \includegraphics[width=\linewidth]{img/teapot_video/teapot_final.png}
            \vspace{0mm}
            \caption{final image}\label{fig:teapot_final}
        \end{figure}
    \end{minipage}
\end{frame}

\begin{frame}{Inverse Rendering~-~Example from this Paper}
        \centering
  \includemedia[
    width=0.62\linewidth,height=0.35\linewidth,
    activate=onclick,
    addresource=teapot.mp4,
    playbutton=fancy,
    transparent,
    passcontext,
    flashvars={
        source=teapot.mp4
        &autoPlay=true
    }
  ]{}{VPlayer.swf}
  \\ 
  All media in this section taken from~\cite{ACM:diffable_raytracing}
\end{frame}

\subsection{Conclusion~-~What can this Method do?}
\begin{frame}{Conclusion}
    \setbeamercovered{transparent}
    \begin{block}{Possibilities}
        \begin{itemize}
            \item Differentiate with respect to \emph{any} scene parameter
            \item Arbitrary non-dirac-materials
            \item Global illumination, occlusion, shadows etc\ldots
            \item Automatic differentiation (PyTorch) $\rightarrow$ Inverse rendering
        \end{itemize}
    \end{block}

    \pause{}
    
    \begin{block}{Some Limitations}
        \begin{itemize}
            \item Performance
            \item Time domain (animations)
            \item Interpenetrating meshes
            \item Non-differentiable shaders
        \end{itemize}
    \end{block}
\end{frame}