ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
FlowNoise.h
Go to the documentation of this file.
1/**
2 * @file FlowNoise.h
3 * @brief A dynamic simplex noise gradient material for a lava lamp effect.
4 *
5 * This file defines the FlowNoise class, which generates a dynamic gradient
6 * using simplex noise and animates the z-position over time to create a flowing,
7 * lava lamp-like visual effect.
8 *
9 * @date 22/12/2024
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "../AnimatedMaterial.h" // Base class for animated materials.
16#include "../../../Utils/Signals/FunctionGenerator.h" // Utility for generating animated functions.
17#include "../Static/GradientMaterial.h" // Include for gradient materials.
18#include "../Static/SimplexNoise.h" // Include for simplex noise generation.
19
20/**
21 * @class FlowNoise
22 * @brief A dynamic simplex noise gradient material for a flowing effect.
23 *
24 * The FlowNoise class generates a gradient using simplex noise and animates
25 * the z-position over time. The result is a flowing, lava lamp-like visual effect.
26 */
28private:
29 FunctionGenerator fGenMatGradientP = FunctionGenerator(FunctionGenerator::Sine, 0.25f, 1.5f, 4.35f); ///< Function for gradient property modulation.
30 FunctionGenerator fGenMatGradientX = FunctionGenerator(FunctionGenerator::Sine, 0.0f, 0.5f, 3.12f); ///< Function for x-axis modulation.
31 FunctionGenerator fGenMatGradientY = FunctionGenerator(FunctionGenerator::Sine, 0.0f, 0.5f, 1.93f); ///< Function for y-axis modulation.
32 FunctionGenerator fGenMatGradientZ = FunctionGenerator(FunctionGenerator::Sine, 0.0f, 0.5f, 4.56f); ///< Function for z-axis modulation.
33 RGBColor noiseSpectrum[2] = {RGBColor(14, 33, 160), RGBColor(236, 83, 176)}; ///< Gradient colors for the noise material.
34 GradientMaterial<2> gNoiseMat = GradientMaterial<2>(noiseSpectrum, 2.0f, false); ///< Gradient material for simplex noise.
35 SimplexNoise<2> sNoise = SimplexNoise<2>(1, &gNoiseMat); ///< Simplex noise generator.
36 float simplexNoiseDepth = 0.0f; ///< Depth parameter for simplex noise.
37
38public:
39 /**
40 * @brief Default constructor for FlowNoise.
41 */
43
44 /**
45 * @brief Sets a specific gradient color.
46 *
47 * @param color The RGB color to set.
48 * @param colorIndex The index in the gradient array to modify.
49 */
50 void SetGradient(RGBColor color, uint8_t colorIndex);
51
52 /**
53 * @brief Updates the material's state based on the provided time ratio.
54 *
55 * @param ratio The time ratio for animation updates.
56 */
57 void Update(float ratio);
58
59 /**
60 * @brief Retrieves the associated material.
61 *
62 * @return Pointer to the Material instance.
63 */
65
66 /**
67 * @brief Computes the color at a given position using simplex noise.
68 *
69 * @param position The position in 3D space.
70 * @param normal The surface normal vector.
71 * @param uvw The texture coordinates.
72 * @return The computed color as an RGBColor.
73 */
74 RGBColor GetRGB(const Vector3D& position, const Vector3D& normal, const Vector3D& uvw) override;
75};
Base class for dynamically updating materials.
A dynamic simplex noise gradient material for a flowing effect.
Definition FlowNoise.h:27
FunctionGenerator fGenMatGradientX
Function for x-axis modulation.
Definition FlowNoise.h:30
FunctionGenerator fGenMatGradientZ
Function for z-axis modulation.
Definition FlowNoise.h:32
Material * GetMaterial()
Retrieves the associated material.
Definition FlowNoise.cpp:23
float simplexNoiseDepth
Depth parameter for simplex noise.
Definition FlowNoise.h:36
FlowNoise()
Default constructor for FlowNoise.
Definition FlowNoise.h:42
RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
Computes the color at a given position using simplex noise.
Definition FlowNoise.cpp:27
FunctionGenerator fGenMatGradientY
Function for y-axis modulation.
Definition FlowNoise.h:31
RGBColor noiseSpectrum[2]
Gradient colors for the noise material.
Definition FlowNoise.h:33
void SetGradient(RGBColor color, uint8_t colorIndex)
Sets a specific gradient color.
Definition FlowNoise.cpp:3
GradientMaterial< 2 > gNoiseMat
Gradient material for simplex noise.
Definition FlowNoise.h:34
void Update(float ratio)
Updates the material's state based on the provided time ratio.
Definition FlowNoise.cpp:8
SimplexNoise< 2 > sNoise
Simplex noise generator.
Definition FlowNoise.h:35
FunctionGenerator fGenMatGradientP
Function for gradient property modulation.
Definition FlowNoise.h:29
A class to generate various waveform functions with customizable parameters.
@ Sine
Sine waveform.
Creates a customizable gradient material for rendering.
Abstract base class for rendering materials.
Definition Material.h:27
Represents an RGB color and provides methods for manipulation.
Definition RGBColor.h:23
A material class for rendering Simplex Noise.
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26