\fresh{}
\section{Media engine}

In order to conduct user study of 3D streaming systems on mobile devices, we must ensure that our system is running at a reasonable framerate.

\subsection{Restructuration of the 3D content on the client}

To sum up the bottlenecks of performance described in Section~\ref{i:rendering}, we need to keep the least amount of objects possible, to do the least amount of \texttt{glDrawArray}, but we want to have separated objects so that frustum culling is efficient.
In our NVE, there are more than a thousand materials and they are reused all over the scene.
Creating local objects to benefit from frustum culling is not an option in our case, so we merge all faces that share material and draw them in a single \texttt{glDrawArray} call.

In order to do so, the content that was previously structured in a way to optimize streaming is restructured live on the client to optimize rendering, as show in Figure~\ref{d3:render-structure}.
That way, when geometry is downloaded for a new material, we know how much space we should allocate for the buffers, and when geometry is downloaded for a material already allocated, we just edit the buffer and transmit it to the GPU\@.

\begin{figure}[ht]
    \centering

    \begin{tikzpicture}

        \node[align=center] at(1.5, -1) {DASH-3D\\Structure};

        \node at(-1.5, -3) {\texttt{seg0.obj}};
        \draw[fill=Pink] (0, -2) rectangle (3, -3);
        \node at(1.5, -2.5) {Material 1};
        \draw[fill=PaleGreen] (0, -3) rectangle (3, -4);
        \node at(1.5, -3.5) {Material 2};

        \node at(-1.5, -6) {\texttt{seg1.obj}};
        \draw[fill=Pink] (0, -5) rectangle (3, -7);
        \node at(1.5, -6) {Material 1};

        \node at(-1.5, -9) {\texttt{seg2.obj}};
        \draw[fill=PaleGreen] (0, -8) rectangle (3, -9);
        \node at(1.5, -8.5) {Material 2};
        \draw[fill=LightBlue] (0, -9) rectangle (3, -10);
        \node at(1.5, -9.5) {Material 3};

        \node[align=center] at (7.5, -1) {Renderer\\Structure};

        \node at(10.5, -3.5) {Object 1};
        \draw[fill=Pink] (6, -2) rectangle (9, -5);
        \node at(7.5, -3.5) {Material 1};

        \node at(10.5, -7) {Object 2};
        \draw[fill=PaleGreen] (6, -6) rectangle (9, -8);
        \node at(7.5, -7) {Material 2};

        \node at(10.5, -9.5) {Object 3};
        \draw[fill=LightBlue] (6, -9) rectangle (9, -10);
        \node at(7.5, -9.5) {Material 3};

        \node[minimum width=3cm,minimum height=2cm] (O1) at (7.5, -3.5) {};
        \draw[-{Latex[length=3mm]}, color=FireBrick] (3, -2.5) -- (O1);
        \draw[-{Latex[length=3mm]}, color=FireBrick] (3, -6) -- (O1);

        \node[minimum width=3cm,minimum height=2cm] (O2) at (7.5, -7) {};
        \draw[-{Latex[length=3mm]}, color=DarkGreen] (3, -3.5) -- (O2);
        \draw[-{Latex[length=3mm]}, color=DarkGreen] (3, -8.5) -- (O2);

        \node[minimum width=3cm,minimum height=2cm] (O3) at (7.5, -9.5) {};
        \draw[-{Latex[length=3mm]}, color=RoyalBlue] (3, -9.5) -- (O3);

        \node at (1.5, -10.75) {$\vdots$};
        \node at (7.5, -10.75) {$\vdots$};
    \end{tikzpicture}

    \caption{Restructuration of the content on the renderer\label{d3:render-structure}}
\end{figure}
