ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
TVStatic.h
Go to the documentation of this file.
1/**
2 * @file TVStatic.h
3 * @brief A dynamic material for simulating TV static with various noise effects.
4 *
5 * The TVStatic class creates a realistic TV static effect using a combination of simplex noise,
6 * gradients, and scanline effects. It provides an animated material that dynamically changes
7 * over time, with additional customization options.
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" // For generating animated signals.
17#include "../Static/GradientMaterial.h" // For gradient-based coloring.
18#include "../Static/SimplexNoise.h" // For generating noise patterns.
19#include "../CombineMaterial.h" // For combining multiple materials.
20#include "../../../Assets/Textures/Static/ColorTest.h" // For additional color test effects.
21
22/**
23 * @class TVStatic
24 * @brief Simulates a TV static effect with noise, scanlines, and color variations.
25 *
26 * The TVStatic class generates a dynamic and customizable TV static effect using a combination
27 * of simplex noise, gradient materials, scanline effects, and color overlays. The effect
28 * includes animation based on function generators and allows for layering multiple materials.
29 */
30class TVStatic : public AnimatedMaterial {
31private:
32 FunctionGenerator colorWiggle1 = FunctionGenerator(FunctionGenerator::Sine, -40.0f, 20.0f, 1.95f); ///< Function for animating color wiggles.
33 FunctionGenerator colorWiggle2 = FunctionGenerator(FunctionGenerator::Sine, -10.0f, 10.0f, 0.87f); ///< Secondary function for color variation.
34 FunctionGenerator fGenMatGradient = FunctionGenerator(FunctionGenerator::Sine, 0.0f, 0.5f, 6.65f); ///< Function for gradient animation.
35
37 RGBColor(255, 255, 255),
38 RGBColor(0, 0, 0),
39 RGBColor(255, 0, 0),
40 RGBColor(0, 255, 0),
41 RGBColor(0, 0, 255)
42 }; ///< Spectrum for simplex noise coloring.
43
44 GradientMaterial<5> gNoiseMat = GradientMaterial<5>(noiseSpectrum, 2.0f, false, true); ///< Gradient for simplex noise material.
45 SimplexNoise<5> sNoise = SimplexNoise<5>(1, &gNoiseMat); ///< Simplex noise generator for TV static.
46
47 float simplexNoiseDepth = 0.0f; ///< Depth value for simplex noise animation.
48
50 RGBColor(0, 0, 0),
51 RGBColor(0, 0, 0),
52 RGBColor(255, 255, 255),
53 RGBColor(0, 0, 0),
54 RGBColor(255, 255, 255),
55 RGBColor(255, 255, 255),
56 RGBColor(255, 255, 255),
57 RGBColor(0, 0, 0),
58 RGBColor(0, 0, 0),
59 RGBColor(255, 255, 255)
60 }; ///< Spectrum for scanline effects.
61
62 GradientMaterial<10> scanlineGradient = GradientMaterial<10>(scanlineSpectrum, 100.0f, false, false); ///< Scanline gradient material.
63
64 ColorTest colorTest = ColorTest(Vector2D(192.0f, 96.0f), Vector2D(140.0f, 72.0f)); ///< Color test overlay.
65 CombineMaterial<3> combineScanline = CombineMaterial<3>(); ///< Material combiner for layering effects.
66
67public:
68 /**
69 * @brief Constructor for TVStatic.
70 *
71 * Initializes the materials and sets up the layers for combining the noise, scanlines,
72 * and color effects.
73 */
75 // Add simplex noise, scanline gradient, and color test to the combiner.
79
80 // Rotate scanline gradient for vertical alignment.
82 }
83
84 /**
85 * @brief Updates the animation parameters for the TV static effect.
86 *
87 * @param ratio The elapsed time ratio for updating animations.
88 */
89 void Update(float ratio);
90
91 /**
92 * @brief Retrieves the combined material representing the TV static effect.
93 *
94 * @return Pointer to the combined material.
95 */
97
98 /**
99 * @brief Computes the color at a given position in the material.
100 *
101 * This method combines the noise, scanline, and color test effects to generate
102 * the final color.
103 *
104 * @param position The position in 3D space.
105 * @param normal The surface normal vector.
106 * @param uvw The texture coordinates.
107 * @return The computed color as an RGBColor.
108 */
109 RGBColor GetRGB(const Vector3D& position, const Vector3D& normal, const Vector3D& uvw) override;
110};
Base class for dynamically updating materials.
Combines multiple materials with specified blending methods and opacities.
void AddMaterial(Method method, Material *material, float opacity)
Adds a new material to the combination.
A class to generate various waveform functions with customizable parameters.
@ Sine
Sine waveform.
Creates a customizable gradient material for rendering.
void SetRotationAngle(float rotationAngle)
Sets the rotation angle for the gradient.
Abstract base class for rendering materials.
Definition Material.h:27
@ Lighten
Chooses the lighter color.
Definition Material.h:40
@ Base
The base material color.
Definition Material.h:34
@ Multiply
Multiplies colors.
Definition Material.h:37
Represents an RGB color and provides methods for manipulation.
Definition RGBColor.h:23
A material class for rendering Simplex Noise.
Simulates a TV static effect with noise, scanlines, and color variations.
Definition TVStatic.h:30
RGBColor noiseSpectrum[5]
Spectrum for simplex noise coloring.
Definition TVStatic.h:36
CombineMaterial< 3 > combineScanline
Material combiner for layering effects.
Definition TVStatic.h:65
GradientMaterial< 10 > scanlineGradient
Scanline gradient material.
Definition TVStatic.h:62
RGBColor scanlineSpectrum[10]
Spectrum for scanline effects.
Definition TVStatic.h:49
SimplexNoise< 5 > sNoise
Simplex noise generator for TV static.
Definition TVStatic.h:45
TVStatic()
Constructor for TVStatic.
Definition TVStatic.h:74
Material * GetMaterial()
Retrieves the combined material representing the TV static effect.
Definition TVStatic.cpp:17
float simplexNoiseDepth
Depth value for simplex noise animation.
Definition TVStatic.h:47
RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
Computes the color at a given position in the material.
Definition TVStatic.cpp:21
FunctionGenerator colorWiggle1
Function for animating color wiggles.
Definition TVStatic.h:32
FunctionGenerator colorWiggle2
Secondary function for color variation.
Definition TVStatic.h:33
void Update(float ratio)
Updates the animation parameters for the TV static effect.
Definition TVStatic.cpp:3
GradientMaterial< 5 > gNoiseMat
Gradient for simplex noise material.
Definition TVStatic.h:44
FunctionGenerator fGenMatGradient
Function for gradient animation.
Definition TVStatic.h:34
ColorTest colorTest
Color test overlay.
Definition TVStatic.h:64
Represents a 2D vector (X, Y) and provides methods for vector arithmetic.
Definition Vector2D.h:27
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26