diff --git a/Images/Fractal_fire.jpg b/Images/Fractal_fire.jpg new file mode 100644 index 0000000..4b271d0 Binary files /dev/null and b/Images/Fractal_fire.jpg differ diff --git a/Images/Fractal_terrain_texture.jpg b/Images/Fractal_terrain_texture.jpg new file mode 100644 index 0000000..4863243 Binary files /dev/null and b/Images/Fractal_terrain_texture.jpg differ diff --git a/Images/Pink_red_liquid_using_perlin_noise_+_bump_+_coloring.png b/Images/Pink_red_liquid_using_perlin_noise_+_bump_+_coloring.png new file mode 100644 index 0000000..1fc6a37 Binary files /dev/null and b/Images/Pink_red_liquid_using_perlin_noise_+_bump_+_coloring.png differ diff --git a/Parties/chap1_1.tex b/Parties/chap1_1.tex index 7596d98..a0cfd82 100644 --- a/Parties/chap1_1.tex +++ b/Parties/chap1_1.tex @@ -33,53 +33,56 @@ Cela a pour effet que le gradient de la fonction de bruit résultante à chaque nœud de grille coïncide avec le vecteur de gradient aléatoire précalculé. \newline -Voici le pseudo-code de l'implantation du bruit de Perlin à 2 dimensions: +Voici une version C++ de l'implantation du bruit de Perlin à 2 dimensions: -\begin{lstlisting}[caption=Implantation du bruit de Perlin en pseudo-code, label=code:perlin] - // Function to linearly interpolate between a0 and a1 - // Weight w should be in the range [0.0, 1.0] - function lerp(float a0, float a1, float w) { - return (1.0 - w)*a0 + w*a1; - } - - // Computes the dot product of the distance and gradient vectors. - function dotGridGradient(int ix, int iy, float x, float y) { - - // Precomputed (or otherwise) gradient vectors at each grid node - extern float Gradient[IYMAX][IXMAX][2]; - - // Compute the distance vector - float dx = x - (float)ix; - float dy = y - (float)iy; - - // Compute the dot-product - return (dx*Gradient[iy][ix][0] + dy*Gradient[iy][ix][1]); - } - - // Compute Perlin noise at coordinates x, y - function perlin(float x, float y) { - - // Determine grid cell coordinates - int x0 = floor(x); - int x1 = x0 + 1; - int y0 = floor(y); - int y1 = y0 + 1; - - // Determine interpolation weights - // Could also use higher order polynomial/s-curve here - float sx = x - (float)x0; - float sy = y - (float)y0; - - // Interpolate between grid point gradients - float n0, n1, ix0, ix1, value; - n0 = dotGridGradient(x0, y0, x, y); - n1 = dotGridGradient(x1, y0, x, y); - ix0 = lerp(n0, n1, sx); - n0 = dotGridGradient(x0, y1, x, y); - n1 = dotGridGradient(x1, y1, x, y); - ix1 = lerp(n0, n1, sx); - value = lerp(ix0, ix1, sy); - - return value; - } +\begin{lstlisting}[caption=Implantation du bruit de Perlin en C++, label=code:perlin] +// Function to linearly interpolate between a0 and a1 +// Weight w should be in the range [0.0, 1.0] +float lerp(float a0, float a1, float w) { + return (1.0 - w)*a0 + w*a1; + + // as an alternative, this slightly faster equivalent formula can be used: + // return a0 + w*(a1 - a0); +} + +// Computes the dot product of the distance and gradient vectors. +float dotGridGradient(int ix, int iy, float x, float y) { + + // Precomputed (or otherwise) gradient vectors at each grid node + extern float Gradient[IYMAX][IXMAX][2]; + + // Compute the distance vector + float dx = x - (float)ix; + float dy = y - (float)iy; + + // Compute the dot-product + return (dx*Gradient[iy][ix][0] + dy*Gradient[iy][ix][1]); +} + +// Compute Perlin noise at coordinates x, y +float perlin(float x, float y) { + + // Determine grid cell coordinates + int x0 = int(x); + int x1 = x0 + 1; + int y0 = int(y); + int y1 = y0 + 1; + + // Determine interpolation weights + // Could also use higher order polynomial/s-curve here + float sx = x - (float)x0; + float sy = y - (float)y0; + + // Interpolate between grid point gradients + float n0, n1, ix0, ix1, value; + n0 = dotGridGradient(x0, y0, x, y); + n1 = dotGridGradient(x1, y0, x, y); + ix0 = lerp(n0, n1, sx); + n0 = dotGridGradient(x0, y1, x, y); + n1 = dotGridGradient(x1, y1, x, y); + ix1 = lerp(n0, n1, sx); + value = lerp(ix0, ix1, sy); + + return value; +} \end{lstlisting} \ No newline at end of file diff --git a/Parties/chap1_2.tex b/Parties/chap1_2.tex index e69de29..8f85db4 100644 --- a/Parties/chap1_2.tex +++ b/Parties/chap1_2.tex @@ -0,0 +1,23 @@ +Due à sa grande flexibilité, ce générateur de bruit peut être utilisé pour +créer plusieurs types d'éléments comme les nuages, le feu, la fumée… +Voici Quelques exemples d'images produites depuis cette méthode: +\begin{figure} + \centering + \includegraphics[width=0.9\linewidth]{Images/Fractal_fire.jpg} + \caption{Feu généré à partir du bruit de Perlin} + \label{img:feu-perlin} +\end{figure} + +\begin{figure} + \centering + \includegraphics[width=0.9\linewidth]{Images/Fractal_terrain_texture.jpg} + \caption{Terrain généré à partir du bruit de Perlin} + \label{img:terrain-perlin} +\end{figure} + +\begin{figure} + \centering + \includegraphics[width=0.9\linewidth]{Images/Pink_red_liquid_using_perlin_noise_+_bump_+_coloring.png} + \caption{Surface organique générée à partir du bruit de Perlin et travaillée avec application texture et lumière} + \label{img:organique-perlin} +\end{figure} \ No newline at end of file diff --git a/rapport.pdf b/rapport.pdf index c4d787c..54bd003 100644 Binary files a/rapport.pdf and b/rapport.pdf differ diff --git a/rapport.tex b/rapport.tex index 091bdc5..e37ad9c 100644 --- a/rapport.tex +++ b/rapport.tex @@ -13,10 +13,10 @@ \newcommand{\guillemets}[1]{\og #1\fg{}} % [1]: nbr arg \lstset{ - language=C, % Code langugage + language=C++, % Code langugage basicstyle=\ttfamily, % Code font, Examples: \footnotesize, \ttfamily -% keywordstyle=\color{OliveGreen}, % Keywords font ('*' = uppercase) -% commentstyle=\color{gray}, % Comments font + % keywordstyle=\color{OliveGreen}, % Keywords font ('*' = uppercase) + % commentstyle=\color{gray}, % Comments font % numbers=left, % Line nums position % numberstyle=\tiny, % Line-numbers fonts % stepnumber=1, % Step between two line-numbers @@ -45,6 +45,7 @@ Université d'Aix-Marseille} \newpage \tableofcontents +\input{Parties/résumé.tex} \newpage \section*{Introduction} \input{Parties/intro.tex} @@ -55,8 +56,8 @@ Université d'Aix-Marseille} \input{Parties/chap1_1.tex} \subsection{Applications} \input{Parties/chap1_2.tex} -\subsection{Limitations} -\input{Parties/chap1_3.tex} +% \subsection{Limitations} +% \input{Parties/chap1_3.tex} \section{Bruit de Gabor} \input{Parties/chap2_intro.tex} @@ -77,8 +78,8 @@ Université d'Aix-Marseille} \section{Conclusion} \input{Parties/conclusion.tex} -\section{Résumé} -\input{Parties/résumé.tex} +% \section{Résumé} +% \input{Parties/résumé.tex} \section{Bibliographie} \end{document}