ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
DepthMaterial.h
Go to the documentation of this file.
1/**
2 * @file DepthMaterial.h
3 * @brief Defines a material that maps depth along a specified axis to RGB values.
4 *
5 * The `DepthMaterial` class uses a gradient to represent depth values along a specified axis.
6 * This is particularly useful for visualizing 3D spatial data as a color gradient.
7 *
8 * @date 22/12/2024
9 * @author Coela Can't
10 */
11
12#pragma once
13
14#include "../Material.h" // Base class for materials.
15#include "../../../Utils/Math/Mathematics.h" // Utilities for mathematical operations.
16#include "GradientMaterial.h" // For creating gradient-based color mapping.
17
18/**
19 * @class DepthMaterial
20 * @brief Maps depth along a specified axis to an RGB color using a gradient.
21 *
22 * The `DepthMaterial` class converts spatial depth data into RGB colors based on a gradient.
23 * It supports customization of the depth axis and offset for precise visualization.
24 */
25class DepthMaterial : public Material {
26public:
27 /**
28 * @enum Axis
29 * @brief Specifies the axis along which depth is calculated.
30 */
31 enum Axis {
32 X, ///< Depth along the X-axis.
33 Y, ///< Depth along the Y-axis.
34 Z ///< Depth along the Z-axis.
35 };
36
37private:
38 RGBColor spectrum[4] = { RGBColor(0, 255, 0), RGBColor(255, 0, 0), RGBColor(0, 255, 0), RGBColor(0, 0, 255) }; ///< Gradient spectrum for depth mapping.
39 GradientMaterial<4> gNoiseMat = GradientMaterial<4>(spectrum, 2.0f, false); ///< Gradient material for depth mapping.
40 Axis axis; ///< Axis along which depth is calculated.
41 float depth = 0.0f; ///< Depth scaling factor.
42 float zOffset = 0.0f; ///< Z-axis offset for depth calculation.
43
44public:
45 /**
46 * @brief Constructs a DepthMaterial instance.
47 *
48 * @param axis The axis along which depth is calculated.
49 * @param depth The scaling factor for depth.
50 * @param zOffset The offset along the Z-axis for depth calculation.
51 */
52 DepthMaterial(Axis axis, float depth, float zOffset);
53
54 /**
55 * @brief Calculates the RGB color at a given position based on depth.
56 *
57 * @param position The position in 3D space.
58 * @param normal The surface normal vector.
59 * @param uvw The texture coordinates.
60 * @return The calculated RGB color based on depth.
61 */
62 RGBColor GetRGB(const Vector3D& position, const Vector3D& normal, const Vector3D& uvw) override;
63};
Defines a material for creating gradient color effects in 3D rendering.
Maps depth along a specified axis to an RGB color using a gradient.
RGBColor spectrum[4]
Gradient spectrum for depth mapping.
GradientMaterial< 4 > gNoiseMat
Gradient material for depth mapping.
float zOffset
Z-axis offset for depth calculation.
Axis axis
Axis along which depth is calculated.
float depth
Depth scaling factor.
RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
Calculates the RGB color at a given position based on depth.
Axis
Specifies the axis along which depth is calculated.
@ Y
Depth along the Y-axis.
@ X
Depth along the X-axis.
@ Z
Depth along the Z-axis.
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
Represents a 3D vector (X, Y, Z) and provides methods for vector arithmetic.
Definition Vector3D.h:26