\documentclass[10pt,a4paper]{article} % Packages \usepackage{fancyhdr} % For header and footer \usepackage{multicol} % Allows multicols in tables \usepackage{tabularx} % Intelligent column widths \usepackage{tabulary} % Used in header and footer \usepackage{hhline} % Border under tables \usepackage{graphicx} % For images \usepackage{xcolor} % For hex colours %\usepackage[utf8x]{inputenc} % For unicode character support \usepackage[T1]{fontenc} % Without this we get weird character replacements \usepackage{colortbl} % For coloured tables \usepackage{setspace} % For line height \usepackage{lastpage} % Needed for total page number \usepackage{seqsplit} % Splits long words. %\usepackage{opensans} % Can't make this work so far. Shame. Would be lovely. \usepackage[normalem]{ulem} % For underlining links % Most of the following are not required for the majority % of cheat sheets but are needed for some symbol support. \usepackage{amsmath} % Symbols \usepackage{MnSymbol} % Symbols \usepackage{wasysym} % Symbols %\usepackage[english,german,french,spanish,italian]{babel} % Languages % Document Info \author{Jonathan\_Walsh1999} \pdfinfo{ /Title (maths-and-tech.pdf) /Creator (Cheatography) /Author (Jonathan\_Walsh1999) /Subject (Maths and Tech Cheat Sheet) } % Lengths and widths \addtolength{\textwidth}{6cm} \addtolength{\textheight}{-1cm} \addtolength{\hoffset}{-3cm} \addtolength{\voffset}{-2cm} \setlength{\tabcolsep}{0.2cm} % Space between columns \setlength{\headsep}{-12pt} % Reduce space between header and content \setlength{\headheight}{85pt} % If less, LaTeX automatically increases it \renewcommand{\footrulewidth}{0pt} % Remove footer line \renewcommand{\headrulewidth}{0pt} % Remove header line \renewcommand{\seqinsert}{\ifmmode\allowbreak\else\-\fi} % Hyphens in seqsplit % This two commands together give roughly % the right line height in the tables \renewcommand{\arraystretch}{1.3} \onehalfspacing % Commands \newcommand{\SetRowColor}[1]{\noalign{\gdef\RowColorName{#1}}\rowcolor{\RowColorName}} % Shortcut for row colour \newcommand{\mymulticolumn}[3]{\multicolumn{#1}{>{\columncolor{\RowColorName}}#2}{#3}} % For coloured multi-cols \newcolumntype{x}[1]{>{\raggedright}p{#1}} % New column types for ragged-right paragraph columns \newcommand{\tn}{\tabularnewline} % Required as custom column type in use % Font and Colours \definecolor{HeadBackground}{HTML}{333333} \definecolor{FootBackground}{HTML}{666666} \definecolor{TextColor}{HTML}{333333} \definecolor{DarkBackground}{HTML}{0258A3} \definecolor{LightBackground}{HTML}{EFF4F9} \renewcommand{\familydefault}{\sfdefault} \color{TextColor} % Header and Footer \pagestyle{fancy} \fancyhead{} % Set header to blank \fancyfoot{} % Set footer to blank \fancyhead[L]{ \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{C} \SetRowColor{DarkBackground} \vspace{-7pt} {\parbox{\dimexpr\textwidth-2\fboxsep\relax}{\noindent \hspace*{-6pt}\includegraphics[width=5.8cm]{/web/www.cheatography.com/public/images/cheatography_logo.pdf}} } \end{tabulary} \columnbreak \begin{tabulary}{11cm}{L} \vspace{-2pt}\large{\bf{\textcolor{DarkBackground}{\textrm{Maths and Tech Cheat Sheet}}}} \\ \normalsize{by \textcolor{DarkBackground}{Jonathan\_Walsh1999} via \textcolor{DarkBackground}{\uline{cheatography.com/81859/cs/22389/}}} \end{tabulary} \end{multicols}} \fancyfoot[L]{ \footnotesize \noindent \begin{multicols}{3} \begin{tabulary}{5.8cm}{LL} \SetRowColor{FootBackground} \mymulticolumn{2}{p{5.377cm}}{\bf\textcolor{white}{Cheatographer}} \\ \vspace{-2pt}Jonathan\_Walsh1999 \\ \uline{cheatography.com/jonathan-walsh1999} \\ \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Cheat Sheet}} \\ \vspace{-2pt}Not Yet Published.\\ Updated 11th May, 2020.\\ Page {\thepage} of \pageref{LastPage}. \end{tabulary} \vfill \columnbreak \begin{tabulary}{5.8cm}{L} \SetRowColor{FootBackground} \mymulticolumn{1}{p{5.377cm}}{\bf\textcolor{white}{Sponsor}} \\ \SetRowColor{white} \vspace{-5pt} %\includegraphics[width=48px,height=48px]{dave.jpeg} Measure your website readability!\\ www.readability-score.com \end{tabulary} \end{multicols}} \begin{document} \raggedright \raggedcolumns % Set font size to small. Switch to any value % from this page to resize cheat sheet text: % www.emerson.emory.edu/services/latex/latex_169.html \footnotesize % Small font. \begin{multicols*}{3} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Quaternions}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{A quaternion is a 4 element vector that can used to encode any rotation in a 3D coordinate system.} \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{q}} = ({\emph{w, x, y, z}}) or {\bf{q}} = (w, v) where v = (x, y, z)} \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{q}} = (w, v) = (cos(theta/2), sing(theta/2)r) & r and theta form an axis-angle rotation. \tn % Row Count 7 (+ 3) % Row 3 \SetRowColor{white} Normalise Quaternions: & w\textasciicircum{}2\textasciicircum{} + x\textasciicircum{}2\textasciicircum{} + y\textasciicircum{}2\textasciicircum{} + z\textasciicircum{}2\textasciicircum{} = 1 \tn % Row Count 9 (+ 2) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Pros}}} \tn % Row Count 10 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Quaternions can easily be combined together, used to transform points/vectors and can be interpolated very easily. Interpolation is vital for animation, which is far more difficult with matrices.} \tn % Row Count 14 (+ 4) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Quaternions only use 4 floats, 12 less then 4x4 matrices.} \tn % Row Count 16 (+ 2) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Cons}}} \tn % Row Count 17 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{They lack hardware support, therefore they need to be converted from matrices to them and back to matrices again.} \tn % Row Count 20 (+ 3) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Formulae 1}}} \tn % Row Count 21 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Quaternion can be converted to a matrix} \tn % Row Count 22 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{If {\bf{q}} = (w, x, y, z), then} \tn % Row Count 23 (+ 1) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{1st row - Mq = {[}1-2y\textasciicircum{}2\textasciicircum{} - 2z\textasciicircum{}2\textasciicircum{} 2xy+2wz 2xz - 2wy 0{]}} \tn % Row Count 25 (+ 2) % Row 13 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{2nd row - Mq = {[}2xy - 2wz 1-2x\textasciicircum{}2\textasciicircum{} - 2z\textasciicircum{}2\textasciicircum{} 2yz + 2wx 0{]}} \tn % Row Count 27 (+ 2) % Row 14 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{3rd row - Mq = {[}2xz + 2wy 2yz - 2wx 1-2x\textasciicircum{}2\textasciicircum{} - 2y\textasciicircum{}2\textasciicircum{} 0{]}} \tn % Row Count 29 (+ 2) % Row 15 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{4th row - Mq = {[}0 0 0 1{]}} \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Quaternions (cont)}} \tn % Row 16 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Multiply result by 1/w\textasciicircum{}2\textasciicircum{} + x\textasciicircum{}2\textasciicircum{} + y\textasciicircum{}2\textasciicircum{} + z\textasciicircum{}2\textasciicircum{} if {\bf{q}} is not normalised} \tn % Row Count 2 (+ 2) % Row 17 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Can be expensive but can be simplified in code. Refer to Van Verth for more details.} \tn % Row Count 4 (+ 2) % Row 18 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Formulae 2}}} \tn % Row Count 5 (+ 1) % Row 19 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Quaternions can be added and scaled} \tn % Row Count 6 (+ 1) % Row 20 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Addition: (w1, x1, y1, z1) + (w2, x2, y2, z2) = (w1 + w2, x1 + x2, y1 + y2, z1 + z2)} \tn % Row Count 8 (+ 2) % Row 21 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Multiplication: {\bf{q1, q2}} = (w, {\bf{v}}) = (w1w2 - {\bf{v1 . v2}}, w1{\bf{v2}} + w2{\bf{v1}} + {\bf{v2}} X {\bf{v1}})} \tn % Row Count 11 (+ 3) % Row 22 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\emph{Note that X means cross product and . means dot product}}} \tn % Row Count 13 (+ 2) % Row 23 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Same effect as multiplying matrices, order important} \tn % Row Count 15 (+ 2) % Row 24 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{This is potentially much faster than matrix multiplication} \tn % Row Count 17 (+ 2) % Row 25 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Formulae 3}}} \tn % Row Count 18 (+ 1) % Row 26 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Inverse}} of quaternion where rotation is in the opposite direction.} \tn % Row Count 20 (+ 2) % Row 27 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{q}}\textasciicircum{}-1\textasciicircum{} = (w, {\bf{-v}})} \tn % Row Count 21 (+ 1) % Row 28 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Quaternion must be normalised before formula is used} \tn % Row Count 23 (+ 2) % Row 29 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Much faster than matrix equivalent} \tn % Row Count 24 (+ 1) % Row 30 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Vector can be represented as quaternions. Set w to 0} \tn % Row Count 26 (+ 2) % Row 31 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{i.e. Vector {\bf{p}} = (x, y , z) = (0, x, y, z) as a quaternion} \tn % Row Count 28 (+ 2) % Row 32 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Formulae 4}}} \tn % Row Count 29 (+ 1) % Row 33 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Rotate}} a vertex or vector {\bf{p}} by a quaternion {\bf{q}} = (w, {\bf{v}})} \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Quaternions (cont)}} \tn % Row 34 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Rotate q ({\bf{p}}) = {\bf{q\textasciicircum{}-1\textasciicircum{}pq}} = (2w\textasciicircum{}2\textasciicircum{} - 1){\bf{p}} + 2({\bf{v . p)v}} + 2w({\bf{v X p}})} \tn % Row Count 2 (+ 2) % Row 35 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\emph{Note that X means cross product and . means dot product}}} \tn % Row Count 4 (+ 2) % Row 36 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Slower than matrix equivalent} \tn % Row Count 5 (+ 1) % Row 37 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Summary}}} \tn % Row Count 6 (+ 1) % Row 38 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Quaternions can perfrom similar operations to matrices with comparable performance although you need to convert to/from matrices and they can't store positioning/scaling} \tn % Row Count 10 (+ 4) % Row 39 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Therefore, there is no compelling reason to use them yet.} \tn % Row Count 12 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.28942 cm} x{2.68758 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Emerging Tech for games}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Hardware Capabilities}} & Screen res/refresh rates \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} & Depth and Stencil buffer formats \tn % Row Count 4 (+ 2) % Row 2 \SetRowColor{LightBackground} & Anti-aliasing \tn % Row Count 5 (+ 1) % Row 3 \SetRowColor{white} & Texture Capabilities \tn % Row Count 6 (+ 1) % Row 4 \SetRowColor{LightBackground} {\bf{Testing Capabilities}} & DX 10+ define min spec \tn % Row Count 8 (+ 2) % Row 5 \SetRowColor{white} & Still need some testing to check for advance features \tn % Row Count 11 (+ 3) % Row 6 \SetRowColor{LightBackground} & Consoles are largely unaffected by such matters as specs are fixed unlike PCs \tn % Row Count 15 (+ 4) % Row 7 \SetRowColor{white} & Still need to check for storage size, peripherals etc. \tn % Row Count 18 (+ 3) % Row 8 \SetRowColor{LightBackground} {\bf{Shader Capabilities}} & Shaders complied to machine code \tn % Row Count 20 (+ 2) % Row 9 \SetRowColor{white} & Shader version defines instruction set available \tn % Row Count 23 (+ 3) % Row 10 \SetRowColor{LightBackground} & Higher shader versions have more instructions like for and if \tn % Row Count 26 (+ 3) % Row 11 \SetRowColor{white} & Have more registers \tn % Row Count 27 (+ 1) % Row 12 \SetRowColor{LightBackground} & Should provide alternate shaders for high and low spec machines \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.28942 cm} x{2.68758 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Emerging Tech for games (cont)}} \tn % Row 13 \SetRowColor{LightBackground} {\bf{Multiple Passes}} & Complex material may need several passes in the shaders \tn % Row Count 3 (+ 3) % Row 14 \SetRowColor{white} & So that one texture can be rendered through different shaders adding multiple postprocessing effects for example \tn % Row Count 9 (+ 6) % Row 15 \SetRowColor{LightBackground} {\bf{Effect files for capabilities}} & Use .fx files we can collect together shader passes and their render states into techniques \tn % Row Count 14 (+ 5) % Row 16 \SetRowColor{white} & Provide a range of techniques for different hardware specifications \tn % Row Count 18 (+ 4) % Row 17 \SetRowColor{LightBackground} & If any one pass in a technique fails capability testing then degrade to simpler technique \tn % Row Count 23 (+ 5) % Row 18 \SetRowColor{white} & The DX effects files system makes this quite simple. Example shown in lecture slides \tn % Row Count 27 (+ 4) % Row 19 \SetRowColor{LightBackground} {\bf{Geometry Shaders}} & This shader processes primitives e.g. triangle, lines \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.28942 cm} x{2.68758 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Emerging Tech for games (cont)}} \tn % Row 20 \SetRowColor{LightBackground} & Like vertex shader but works with multiple vertices at the same time \tn % Row Count 4 (+ 4) % Row 21 \SetRowColor{white} & Operates on the output of vertex shader \tn % Row Count 6 (+ 2) % Row 22 \SetRowColor{LightBackground} & Can also create or delete primitives ie output can be different to input \tn % Row Count 10 (+ 4) % Row 23 \SetRowColor{white} & Input: Array of vertices \tn % Row Count 12 (+ 2) % Row 24 \SetRowColor{LightBackground} & Output: Stream of primitives - Must be specified as a triangle strip for example. Can output any number of primitives. Example shown on lecture slides \tn % Row Count 20 (+ 8) % Row 25 \SetRowColor{white} {\bf{Geometry Shader uses}} & Distorting, animating geometry \tn % Row Count 22 (+ 2) % Row 26 \SetRowColor{LightBackground} & Silhouettes \tn % Row Count 23 (+ 1) % Row 27 \SetRowColor{white} & Creating extra view-dependent gemetry \tn % Row Count 25 (+ 2) % Row 28 \SetRowColor{LightBackground} & Particle systems without instancing \tn % Row Count 27 (+ 2) % Row 29 \SetRowColor{white} {\bf{Geometry shader considerations}} & Not needed for traditional geometry rendering methods so set gs shader to NULL \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.28942 cm} x{2.68758 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Emerging Tech for games (cont)}} \tn % Row 30 \SetRowColor{LightBackground} & Performance of geomtry shaders may be an issue for older GPUs \tn % Row Count 3 (+ 3) % Row 31 \SetRowColor{white} {\bf{Stream Output stage}} & Data ouput from gs can be written back into GPU memory \tn % Row Count 6 (+ 3) % Row 32 \SetRowColor{LightBackground} & Very powerful DX 11 feature \tn % Row Count 8 (+ 2) % Row 33 \SetRowColor{white} & Particle system can be done in 2 passes on the GPU. Pass1 - render with GPU as normal. Pass2 - Update particle positions on GPU, writing back to memory. There ios no CPU inttervention - efficent \tn % Row Count 18 (+ 10) % Row 34 \SetRowColor{LightBackground} {\bf{Stream output Considerations}} & Cannot ouput to same buffer that is being input from \tn % Row Count 21 (+ 3) % Row 35 \SetRowColor{white} & Work around this by using double buffering \tn % Row Count 23 (+ 2) % Row 36 \SetRowColor{LightBackground} & Often need multiple passes to render/update geometry \tn % Row Count 26 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Instancing / Stream-out for Particles}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Instancing Overview}} & Instancing is a method to render many models or sprites in a single API draw call \tn % Row Count 5 (+ 5) % Row 1 \SetRowColor{white} & Previosuly we have rendered each model one at a time \tn % Row Count 8 (+ 3) % Row 2 \SetRowColor{LightBackground} & Send a list of instances with the vertex and index data \tn % Row Count 11 (+ 3) % Row 3 \SetRowColor{white} & List contains what is required to render each model \tn % Row Count 14 (+ 3) % Row 4 \SetRowColor{LightBackground} & Removes per-model state changes \tn % Row Count 16 (+ 2) % Row 5 \SetRowColor{white} & Allows for massively increased batch sizes \tn % Row Count 19 (+ 3) % Row 6 \SetRowColor{LightBackground} {\bf{Instance Buffers / State}} & Instance data stored on GPU is instance buffer \tn % Row Count 22 (+ 3) % Row 7 \SetRowColor{white} & Smplest instance buffer might contain a list of instance positions \tn % Row Count 26 (+ 4) % Row 8 \SetRowColor{LightBackground} & Model defines by verterx/index data rendered once at each psoition in this buffer \tn % Row Count 31 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Instancing / Stream-out for Particles (cont)}} \tn % Row 9 \SetRowColor{LightBackground} & State requirement for instancing can be an issue \tn % Row Count 3 (+ 3) % Row 10 \SetRowColor{white} {\bf{Vertex Shaders for instancing}} & VS often unusual when instancing, depending on what is stored in the instance buffer \tn % Row Count 8 (+ 5) % Row 11 \SetRowColor{LightBackground} & Very common to store some per-instance data and randomise other elements \tn % Row Count 12 (+ 4) % Row 12 \SetRowColor{white} {\bf{Instance Buffer Data}} & Can store more than just position in an instance buffer to give each instance a different look: Rotation, scale or store entire world matrix per-instance \tn % Row Count 20 (+ 8) % Row 13 \SetRowColor{LightBackground} & Can also store mroe unusal data: Seed value to randomise each isntance or entity/paticle data to allow the model to be updated on the GPU using stream-out \tn % Row Count 28 (+ 8) % Row 14 \SetRowColor{white} {\bf{CPU / GPU Instancing}} & Simple instancing is processes using both CPU and GPU. GPU render instances and UPU update instances \tn % Row Count 33 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Instancing / Stream-out for Particles (cont)}} \tn % Row 15 \SetRowColor{LightBackground} & Instance buffer must be made available to both CPU and GPU \tn % Row Count 3 (+ 3) % Row 16 \SetRowColor{white} & Space is reserved forr instance data in both CPU and GPU memory \tn % Row Count 7 (+ 4) % Row 17 \SetRowColor{LightBackground} & Constant copying of instance buffer between GPU and CPU means performance is lower than normal \tn % Row Count 12 (+ 5) % Row 18 \SetRowColor{white} & This is why we might not want to store a world matrix for each instance. Instead the data is often compressed \tn % Row Count 18 (+ 6) % Row 19 \SetRowColor{LightBackground} & Implies VS may have to do additional work to derive the full instance data \tn % Row Count 22 (+ 4) % Row 20 \SetRowColor{white} {\bf{Using Instancing}} & Instancing suits the rendering of large numbers of similar models. ie trees, armies \tn % Row Count 27 (+ 5) % Row 21 \SetRowColor{LightBackground} {\bf{Example: Particle Systems}} & Particles are all similar, often camera-facing sprites \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Instancing / Stream-out for Particles (cont)}} \tn % Row 22 \SetRowColor{LightBackground} & Particle systems are an ideal condidate for instancing \tn % Row Count 3 (+ 3) % Row 23 \SetRowColor{white} & Each particle system stores rendering data such as position, rotation, sclae, colour, alpha \tn % Row Count 8 (+ 5) % Row 24 \SetRowColor{LightBackground} & Each particle requires data to update its position/rotation each frame \tn % Row Count 12 (+ 4) % Row 25 \SetRowColor{white} & Particles are spawned from emitters \tn % Row Count 14 (+ 2) % Row 26 \SetRowColor{LightBackground} & Particles have a life time after which they die \tn % Row Count 17 (+ 3) % Row 27 \SetRowColor{white} & There may be attractors, repulsors and other features added for system \seqsplit{complexity/flexibility} \tn % Row Count 22 (+ 5) % Row 28 \SetRowColor{LightBackground} & Approach: Store render data in instance buffer, store update data, update particles using CPU and then copy entire buffer to GPU, render particles in one vatch using instancing, much faster but still requires CPU/GPU copy \tn % Row Count 34 (+ 12) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Instancing / Stream-out for Particles (cont)}} \tn % Row 29 \SetRowColor{LightBackground} {\bf{Sprite-based particle systems}} & Smart approach for camera facing sprite particles however this method can't be used if the particles are models \tn % Row Count 6 (+ 6) % Row 30 \SetRowColor{white} {\bf{Advanced Instancing}} & Instancing can look poor due to lack of variety \tn % Row Count 9 (+ 3) % Row 31 \SetRowColor{LightBackground} & Complex instancing techniques store more states e,g, animation data, texture offsets, material settings \tn % Row Count 15 (+ 6) % Row 32 \SetRowColor{white} & Able to render models in different poses, with differenttextures and material tweaks. Good for vegetation, crowds etc. \tn % Row Count 21 (+ 6) % Row 33 \SetRowColor{LightBackground} & More complex shaders can help here \tn % Row Count 23 (+ 2) % Row 34 \SetRowColor{white} & LAtest GPUs deal well with this kind of shader \tn % Row Count 26 (+ 3) % Row 35 \SetRowColor{LightBackground} {\bf{Particles without CPU/GPU copy}} & Instancing can be slow due to the CPU update/copy \tn % Row Count 29 (+ 3) % Row 36 \SetRowColor{white} & One simple workaround is to avoid updates. \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Instancing / Stream-out for Particles (cont)}} \tn % Row 37 \SetRowColor{LightBackground} & Drawback is that it is inflexible as paths are alwas the same. e.g. fountain can't be affected by wind \tn % Row Count 6 (+ 6) % Row 38 \SetRowColor{white} {\bf{GPU stream-out for particle update}} & DX 10 supports stream output. Allows GPU to output vertex data back into a vertex buffer instead of sending it on for rendering. \tn % Row Count 13 (+ 7) % Row 39 \SetRowColor{LightBackground} & Using stream output hte GPU can be used to update particles for entities position, rotation etc \tn % Row Count 18 (+ 5) % Row 40 \SetRowColor{white} & Both render and update data is stored GPU only \tn % Row Count 21 (+ 3) % Row 41 \SetRowColor{LightBackground} & Typically we render the models twice. Pass1: Render models using instancing or similar. Pass2: Update models with stream-out - no actual rendering \tn % Row Count 29 (+ 8) % Row 42 \SetRowColor{white} {\bf{Stream output considerations}} & Reads from GPU buffer and writes back to one but can't output to same buffer that is being input from. Work around this by double buffering \tn % Row Count 36 (+ 7) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Instancing / Stream-out for Particles (cont)}} \tn % Row 43 \SetRowColor{LightBackground} & Stream-out allows GPU only entities which is especially effective for particles. \tn % Row Count 4 (+ 4) % Row 44 \SetRowColor{white} & Works expecially well with the sprite-based particles technique \tn % Row Count 8 (+ 4) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{DX 11 - New Features}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{New Features}} & DX 11 was introduced with Win7 \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} & Featres include multithreading, tessellation, compute shaders, shader Model 5.0 and high quality texture compression formats. \tn % Row Count 8 (+ 6) % Row 2 \SetRowColor{LightBackground} {\bf{DX10 DX11 Differences}} & Nearly everything DX10 works with minimal change in DX11 \tn % Row Count 11 (+ 3) % Row 3 \SetRowColor{white} & Device pointer has been split in two. Device pointer for overall control and context pointer for each thread \tn % Row Count 16 (+ 5) % Row 4 \SetRowColor{LightBackground} & .fx not in the provided libraries \tn % Row Count 18 (+ 2) % Row 5 \SetRowColor{white} & DX maths libraries not in 11 \tn % Row Count 20 (+ 2) % Row 6 \SetRowColor{LightBackground} & No font support \tn % Row Count 21 (+ 1) % Row 7 \SetRowColor{white} & Few other minor changes \tn % Row Count 23 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{Pipeline}} & Get two programmable stage: hull and domain shaders \tn % Row Count 26 (+ 3) % Row 9 \SetRowColor{white} & One fixed stage in between: Tessellation \tn % Row Count 28 (+ 2) % Row 10 \SetRowColor{LightBackground} & All three must be used to gether for tessellation otherwise disabled \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{DX 11 - New Features (cont)}} \tn % Row 11 \SetRowColor{LightBackground} {\bf{Tessellation}} & Input geometry made of patches and control points. \tn % Row Count 3 (+ 3) % Row 12 \SetRowColor{white} & Vertex shader processes each control point \tn % Row Count 5 (+ 2) % Row 13 \SetRowColor{LightBackground} & Hull shader also processes each control point but can access all points for a patch. Used for specific transforms. \tn % Row Count 11 (+ 6) % Row 14 \SetRowColor{white} & Hull shader has an associated patch constant function which is called once per patch \tn % Row Count 15 (+ 4) % Row 15 \SetRowColor{LightBackground} & Tessellation stage tessellates the patch as required \tn % Row Count 18 (+ 3) % Row 16 \SetRowColor{white} & Domain shader takes the generic tessellation and control points and creates the final vertices \tn % Row Count 23 (+ 5) % Row 17 \SetRowColor{LightBackground} {\bf{Patches/control points}} & A Patch is a line, triangle or quad which is bent or shaped by some number of control points \tn % Row Count 28 (+ 5) % Row 18 \SetRowColor{white} & DX does not specify the available patch types \tn % Row Count 31 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{DX 11 - New Features (cont)}} \tn % Row 19 \SetRowColor{LightBackground} & This is potentially a huge change for game asset creation \tn % Row Count 3 (+ 3) % Row 20 \SetRowColor{white} {\bf{Hull shader}} & Gets access to all control points for a single patch and can {[}rpcess them in any way \tn % Row Count 7 (+ 4) % Row 21 \SetRowColor{LightBackground} & Output: Final control points used to shape the patch. MAy output greater or fewer points if necessay \tn % Row Count 12 (+ 5) % Row 22 \SetRowColor{white} & Can be used for advanced purposes like approximating complex input splines using simpler output splines. providing per control point info to help the patch constant \tn % Row Count 20 (+ 8) % Row 23 \SetRowColor{LightBackground} {\bf{Patch Constant Function}} & Called once per patch - decides how much to tessellate each patch \tn % Row Count 23 (+ 3) % Row 24 \SetRowColor{white} & Access input control points and the hull shader output control points as array to do its job \tn % Row Count 28 (+ 5) % Row 25 \SetRowColor{LightBackground} {\bf{Tessellation Stage}} & Uses factors specified in the patch \tn % Row Count 30 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{DX 11 - New Features (cont)}} \tn % Row 26 \SetRowColor{LightBackground} & Divides up a unit square, triangle or line based on the factors \tn % Row Count 3 (+ 3) % Row 27 \SetRowColor{white} & works in a generic 0-\textgreater{}1 space \tn % Row Count 5 (+ 2) % Row 28 \SetRowColor{LightBackground} & Several fixed algorithms are avaliable for the tessellation \tn % Row Count 8 (+ 3) % Row 29 \SetRowColor{white} {\bf{Domain Shader}} & Takes control points output from hull shader and the generic vertices output from the tessellation stage \tn % Row Count 13 (+ 5) % Row 30 \SetRowColor{LightBackground} & Combine to create final tessellation for the scene \tn % Row Count 16 (+ 3) % Row 31 \SetRowColor{white} & Exactly whatthis involves depends on the patch type. \tn % Row Count 19 (+ 3) % Row 32 \SetRowColor{LightBackground} {\bf{Distance / Density Variation}} & Common to vary amount of tessellation based on the geometry distance \tn % Row Count 23 (+ 4) % Row 33 \SetRowColor{white} & Distance variation is simpler \tn % Row Count 25 (+ 2) % Row 34 \SetRowColor{LightBackground} & Density variation needs pre-processing \tn % Row Count 27 (+ 2) % Row 35 \SetRowColor{white} {\bf{Water-tight patch seams}} & As as tessellation is varied there are problems with patch seams. - cracks in geometry appear \tn % Row Count 32 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.18988 cm} x{2.78712 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{DX 11 - New Features (cont)}} \tn % Row 36 \SetRowColor{LightBackground} & That is why we can control the edge tessellation separately to ensure all edges have the same tessellation factor. \tn % Row Count 6 (+ 6) % Row 37 \SetRowColor{white} {\bf{Displacement Mapping}} & Adjust height of vertices \tn % Row Count 8 (+ 2) % Row 38 \SetRowColor{LightBackground} & Effectively this parallax mapping done properly \tn % Row Count 11 (+ 3) % Row 39 \SetRowColor{white} & Result has correct silhouettes and no visual problems \tn % Row Count 14 (+ 3) % Row 40 \SetRowColor{LightBackground} {\bf{Technical Issues}} & Tessellation has performance implications \tn % Row Count 16 (+ 2) % Row 41 \SetRowColor{white} & Displacement mapping brings more seam issues \tn % Row Count 18 (+ 2) % Row 42 \SetRowColor{LightBackground} & Models must be designed with displacement in mind \tn % Row Count 21 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{1.89126 cm} x{3.08574 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Sterescopic Rendering}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Depth Perception - 2D}} & Number of depth cues in a 2D image/video \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} & Pos and perspecive \tn % Row Count 3 (+ 1) % Row 2 \SetRowColor{LightBackground} & Known sizes of objects \tn % Row Count 4 (+ 1) % Row 3 \SetRowColor{white} & Visible detail \tn % Row Count 5 (+ 1) % Row 4 \SetRowColor{LightBackground} & Motion Parallax \tn % Row Count 6 (+ 1) % Row 5 \SetRowColor{white} & Shadows and lighting \tn % Row Count 7 (+ 1) % Row 6 \SetRowColor{LightBackground} & Occlusion - nearer objects hide further ones \tn % Row Count 9 (+ 2) % Row 7 \SetRowColor{white} & Atmospheric blurring - distance fog \tn % Row Count 11 (+ 2) % Row 8 \SetRowColor{LightBackground} & None of these require 2 eyes just moncular vision \tn % Row Count 14 (+ 3) % Row 9 \SetRowColor{white} {\bf{Binocular Vision}} & We gain additional cues from having 2 eyes \tn % Row Count 16 (+ 2) % Row 10 \SetRowColor{LightBackground} & Image in each eye is different \tn % Row Count 18 (+ 2) % Row 11 \SetRowColor{white} & Brain resolves into one image with depth \tn % Row Count 20 (+ 2) % Row 12 \SetRowColor{LightBackground} & {\emph{Not sure if this will come up in exam so only covered briefly}} \tn % Row Count 23 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Animation: Interpolation}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Interpolation}} is where a calculation is made to decipher a transform between 2 control transformations of a model} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{An animation is stored as a sequence of key frames (or transforms).} \tn % Row Count 5 (+ 2) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{In order to get the frames in between the key frames, interpolation is used} \tn % Row Count 7 (+ 2) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Interpolation occurs in alpha blening and skinning} \tn % Row Count 8 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Linear Interpolation (Lerp)}}} \tn % Row Count 9 (+ 1) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Interpolation between two mathematical elements (could be points) P0 and P1} \tn % Row Count 11 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{P(t) = P0(1-t) + P1t} \tn % Row Count 12 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Where t is typically in the range {[}0, 1{]} and the start and end elements are P0 and P1 respectively.} \tn % Row Count 14 (+ 2) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{The interpolated point will be on a straight line in between P0 and P1, hence linear interpolation} \tn % Row Count 16 (+ 2) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Normalised Lerp (Nlerp)}}} \tn % Row Count 17 (+ 1) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Can use Linear Interpolation for transformations including translations, scaling and rotations, however, the results for rotations is not correct, resulting in unwanted scaling. Therefore, Nlerp or normalised Lerp is required for rotation.} \tn % Row Count 22 (+ 5) % Row 11 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{This works however, the angles can still be inaccurate. Can use Nlerp for rotations if the overall rotation is small enough.} \tn % Row Count 25 (+ 3) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Spherical Linear Interpolation (Slerp)}}} \tn % Row Count 26 (+ 1) % Row 13 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Linear interpolation of angles is sameas linear interpolation of an arc on a sphere.} \tn % Row Count 28 (+ 2) % Row 14 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Forumla different from linear interpolation (Lerp)} \tn % Row Count 29 (+ 1) % Row 15 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{slerp(P1, P2, t) = P1(P1\textasciicircum{}-1\textasciicircum{}P2)\textasciicircum{}t\textasciicircum{}} \tn % Row Count 30 (+ 1) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Animation: Interpolation (cont)}} \tn % Row 16 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{More suited for larger rotation as it calculates the correct interpolated rotation} \tn % Row Count 2 (+ 2) % Row 17 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Slerp for Matrices: Substitute the matrices into the forumla. Required to raise the matrix to the power with t. This means that we need to convert the matrix to an axis-angle format then calculate theta\textasciicircum{}t\textasciicircum{} then convert back.} \tn % Row Count 7 (+ 5) % Row 18 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{This is very expensive} \tn % Row Count 8 (+ 1) % Row 19 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Slerp for Quaternions: The only thing that makes it make expensive is the sine function. There can be accuracy problems for small theta, but more useable than the matrix version} \tn % Row Count 12 (+ 4) % Row 20 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Quaternion formula: slerp(P1, P2, t) = (sin((1-5)theta)P1 + sin(t theta) P2) / sin(theta)} \tn % Row Count 14 (+ 2) % Row 21 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Summary}}} \tn % Row Count 15 (+ 1) % Row 22 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Can use Lerp for positioning and scaling} \tn % Row Count 16 (+ 1) % Row 23 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{For small rotations use nLerp} \tn % Row Count 17 (+ 1) % Row 24 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{For larger rotations use Slerp} \tn % Row Count 18 (+ 1) % Row 25 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Rotations should be stored as quaternions if interpolation is involved as matrices are expensive} \tn % Row Count 20 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Animation: Practicalities}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Matrices are not good at animations as they are performance heavy use far too much storage, so quaternions should be used instead} \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{We can decompose the transformation into rotation, translation, scale etc., using vectors for translation and scale and quaternions for rotation} \tn % Row Count 6 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Spatial Partitioning}} & is any scheme that divides the game world into smaller spaces \tn % Row Count 4 (+ 4) % Row 1 \SetRowColor{white} & Needed for larger scale games \tn % Row Count 6 (+ 2) % Row 2 \SetRowColor{LightBackground} {\bf{Problems with Large Games}} & Complex games can contain millions of instances \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} & The majority of instances are likely to be far from the player \tn % Row Count 13 (+ 4) % Row 4 \SetRowColor{LightBackground} & We would like to cull these instances instead \tn % Row Count 16 (+ 3) % Row 5 \SetRowColor{white} {\bf{Simple Culling Methods}} & Can cull entity instances against the viewing frustum. This is the volume of space visible from the camera, which is a cone with its head cut off. \tn % Row Count 24 (+ 8) % Row 6 \SetRowColor{LightBackground} & Check each instance against each of the 6 planes defining the frustum or more simply rejecting those beind the camera near clip plane \tn % Row Count 31 (+ 7) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 7 \SetRowColor{LightBackground} & Use bounding volumes and simple maths like boxes or spheres \tn % Row Count 3 (+ 3) % Row 8 \SetRowColor{white} {\bf{Rationale for Spatial Partitioning}} & Culling instance one-by-one is not the best approach for very complex environments. There are too many instances to even consider in one frame. \tn % Row Count 11 (+ 8) % Row 9 \SetRowColor{LightBackground} & Need to reformulate problem and don't process non-visible instances at all \tn % Row Count 15 (+ 4) % Row 10 \SetRowColor{white} & Partitions can be seen as chunks of space and instead identify which partitions are invisible allowing use to accept or reject large groups of instances at once. \tn % Row Count 24 (+ 9) % Row 11 \SetRowColor{LightBackground} {\bf{Simple Example}} & Most space partitioning schemes use some form of graph to subdivide the world where each node represents a space. Shape of the spaces vary by scheme. The edges represent how the spaces are related or connected. \tn % Row Count 35 (+ 11) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 12 \SetRowColor{LightBackground} & One example shows a very basic partition/graph demonstrating how areas in the sene are connected and how a group of instances can be reject by one check. (Refer to lecture slides for diagram) \tn % Row Count 10 (+ 10) % Row 13 \SetRowColor{white} {\bf{Level Division}} & Space partitions are not just for visibility checks \tn % Row Count 13 (+ 3) % Row 14 \SetRowColor{LightBackground} & This can help in a variety of non-rendering situations. \tn % Row Count 16 (+ 3) % Row 15 \SetRowColor{white} & For example a game can be partitioned into levels. Another example could be loading or releasing resources when moving between different partitions. Or having new pp or lighting effects or changing music etc. \tn % Row Count 27 (+ 11) % Row 16 \SetRowColor{LightBackground} {\bf{Game Logic}} & Space partitions can also help with game logic \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 17 \SetRowColor{LightBackground} & For example a race track can be split up into sectors where only the current and neighbouring sectors enable AI physics and rendering because AI race cars which are far away don't need physics etc. because you can't see them. \tn % Row Count 12 (+ 12) % Row 18 \SetRowColor{white} & These sectors can also simplify lap processing which can include distance covered, telemetrics or detecting whether you are going the wrong way around a race track. \tn % Row Count 21 (+ 9) % Row 19 \SetRowColor{LightBackground} \seqsplit{Visibility/Audibility} & Paritions can be used to determine whether you can hear sound past a concrete wall for example. \tn % Row Count 26 (+ 5) % Row 20 \SetRowColor{white} {\bf{Potentially Visible Sets (PVS)}} & Each node in a space partition has a potentially visible set (PVS) \tn % Row Count 30 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 21 \SetRowColor{LightBackground} & These are the nodes that can in some be seen from that node. For example, you can see the living from the hallway because you can see through an open door. (Diagram shown in lecture slides) \tn % Row Count 10 (+ 10) % Row 22 \SetRowColor{white} & PVS can be pre-calculated and stored with each node. This indicates which other nodes to render whe in that node. \tn % Row Count 16 (+ 6) % Row 23 \SetRowColor{LightBackground} {\bf{Generating PVS}} & A PVS scheme is conceptually simple \tn % Row Count 18 (+ 2) % Row 24 \SetRowColor{white} & However, generating the PVS for each node is non-trivial \tn % Row Count 21 (+ 3) % Row 25 \SetRowColor{LightBackground} & Possible approaches include using brute force, which considers many different camera positions. This can be slow and result in possible errors. You can manually create PVS. This can only be possible for simpler graphs and is error prone. Finally \seqsplit{mathematical/geometric} approaches can be used, which are complex and often have limitations \tn % Row Count 38 (+ 17) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 26 \SetRowColor{LightBackground} {\bf{PVS Limitations}} & PVS does not consider dynamic geometry. For exampe if you have a level that has a door which opens then the door must be considered as open for PVS \tn % Row Count 8 (+ 8) % Row 27 \SetRowColor{white} & Potentially visible sets must be conservative. For example, a node visible from only a tiny portion of the current node would need to be entirely visible \tn % Row Count 16 (+ 8) % Row 28 \SetRowColor{LightBackground} & So whilst efficent to execute, PVS systems are not ideally effective in node rejection. \tn % Row Count 21 (+ 5) % Row 29 \SetRowColor{white} {\bf{PVS Use}} & PVS system is not space partitioning scheme as such \tn % Row Count 24 (+ 3) % Row 30 \SetRowColor{LightBackground} & PVS can be added to any space partition graph regardless of shceme used \tn % Row Count 28 (+ 4) % Row 31 \SetRowColor{white} & USed as a quick way to renduce the number of nodes under consideration \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 32 \SetRowColor{LightBackground} {\bf{Portal Systems}} & A Portal system is a method that concetrates on the graph edges \tn % Row Count 4 (+ 4) % Row 33 \SetRowColor{white} & Spaces in such a system are connected through portals. A portal is typically a natural opneing such as a door or window \tn % Row Count 10 (+ 6) % Row 34 \SetRowColor{LightBackground} & Portals allow us to reject other nodes based on the camera view \tn % Row Count 14 (+ 4) % Row 35 \SetRowColor{white} {\bf{Basic Portal usage}} & Identify which node the camera is in \tn % Row Count 16 (+ 2) % Row 36 \SetRowColor{LightBackground} & Identify whether each of the node's portals are visible in the viewport \tn % Row Count 20 (+ 4) % Row 37 \SetRowColor{white} & Now we know the nodes connected through the visible portals are also visible \tn % Row Count 24 (+ 4) % Row 38 \SetRowColor{LightBackground} {\bf{Refinements}} & When a visible portal is found store its viewport dimensions (2D rectangle) \tn % Row Count 28 (+ 4) % Row 39 \SetRowColor{white} & Clip portals in the connected node against this smaller area. Reject obscured nodes \tn % Row Count 33 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 40 \SetRowColor{LightBackground} & Watch out for multiple portals leading to same nodes. We don't want to render nodes twice. \tn % Row Count 5 (+ 5) % Row 41 \SetRowColor{white} {\bf{Portal Pros}} & Cheao and simple implement \tn % Row Count 7 (+ 2) % Row 42 \SetRowColor{LightBackground} & Effective for indoor geometry \tn % Row Count 9 (+ 2) % Row 43 \SetRowColor{white} & Portals can handle dynamic gemometry (unlike PVS) \tn % Row Count 12 (+ 3) % Row 44 \SetRowColor{LightBackground} & Each portal with 2 sides don't need to be in the same place. \tn % Row Count 15 (+ 3) % Row 45 \SetRowColor{white} {\bf{Portal Cons}} & Can be tricky to know which node a partiuclar point is in \tn % Row Count 18 (+ 3) % Row 46 \SetRowColor{LightBackground} & Need to know which node the camera is in to start the algorithm. e.g. what if a camera travels through a wall or teleports? \tn % Row Count 25 (+ 7) % Row 47 \SetRowColor{white} & Portals are of little use for open areas \tn % Row Count 27 (+ 2) % Row 48 \SetRowColor{LightBackground} & Not easy to automatically generate portals from arbitrary geometry \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 49 \SetRowColor{LightBackground} {\bf{Grids as Spatial Partitions}} & Can collect local entities for visibility culling like AI \tn % Row Count 3 (+ 3) % Row 50 \SetRowColor{white} & Can be used to map terrain (Height/influence maps) \tn % Row Count 6 (+ 3) % Row 51 \SetRowColor{LightBackground} & Can be extended to 3D \tn % Row Count 8 (+ 2) % Row 52 \SetRowColor{white} {\bf{Disadvantages to Grids as SP}} & May have many empty nodes, wasting memory, reducing cache efficency \tn % Row Count 12 (+ 4) % Row 53 \SetRowColor{LightBackground} & Choice of partition size tricky - too small gives many empty odes, too large and culling etc. is ineffective \tn % Row Count 18 (+ 6) % Row 54 \SetRowColor{white} {\bf{Mapping a Grid to the World}} & A grid is an integer indexed structure for a rectangle of world space \tn % Row Count 22 (+ 4) % Row 55 \SetRowColor{LightBackground} & Need to map between world space coords and grid indices \tn % Row Count 25 (+ 3) % Row 56 \SetRowColor{white} Conversions for X dimension are (Y similar): & GridX = (int)(GridWidth * (WorldX - MinX) / (MaxX - MinX)) \tn % Row Count 28 (+ 3) % Row 57 \SetRowColor{LightBackground} & WorldX = Min +(float)GridX * (MaxX - MinX) / GridWidth \tn % Row Count 31 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 58 \SetRowColor{LightBackground} & 2nd formular gives bottom-left of grid square \tn % Row Count 3 (+ 3) % Row 59 \SetRowColor{white} {\bf{Quadtrees / Qctrees}} & Quadtrees / Qctrees are hierarchical partition systems which use a tree structure to represent an area/volume of space. \tn % Row Count 9 (+ 6) % Row 60 \SetRowColor{LightBackground} & USe specific division scheme \tn % Row Count 11 (+ 2) % Row 61 \SetRowColor{white} & Quadtrees are in 2D, Octrees in 3D \tn % Row Count 13 (+ 2) % Row 62 \SetRowColor{LightBackground} {\bf{Creating a Quadtree}} & Root node is entire space \tn % Row Count 15 (+ 2) % Row 63 \SetRowColor{white} & Divide into four equal quadrant \tn % Row Count 17 (+ 2) % Row 64 \SetRowColor{LightBackground} & Repeat division with each quadrant \tn % Row Count 19 (+ 2) % Row 65 \SetRowColor{white} & Until some condition is met - max depth, empty node etc. \tn % Row Count 22 (+ 3) % Row 66 \SetRowColor{LightBackground} {\bf{Location in a Quadtree}} & Easy to find which node point is in \tn % Row Count 24 (+ 2) % Row 67 \SetRowColor{white} & Can be optimised \tn % Row Count 25 (+ 1) % Row 68 \SetRowColor{LightBackground} & Can use bitwise integer math \tn % Row Count 27 (+ 2) % Row 69 \SetRowColor{white} {\bf{Quadtrees for visibility culling}} & USe for frustum culling \tn % Row Count 29 (+ 2) % Row 70 \SetRowColor{LightBackground} & Viewing frustum is 6 planes \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 71 \SetRowColor{LightBackground} & Test if a node is visible \tn % Row Count 2 (+ 2) % Row 72 \SetRowColor{white} {\bf{Quadtree Problem}} & Entities aren't points \tn % Row Count 4 (+ 2) % Row 73 \SetRowColor{LightBackground} & May overlap a node boundary \tn % Row Count 6 (+ 2) % Row 74 \SetRowColor{white} & Entity needs to be in a larger parent node \tn % Row Count 9 (+ 3) % Row 75 \SetRowColor{LightBackground} & Worst case: entities overlaps origin and does not fit in any node except root and will never be culled \tn % Row Count 15 (+ 6) % Row 76 \SetRowColor{white} & Hot-spots like this all the way around the boundaries of larger nodes. \tn % Row Count 19 (+ 4) % Row 77 \SetRowColor{LightBackground} {\bf{Solution}} & Loose Quadtrees \tn % Row Count 20 (+ 1) % Row 78 \SetRowColor{white} & Have nodes overlap \tn % Row Count 21 (+ 1) % Row 79 \SetRowColor{LightBackground} & Entities will then fit in original node area \tn % Row Count 24 (+ 3) % Row 80 \SetRowColor{white} & Few changes to algorithm - increase node size when inserting entities and when doing frustum culling \tn % Row Count 29 (+ 5) % Row 81 \SetRowColor{LightBackground} & Removes hotspot problem \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 82 \SetRowColor{LightBackground} & At the expense of larger nodes at the same level \tn % Row Count 3 (+ 3) % Row 83 \SetRowColor{white} {\bf{Quadtrees for Collision Detection}} & Saw intersection of viewing frustum with quadtree \tn % Row Count 6 (+ 3) % Row 84 \SetRowColor{LightBackground} & Easy to find intersection of other primitives - sphere, cuboids, rays etc. \tn % Row Count 10 (+ 4) % Row 85 \SetRowColor{white} & Basis for collision detection/ray casting/particle systems \tn % Row Count 13 (+ 3) % Row 86 \SetRowColor{LightBackground} & Can help if we add adjacency info to the tree \tn % Row Count 16 (+ 3) % Row 87 \SetRowColor{white} {\bf{Binary Space Partitioning (BSP)}} & Hierarchical division of space and uses another tree structure. This one represents all space \tn % Row Count 21 (+ 5) % Row 88 \SetRowColor{LightBackground} & Partitions are separated by lines in 2D or planes in 3D \tn % Row Count 24 (+ 3) % Row 89 \SetRowColor{white} & Recursively divide each partition into 2 smaller ones \tn % Row Count 27 (+ 3) % Row 90 \SetRowColor{LightBackground} & Creates a binary tree \tn % Row Count 29 (+ 2) % Row 91 \SetRowColor{white} {\bf{Creating a BSP}} & Repeatedly divide space in 2 \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 92 \SetRowColor{LightBackground} & Stop when max x elements in each partition. Partitions are small enough. tree reaches certain depth and choice depends on application \tn % Row Count 7 (+ 7) % Row 93 \SetRowColor{white} {\bf{Locating a Point in a BSP}} & Given a point, each to find which partition it is in. Start at root of tree \tn % Row Count 11 (+ 4) % Row 94 \SetRowColor{LightBackground} & Look at example in lecture slides \tn % Row Count 13 (+ 2) % Row 95 \SetRowColor{white} {\bf{BSP for solid/hollow spaces}} & Can use the polygons in the scene as the division planes. Choose a polygon as a plane and polygons crossing the planes are split \tn % Row Count 20 (+ 7) % Row 96 \SetRowColor{LightBackground} & BSP splits space into hollow/solid volumes \tn % Row Count 23 (+ 3) % Row 97 \SetRowColor{white} & All polygons/entities places in hollow ones \tn % Row Count 26 (+ 3) % Row 98 \SetRowColor{LightBackground} {\bf{BSP / Brush modelling}} & Traditional style of BSP used for FPS games \tn % Row Count 29 (+ 3) % Row 99 \SetRowColor{white} & In conjunction with PVS \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.4885 cm} x{2.4885 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Spatial Partitioning (cont)}} \tn % Row 100 \SetRowColor{LightBackground} & Can also be used to render partitions in a strict back to fron order \tn % Row Count 4 (+ 4) % Row 101 \SetRowColor{white} & Lends itself to a unique form of 3D modelling called brush modelling. You start with a entirely solid world, cut out primitives, entities paces in hollowed out areas. This is like digging out the level. \tn % Row Count 15 (+ 11) % Row 102 \SetRowColor{LightBackground} {\bf{BSP Pros and Cons}} & +BSP trees are a well established technique \tn % Row Count 18 (+ 3) % Row 103 \SetRowColor{white} & +Used for \seqsplit{rendering/collision/ray-tracing} \tn % Row Count 21 (+ 3) % Row 104 \SetRowColor{LightBackground} & +Can be generated automatically \tn % Row Count 23 (+ 2) % Row 105 \SetRowColor{white} & +Fully Classify space \tn % Row Count 25 (+ 2) % Row 106 \SetRowColor{LightBackground} & -Need good algorithm to choose dividing planes \tn % Row Count 28 (+ 3) % Row 107 \SetRowColor{white} & -Hollow/solid BSP generates extra polygons due to splitting \tn % Row Count 31 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Deferred Rendering}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Forward Rendering}} & Name for the method of rendering we have used in all material so far \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} & Render geometry and light effects on the geometry in single pass \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} & Cost = numObjects x NumLights - Get's very expensive \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} & Forward rendering can be effective but need a slow uber-shader or lots of shaders and batch problems \tn % Row Count 14 (+ 5) % Row 4 \SetRowColor{LightBackground} & Doesn't work well with lots of lights in one place \tn % Row Count 17 (+ 3) % Row 5 \SetRowColor{white} {\bf{Deferred Rendering}} & Decouples geometry from lighting \tn % Row Count 19 (+ 2) % Row 6 \SetRowColor{LightBackground} & Splits the rendering process into 2 stages \tn % Row Count 21 (+ 2) % Row 7 \SetRowColor{white} & Cost = NumObject + NumLights - Much cheaper \tn % Row Count 23 (+ 2) % Row 8 \SetRowColor{LightBackground} {\bf{G-Buffer}} & Render geometry to g-buffer, which is several textures holding geometry and surface data \tn % Row Count 27 (+ 4) % Row 9 \SetRowColor{white} & Example: Texture1: Diffuse Colour Texture2: WorldPosition Texture3: WorldNormal \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Deferred Rendering (cont)}} \tn % Row 10 \SetRowColor{LightBackground} & Pixel shader can render to several render targets at the same time, so can build three textures all in one pass with a special pixel shader \tn % Row Count 7 (+ 7) % Row 11 \SetRowColor{white} & MRT = Multiple Render Target \tn % Row Count 9 (+ 2) % Row 12 \SetRowColor{LightBackground} & Data in g-buffer is anything we need to calculate lit version of the scene \tn % Row Count 13 (+ 4) % Row 13 \SetRowColor{white} & Large g-buffer results in major performance drain - memory access is slow... \tn % Row Count 17 (+ 4) % Row 14 \SetRowColor{LightBackground} & So data compression in the g-buffer is common ie store x and y of normal together with a single bit for direction \tn % Row Count 22 (+ 5) % Row 15 \SetRowColor{white} {\bf{Lighting Volumes}} & G-buffer is not displayed \tn % Row Count 24 (+ 2) % Row 16 \SetRowColor{LightBackground} & Render actual scene by going through each light and rendering it's effect on the geometry \tn % Row Count 28 (+ 4) % Row 17 \SetRowColor{white} & Point light lights up a sphere around itself. Render the sphere around the point light. For each pixel find if it is actually lit up. USe data in g-buffer to calculate amount of light. Do this for every light and accumulate = rendered scene \tn % Row Count 39 (+ 11) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Deferred Rendering (cont)}} \tn % Row 18 \SetRowColor{LightBackground} & Same concept for spotlights \tn % Row Count 2 (+ 2) % Row 19 \SetRowColor{white} & Don't need high-poly spheres or cones \tn % Row Count 4 (+ 2) % Row 20 \SetRowColor{LightBackground} & Examples shown in lecture \tn % Row Count 6 (+ 2) % Row 21 \SetRowColor{white} {\bf{Deferred - Pros and Cons}} & +Lights become cheap to render \tn % Row Count 8 (+ 2) % Row 22 \SetRowColor{LightBackground} & +No need for complex partitioning \tn % Row Count 10 (+ 2) % Row 23 \SetRowColor{white} & +Shaders become simpler - less of them \tn % Row Count 12 (+ 2) % Row 24 \SetRowColor{LightBackground} & +Better batching performance \tn % Row Count 14 (+ 2) % Row 25 \SetRowColor{white} & +G-buffer data can eb reused for Post-Processing \tn % Row Count 17 (+ 3) % Row 26 \SetRowColor{LightBackground} & -Huge g-buffer can be a slow down \tn % Row Count 19 (+ 2) % Row 27 \SetRowColor{white} & -G-Buffer compression to counter this reduces material flexibility \tn % Row Count 22 (+ 3) % Row 28 \SetRowColor{LightBackground} & -Transparant obkects don't work, must be rendered separately \tn % Row Count 25 (+ 3) % Row 29 \SetRowColor{white} & -MSAA becomes very diffcult due to g-buffer \tn % Row Count 27 (+ 2) % Row 30 \SetRowColor{LightBackground} & -Not actually particularly useful in some scenes(daylight) \tn % Row Count 30 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.04057 cm} x{2.93643 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Deferred Rendering (cont)}} \tn % Row 31 \SetRowColor{LightBackground} & More advanced techniques are getting very complex \tn % Row Count 3 (+ 3) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Optimisation for Games}} \tn % Row 0 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Optimisation Tradeoffs}}} \tn % Row Count 1 (+ 1) % Row 1 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Reducing memory use can decrease speed} \tn % Row Count 2 (+ 1) % Row 2 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Increased speed might be at the expense of memory} \tn % Row Count 3 (+ 1) % Row 3 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{When not to optimise}}} \tn % Row Count 4 (+ 1) % Row 4 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Never optimise code unless you are sure that is affects performance} \tn % Row Count 6 (+ 2) % Row 5 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Optimisations usually harm \seqsplit{readability/maintainability} of code} \tn % Row Count 8 (+ 2) % Row 6 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Can reduce functionality} \tn % Row Count 9 (+ 1) % Row 7 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Can make architecture less flexible} \tn % Row Count 10 (+ 1) % Row 8 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Performance Analysis}}} \tn % Row Count 11 (+ 1) % Row 9 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Generally, 90\% of processor time is spent on just 10\% of code} \tn % Row Count 13 (+ 2) % Row 10 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Need to identify the 10\% to optimise effectively} \tn % Row Count 14 (+ 1) % Row 11 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Tools can be used to analyse performance of code during run-time} \tn % Row Count 16 (+ 2) % Row 12 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Performance Analysis Tools}}} \tn % Row Count 17 (+ 1) % Row 13 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Simple timing functions} \tn % Row Count 18 (+ 1) % Row 14 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-Profiler - Reports on time spent in different functions} \tn % Row Count 20 (+ 2) % Row 15 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Specialist tools like VTune, PTU, PerfKit, PerfHUD etc.} \tn % Row Count 22 (+ 2) % Row 16 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Compiler Optimisations}}} \tn % Row Count 23 (+ 1) % Row 17 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{Compilers can perform some optimisations} \tn % Row Count 24 (+ 1) % Row 18 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{Optimisations can be enabled using release mode in visual stuido.} \tn % Row Count 26 (+ 2) % Row 19 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Basic Language Optimisations}}} \tn % Row Count 27 (+ 1) % Row 20 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-Loop Untrolling - Does not loop through indices, just duplicated lines of code instead} \tn % Row Count 29 (+ 2) % Row 21 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Remove constant calculations by using a variable outside a loop for example} \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{p{0.4977 cm} p{0.4977 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Optimisation for Games (cont)}} \tn % Row 22 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-Change ording of conditions, like OR for example. Put simple condition first} \tn % Row Count 2 (+ 2) % Row 23 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Pass by reference not copy} \tn % Row Count 3 (+ 1) % Row 24 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-Use early return within functions whenever possible} \tn % Row Count 5 (+ 2) % Row 25 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Inline functions - stores functions in cache but can be ignored by compiler} \tn % Row Count 7 (+ 2) % Row 26 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-Break code into smaller steps. For example, don't have calculations inside if statements. Does not directly lead to optimisations but can help compiler optimise.} \tn % Row Count 11 (+ 4) % Row 27 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Try programming in assembly, although it would be very complex and compliers would probably do a better job.} \tn % Row Count 14 (+ 3) % Row 28 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{{\bf{Data Structure Choices}}} \tn % Row Count 15 (+ 1) % Row 29 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Static structures like fixed arrays might improe performance over dynamic ones} \tn % Row Count 17 (+ 2) % Row 30 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-Only choose data structures that suit your needs, nothing more} \tn % Row Count 19 (+ 2) % Row 31 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{{\bf{Algorithmic Improvements}}} \tn % Row Count 20 (+ 1) % Row 32 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-Can multiple by 0.5 rather than dividing by 2} \tn % Row Count 21 (+ 1) % Row 33 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Reduce nesting of loops - don't go deeper than 3} \tn % Row Count 22 (+ 1) % Row 34 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-Reduce range of loop counters} \tn % Row Count 23 (+ 1) % Row 35 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Sort data into more convenient orders} \tn % Row Count 24 (+ 1) % Row 36 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-Cluster similar cases into one} \tn % Row Count 25 (+ 1) % Row 37 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Reduce maths operations} \tn % Row Count 26 (+ 1) % Row 38 \SetRowColor{LightBackground} \mymulticolumn{2}{x{5.377cm}}{-Pre-calculate formulae using look-up tables} \tn % Row Count 27 (+ 1) % Row 39 \SetRowColor{white} \mymulticolumn{2}{x{5.377cm}}{-Remove code completely!} \tn % Row Count 28 (+ 1) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Alpha Sorting and Soft Particles}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Alpha Sorting Problems}} & Attractive blending technique but cuases sorting issues \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} & Problem is depth buffer ignores transparancy \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} & Avoid problem by drawing polygons back to front. \tn % Row Count 9 (+ 3) % Row 3 \SetRowColor{white} {\bf{Run-time Depth Sorting}} & If all polygons face camera ie particle system then you can sort polygons based on camera-space z distance \tn % Row Count 15 (+ 6) % Row 4 \SetRowColor{LightBackground} & Issues arise with this based on example shown on slides with the lines \tn % Row Count 19 (+ 4) % Row 5 \SetRowColor{white} & To solve this assume polygons don't intersect \tn % Row Count 22 (+ 3) % Row 6 \SetRowColor{LightBackground} & Then given 2 polygons one of them will be entirely on one side of the plane of the other \tn % Row Count 27 (+ 5) % Row 7 \SetRowColor{white} & Identify this polygon and see if it is on the side nearer the camera or not \tn % Row Count 31 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Alpha Sorting and Soft Particles (cont)}} \tn % Row 8 \SetRowColor{LightBackground} & First step is to get a face normal for each polygon \tn % Row Count 3 (+ 3) % Row 9 \SetRowColor{white} & Join either point of polygn 2 to eachh of the points polygon 1. Calculate dot products of these with normal of polygon 2. Results all +ve : poly 1 is nearer. Results all -ve: poly 1 further. Results mixed: poly1 is split by place of poly 2. So repeat test the other way around. If split both ways then the polygons are intersecting. Refer to slides for diagrams etc. \tn % Row Count 21 (+ 18) % Row 10 \SetRowColor{LightBackground} {\bf{Run-time sorting practicalities}} & Must ensure this sorting is efficient as possible. so sort pointer to polygon not polygon data itself \tn % Row Count 26 (+ 5) % Row 11 \SetRowColor{white} & In practice, another technique alpha-to-coverage is often used as an alternative. \tn % Row Count 30 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Alpha Sorting and Soft Particles (cont)}} \tn % Row 12 \SetRowColor{LightBackground} {\bf{Hard Flat particles}} & Alpha blending is as useful as other blending methods once the polygons are sorted \tn % Row Count 4 (+ 4) % Row 13 \SetRowColor{white} & However all blending methods exhibit hard edges if they intersect other polygons \tn % Row Count 8 (+ 4) % Row 14 \SetRowColor{LightBackground} & Particuarly large particles like smoke indoors \tn % Row Count 11 (+ 3) % Row 15 \SetRowColor{white} {\bf{Soft Particles}} & To improve further we can compare depth of particle with depth already in buffer and then fade pixels out when the distance is small. - Adjust alpha toward 0 \tn % Row Count 19 (+ 8) % Row 16 \SetRowColor{LightBackground} {\bf{Depth-Soft Particles}} & This method can be combined with the depth particles idea presented earlier \tn % Row Count 23 (+ 4) % Row 17 \SetRowColor{white} & We must do some detailed work with depth buffer but almost completely removes hard edges where alpha particles intersect solid objects. \tn % Row Count 30 (+ 7) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Alpha Sorting and Soft Particles (cont)}} \tn % Row 18 \SetRowColor{LightBackground} {\bf{Further Possibilities}} & Can explore volumetric particles - consider the volume of particle that camera is looking through. \tn % Row Count 5 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Linear Dynamics and Particle based Physics}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Particle System Basics}} & Data: Position, velocity, possibly mass \tn % Row Count 2 (+ 2) % Row 1 \SetRowColor{white} & Particle velocity must change or it will only movie in a straight line. Change in velocity is called acceleration. Acceleration caused by forces on particle. Gravity is common force. \tn % Row Count 11 (+ 9) % Row 2 \SetRowColor{LightBackground} {\bf{Particle Update}} & F=ma \tn % Row Count 13 (+ 2) % Row 3 \SetRowColor{white} & Use above formula to update particle each frame \tn % Row Count 16 (+ 3) % Row 4 \SetRowColor{LightBackground} & Diagram shown in lecture slides \tn % Row Count 18 (+ 2) % Row 5 \SetRowColor{white} {\bf{Aprox. in this update}} & This ibasic physics of forces, acclerations and velocities doesn't just apply to particles. Starting point for modeling physics too. \tn % Row Count 24 (+ 6) % Row 6 \SetRowColor{LightBackground} & Problem: Approach is only an approx. we only update things once per frame. Assumes vecocity was constant over entire time period of rame. This is wrong - forces/acceleration will change gradually throughout frame. Whereas our simple approach changes the velocity isntantly to a new value each frame. \tn % Row Count 38 (+ 14) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Linear Dynamics and Particle based Physics (cont)}} \tn % Row 7 \SetRowColor{LightBackground} & Example of this is when you have a particle following an orbit around an object. Over time the particle will move further away from the object it is orbitting. This is down to approximations and is wrong. \tn % Row Count 10 (+ 10) % Row 8 \SetRowColor{white} {\bf{Initial Value problems}} & Updating particle pos is an example of an initial value problem. We know the value of an equation at an initial point in time. Want ot calculate value at some furutre point in time. \tn % Row Count 19 (+ 9) % Row 9 \SetRowColor{LightBackground} & In this case we know pos and velocity from this frmae. Want to know position and velcity for next frame. The simple but flawed method just shown is one way of solving an initial value problem. Will present others with better accuracy. \tn % Row Count 30 (+ 11) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Linear Dynamics and Particle based Physics (cont)}} \tn % Row 10 \SetRowColor{LightBackground} {\bf{Formal Definition}} & Function which changes over time: p(t) \tn % Row Count 2 (+ 2) % Row 11 \SetRowColor{white} & Initial position/veclocity: p0 (where t = 0) \tn % Row Count 4 (+ 2) % Row 12 \SetRowColor{LightBackground} & Time period: h \tn % Row Count 5 (+ 1) % Row 13 \SetRowColor{white} & Value next frame: p(t0 + h) \tn % Row Count 7 (+ 2) % Row 14 \SetRowColor{LightBackground} & Need derivatives: p'(t), p''(t) \tn % Row Count 9 (+ 2) % Row 15 \SetRowColor{white} & 1st derivative of pos = velocity. 2nd = acceleration \tn % Row Count 12 (+ 3) % Row 16 \SetRowColor{LightBackground} {\bf{Euler's Method}} & Taylor series is a represenation of a function based on the derivatives at a single point (int time) \tn % Row Count 17 (+ 5) % Row 17 \SetRowColor{white} & p(t + h) = p(t) + hp'(t) + h\textasciicircum{}2\textasciicircum{}/2p''(t) + h\textasciicircum{}3\textasciicircum{}/3!p'''(t) + ... + h\textasciicircum{}n\textasciicircum{}/n!p\textasciicircum{}(n)\textasciicircum{} + ... \tn % Row Count 21 (+ 4) % Row 18 \SetRowColor{LightBackground} & Arranged here to suit our problem \tn % Row Count 23 (+ 2) % Row 19 \SetRowColor{white} & p is pos, p' velocity, p'' acceleration, p''' acceleration of acceleration \tn % Row Count 27 (+ 4) % Row 20 \SetRowColor{LightBackground} & As h is smaller aprrox is more accurate \tn % Row Count 29 (+ 2) % Row 21 \SetRowColor{white} & IT is an infinite series - cannot be completly calculated \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Linear Dynamics and Particle based Physics (cont)}} \tn % Row 22 \SetRowColor{LightBackground} & Eulers Method uses just the 1st two terms in the series and assumes the rest are small enough to ignore. \tn % Row Count 5 (+ 5) % Row 23 \SetRowColor{white} & Translation into games terms: posNextFrame = currentPos + frameTime * currentVelocity \tn % Row Count 9 (+ 4) % Row 24 \SetRowColor{LightBackground} & veclocityNextFrame = currentVelocity + frameTime * currentAccel \tn % Row Count 12 (+ 3) % Row 25 \SetRowColor{white} & This is exactly the method presented earlier for updating particles in a particle system. Not ideal, terms are ignored (not always small). Still widely acceptable when accuracy isn't required. \tn % Row Count 21 (+ 9) % Row 26 \SetRowColor{LightBackground} {\bf{Mid-point Method}} & Problem with Euler's method is that velocity and acceleration are taken at the start of the frame. \tn % Row Count 26 (+ 5) % Row 27 \SetRowColor{white} & The mid-point method takes them half way through the frame. \tn % Row Count 29 (+ 3) % Row 28 \SetRowColor{LightBackground} & This has better accuracy than Euler's method but not perfect as half-way values are themselves approx. \tn % Row Count 34 (+ 5) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Linear Dynamics and Particle based Physics (cont)}} \tn % Row 29 \SetRowColor{LightBackground} {\bf{Basic Verlet Method}} & Less reliant on velocity \tn % Row Count 2 (+ 2) % Row 30 \SetRowColor{white} & Can be resrictive because of that \tn % Row Count 4 (+ 2) % Row 31 \SetRowColor{LightBackground} & OK for particle systems if only concerned with position \tn % Row Count 7 (+ 3) % Row 32 \SetRowColor{white} & Most basic method: uses pos from the current and previous frame and uses current acceleration \tn % Row Count 12 (+ 5) % Row 33 \SetRowColor{LightBackground} & formula: y(t+h) = 2y(5) - y(t-h) + h\textasciicircum{}2\textasciicircum{}y''(t) \tn % Row Count 15 (+ 3) % Row 34 \SetRowColor{white} & posNextFrame = 2 * currentPos - posLastFrame + (frame time)\textasciicircum{}2\textasciicircum{} * currentAcceleration \tn % Row Count 19 (+ 4) % Row 35 \SetRowColor{LightBackground} & Has similar accuracy to mid-point method \tn % Row Count 21 (+ 2) % Row 36 \SetRowColor{white} {\bf{Particle Physics - Springs}} & Forces involved: Gravity, spring compression and spring stretch \tn % Row Count 24 (+ 3) % Row 37 \SetRowColor{LightBackground} & Considers particle mass \tn % Row Count 26 (+ 2) % Row 38 \SetRowColor{white} {\bf{Spring Forces}} & Force exerted by spring is from Hooke's Law: F = -kx \tn % Row Count 29 (+ 3) % Row 39 \SetRowColor{LightBackground} & x = displacement for spring's equilibrium pos \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Linear Dynamics and Particle based Physics (cont)}} \tn % Row 40 \SetRowColor{LightBackground} & k = spring coefficent (stiffness) \tn % Row Count 2 (+ 2) % Row 41 \SetRowColor{white} {\bf{Practicalities}} & Real life systems slow down with friction \tn % Row Count 4 (+ 2) % Row 42 \SetRowColor{LightBackground} & Instead of friction we will damp the motion \tn % Row Count 6 (+ 2) % Row 43 \SetRowColor{white} & Damping force: Fd = -cv \tn % Row Count 8 (+ 2) % Row 44 \SetRowColor{LightBackground} & v = velocity \tn % Row Count 9 (+ 1) % Row 45 \SetRowColor{white} & c = damping coefficent - works against current velocity range: 0-1 \tn % Row Count 12 (+ 3) % Row 46 \SetRowColor{LightBackground} {\bf{Uses}} & Can model rope, cloth and jelly-like objects \tn % Row Count 14 (+ 2) % Row 47 \SetRowColor{white} {\bf{Different Connectors}} & Can use new connetor type such as elastic, rods and string \tn % Row Count 17 (+ 3) % Row 48 \SetRowColor{LightBackground} & Key difference introduced: Some types behave differently when stretched and compressed, some are constrained, some don't exert forces at some times. \tn % Row Count 24 (+ 7) % Row 49 \SetRowColor{white} {\bf{Constraints}} & Rods and strings have constraints. Rods must always be same length and string cannot be longer than original length \tn % Row Count 30 (+ 6) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.14011 cm} x{2.83689 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Linear Dynamics and Particle based Physics (cont)}} \tn % Row 50 \SetRowColor{LightBackground} {\bf{Mathematical Approaches}} & Each constraint can be written as an equation illustrating then fixed length between particles such as: |pi-pj|\textasciicircum{}2\textasciicircum{} - Lij\textasciicircum{}2\textasciicircum{} = 0 \tn % Row Count 6 (+ 6) % Row 51 \SetRowColor{white} & p is particle pos and L is fixed length of connecter \tn % Row Count 9 (+ 3) % Row 52 \SetRowColor{LightBackground} & Several constraints we have several equations \tn % Row Count 12 (+ 3) % Row 53 \SetRowColor{white} & Known as a system of linear equations \tn % Row Count 14 (+ 2) % Row 54 \SetRowColor{LightBackground} {\bf{Solving Constraints}} & Of the various mathematical solutions most have a similar repeated iterative approach. Examples shown in slides \tn % Row Count 20 (+ 6) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Advanced Graphics: Scene Post-Processing}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Front/back buffers}} & Visible viewport can be called front buffer \tn % Row Count 3 (+ 3) % Row 1 \SetRowColor{white} & A 2nd off-screen back buffer is the usual render target \tn % Row Count 6 (+ 3) % Row 2 \SetRowColor{LightBackground} & After frame rendering the back buffer is copied to the front buffer \tn % Row Count 10 (+ 4) % Row 3 \SetRowColor{white} & This is a form of double-buffering \tn % Row Count 12 (+ 2) % Row 4 \SetRowColor{LightBackground} {\bf{Swap methods/chains}} & Methods to get the back buffer content to the front buffer involve a simlpe copy were the back buffer is discarded or te 2 buffers are swapped which is useful if we want to keep the last frame \tn % Row Count 22 (+ 10) % Row 5 \SetRowColor{white} & Can have more than one back buffer. This is known as triple-buffering \tn % Row Count 26 (+ 4) % Row 6 \SetRowColor{LightBackground} & Improved concurrency with GPU \tn % Row Count 28 (+ 2) % Row 7 \SetRowColor{white} & Multiple back buffers must use the swap method which is called a swap chain \tn % Row Count 32 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Advanced Graphics: Scene Post-Processing (cont)}} \tn % Row 8 \SetRowColor{LightBackground} {\bf{VSync or Not}} & Copy/swap is fast operation \tn % Row Count 2 (+ 2) % Row 9 \SetRowColor{white} & Can perform it during the monitor's vertical sync \tn % Row Count 5 (+ 3) % Row 10 \SetRowColor{LightBackground} & If you do this though the FPS will be tied to monitor refresh rate \tn % Row Count 9 (+ 4) % Row 11 \SetRowColor{white} & Alternatively can copy to front buffer immediately. - May see tearing \tn % Row Count 13 (+ 4) % Row 12 \SetRowColor{LightBackground} {\bf{Alternative Render Targets}} & Not necessary to render to a back buffer \tn % Row Count 15 (+ 2) % Row 13 \SetRowColor{white} & We can render to a texture or to a specially created render target \tn % Row Count 19 (+ 4) % Row 14 \SetRowColor{LightBackground} & Can create explicit render targets or render to multiple render targets \tn % Row Count 23 (+ 4) % Row 15 \SetRowColor{white} {\bf{Scene Post-Processing}} & Assume we render the entire scene to an intermediate texture \tn % Row Count 26 (+ 3) % Row 16 \SetRowColor{LightBackground} & Can then copy it to back buffer to be presented to the viewport but we can also perform additional image processing during this copy \tn % Row Count 33 (+ 7) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.33919 cm} x{2.63781 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Advanced Graphics: Scene Post-Processing (cont)}} \tn % Row 17 \SetRowColor{LightBackground} & The copy process is effectively another rendering pass so the look of the scene is altered through pixel shader \tn % Row Count 6 (+ 6) % Row 18 \SetRowColor{white} & This is full-screen post-processing \tn % Row Count 8 (+ 2) % Row 19 \SetRowColor{LightBackground} {\bf{Multiple Passes / Render Targets}} & Can post-process in multiple passes \tn % Row Count 10 (+ 2) % Row 20 \SetRowColor{white} & The textures used do not have to all be the same size so that you can scale down and back up for blur for example \tn % Row Count 16 (+ 6) % Row 21 \SetRowColor{LightBackground} & Can make complex sequences of post processing like bloom. \tn % Row Count 19 (+ 3) % Row 22 \SetRowColor{white} & {\emph{Don't need to talk any more about Post Processing - Should be confident from assignment }} \tn % Row Count 24 (+ 5) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Water Rendering}} \tn % Row 0 \SetRowColor{LightBackground} {\bf{Visual Aspects of Water}} & Reflection, refraction, fresnel effect, kught extinction, surface deformation, foam/spray/caustics and underwater effects \tn % Row Count 7 (+ 7) % Row 1 \SetRowColor{white} {\bf{Reflection}} & Water behaves to some degree like a mirror \tn % Row Count 10 (+ 3) % Row 2 \SetRowColor{LightBackground} & Perfectly still water presents a perfect reflection \tn % Row Count 13 (+ 3) % Row 3 \SetRowColor{white} & Surface deformation presents practical difficulties as the normals vary \tn % Row Count 17 (+ 4) % Row 4 \SetRowColor{LightBackground} {\bf{Reflection Practicalities}} & Can be dynamic, movement in scene is reflected \tn % Row Count 20 (+ 3) % Row 5 \SetRowColor{white} & Or static - Just skybox reflected \tn % Row Count 22 (+ 2) % Row 6 \SetRowColor{LightBackground} & Static case - Cube mapping works effectively, reflect ray from camera off the surface normal and into a cube, hlsl support for cube-mapping makes this simple, works without difficulty with varying normals \tn % Row Count 33 (+ 11) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Water Rendering (cont)}} \tn % Row 7 \SetRowColor{LightBackground} & Dynamic reflections - cube mapping not effective so reflect the camera in the plane of the water, render the scene from this reflected camera into a texture, draw the water surface mapped with this reflection texture \tn % Row Count 11 (+ 11) % Row 8 \SetRowColor{white} & Varying normal can be simulated by offsetting which part of the reflection texture sampled \tn % Row Count 16 (+ 5) % Row 9 \SetRowColor{LightBackground} & Not a fully robust solution. Reflections might come from parts of the scene that were not rendered in the reflection texture. Approach only works perfectly for completely flat water \tn % Row Count 26 (+ 10) % Row 10 \SetRowColor{white} & Alternative approach is to use ray-tracing or similar \tn % Row Count 29 (+ 3) % Row 11 \SetRowColor{LightBackground} {\bf{Self-Reflection}} & If the water surface is choppy enough it may reflect other parts of the water \tn % Row Count 33 (+ 4) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Water Rendering (cont)}} \tn % Row 12 \SetRowColor{LightBackground} & Reflection and refraction require multi-pass approaches to do properly however don't need to do it properly in most cases \tn % Row Count 7 (+ 7) % Row 13 \SetRowColor{white} & Static cube mapping: Lower half of cube map not really needed so draw the upper half reflected \tn % Row Count 12 (+ 5) % Row 14 \SetRowColor{LightBackground} & Dynamic reflected camera: render the water in the reflection texture using static cube mapping \tn % Row Count 17 (+ 5) % Row 15 \SetRowColor{white} {\bf{Refraction}} & Where light crosses the interface between 2 different materials it bends \tn % Row Count 21 (+ 4) % Row 16 \SetRowColor{LightBackground} & Amount of bend is given by Snell's Law \tn % Row Count 23 (+ 2) % Row 17 \SetRowColor{white} & Depends on: Angle of incidence, refractive indexes, vacuum has a refractive index of 1, clean water is 1.33 \tn % Row Count 29 (+ 6) % Row 18 \SetRowColor{LightBackground} & n1sin(theta1) = n2sin(theta2) \tn % Row Count 31 (+ 2) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Water Rendering (cont)}} \tn % Row 19 \SetRowColor{LightBackground} {\bf{Refraction in Water}} & When looking into water, light coming from under the water is bent and the scene at the water surface appears shifted and distorted \tn % Row Count 7 (+ 7) % Row 20 \SetRowColor{white} & Amount of shift/distortion depends on: angle at which we view the surface, variations in the surface shape - waves ripples, both of these vary per pixel \tn % Row Count 15 (+ 8) % Row 21 \SetRowColor{LightBackground} {\bf{Refraction - Practicalities}} & Refraction typically rendered in the manner of a post processing effect - similar to distorted glass \tn % Row Count 20 (+ 5) % Row 22 \SetRowColor{white} & Process - Underwater parts of scene rendered to texture, water surface is rendered and this texture is applied, distortion is applied to UVs \tn % Row Count 27 (+ 7) % Row 23 \SetRowColor{LightBackground} & Fully robust system would be complex \tn % Row Count 29 (+ 2) % Row 24 \SetRowColor{white} {\bf{Combining reflection and Refraction}} & Both involve rendering scene to texture \tn % Row Count 32 (+ 3) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Water Rendering (cont)}} \tn % Row 25 \SetRowColor{LightBackground} & In practice: Create 2 textures, render sabove water scene(reflected) to 1 and the below water scene to the other. Clip each of these scenes at the water surface \tn % Row Count 8 (+ 8) % Row 26 \SetRowColor{white} & Render water surface blending reflection and refraction textures \tn % Row Count 12 (+ 4) % Row 27 \SetRowColor{LightBackground} & Blending amount depends on viewing angle \tn % Row Count 14 (+ 2) % Row 28 \SetRowColor{white} {\bf{Fresnel Effect}} & To do with viewing angle and blending of textures \tn % Row Count 17 (+ 3) % Row 29 \SetRowColor{LightBackground} & Effect depends on the material involved \tn % Row Count 19 (+ 2) % Row 30 \SetRowColor{white} & F = F0 + (1 - F0)(1 - N . C)\textasciicircum{}5\textasciicircum{} \tn % Row Count 21 (+ 2) % Row 31 \SetRowColor{LightBackground} & F0 = ((n1 - n2)/(n1+n2))\textasciicircum{}2\textasciicircum{} \tn % Row Count 23 (+ 2) % Row 32 \SetRowColor{white} & n1, n2 are the refractive indexes of the material \tn % Row Count 26 (+ 3) % Row 33 \SetRowColor{LightBackground} & N = surface normal C = Normal to the camera \tn % Row Count 29 (+ 3) % Row 34 \SetRowColor{white} & F gives the proportion of reflected light coming from the surface, the remainder comes from refraction. e.g. if F = 0.3 at a point on the surface. Point emits 30\% reflected light and 70\% refracted light \tn % Row Count 40 (+ 11) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Water Rendering (cont)}} \tn % Row 35 \SetRowColor{LightBackground} & Fresnel formula calculated in pixel shader giving a blending ratio for the reflection and refraction textures \tn % Row Count 6 (+ 6) % Row 36 \SetRowColor{white} {\bf{Light Extinction}} & Light attenuates in water as well as air \tn % Row Count 8 (+ 2) % Row 37 \SetRowColor{LightBackground} & The effect in water is much stronger though \tn % Row Count 11 (+ 3) % Row 38 \SetRowColor{white} {\bf{Practicalities}} & Effects refracted light only \tn % Row Count 13 (+ 2) % Row 39 \SetRowColor{LightBackground} & Need to know how far light has travelled \tn % Row Count 15 (+ 2) % Row 40 \SetRowColor{white} & Several approaches can be used: e.g. render water surface only to texture, store only its world space distance from camera, when renedering refraction texture subract the distace of each underwater pixel from the water surface distance at the same point. Gives distance the light travels through water to surface. Linearly belend RGB components based on this distance and the extinction distances given. Water surface distance texture created in the 1st step can aslso be used to do the above/below water clipping \tn % Row Count 41 (+ 26) \end{tabularx} \par\addvspace{1.3em} \vfill \columnbreak \begin{tabularx}{5.377cm}{x{2.43873 cm} x{2.53827 cm} } \SetRowColor{DarkBackground} \mymulticolumn{2}{x{5.377cm}}{\bf\textcolor{white}{Water Rendering (cont)}} \tn % Row 41 \SetRowColor{LightBackground} & For surface normals you can animate normal maps to get a wave or ripple effect etc. \tn % Row Count 5 (+ 5) % Row 42 \SetRowColor{white} & Refer to lecture for more detail \tn % Row Count 7 (+ 2) \hhline{>{\arrayrulecolor{DarkBackground}}--} \end{tabularx} \par\addvspace{1.3em} % That's all folks \end{multicols*} \end{document}