ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
Material.h
Go to the documentation of this file.
1/**
2 * @file Material.h
3 * @brief Base class for materials defining shading and rendering behavior.
4 *
5 * The `Material` class serves as an interface for materials that calculate
6 * color based on various blending methods and surface parameters.
7 *
8 * @date 22/12/2024
9 * @version 1.0
10 * @author Coela Can't
11 */
12
13#pragma once
14
15#include "../../Utils/RGBColor.h"
16#include "../../Utils/Math/Vector3D.h"
17
18/**
19 * @class Material
20 * @brief Abstract base class for rendering materials.
21 *
22 * The `Material` class provides a virtual interface for deriving specific
23 * material types, defining how colors are computed based on position, normals,
24 * and UVW texture coordinates. Materials also support various blending methods
25 * through the `Method` enumeration.
26 */
27class Material {
28public:
29 /**
30 * @enum Method
31 * @brief Defines blending methods for combining colors.
32 */
33 enum Method {
34 Base, ///< The base material color.
35 Add, ///< Adds colors together.
36 Subtract, ///< Subtracts colors.
37 Multiply, ///< Multiplies colors.
38 Divide, ///< Divides colors.
39 Darken, ///< Chooses the darker color.
40 Lighten, ///< Chooses the lighter color.
41 Screen, ///< Screen blending.
42 Overlay, ///< Overlay blending.
43 SoftLight, ///< Soft light blending.
44 Replace, ///< Replaces the base color.
45 EfficientMask, ///< Efficient masking method.
46 Bypass ///< Passes through without blending.
47 };
48
49 /**
50 * @brief Pure virtual function to calculate color based on surface parameters.
51 *
52 * @param position The position in 3D space.
53 * @param normal The normal vector at the position.
54 * @param uvw The UVW texture coordinates.
55 * @return The computed color as `RGBColor`.
56 */
57 virtual RGBColor GetRGB(const Vector3D& position, const Vector3D& normal, const Vector3D& uvw) = 0;
58
59 /**
60 * @brief Virtual destructor for proper cleanup in derived classes.
61 */
62 virtual ~Material() = default;
63};
Abstract base class for rendering materials.
Definition Material.h:27
Method
Defines blending methods for combining colors.
Definition Material.h:33
@ Bypass
Passes through without blending.
Definition Material.h:46
@ Lighten
Chooses the lighter color.
Definition Material.h:40
@ Add
Adds colors together.
Definition Material.h:35
@ Divide
Divides colors.
Definition Material.h:38
@ Screen
Screen blending.
Definition Material.h:41
@ EfficientMask
Efficient masking method.
Definition Material.h:45
@ Replace
Replaces the base color.
Definition Material.h:44
@ Overlay
Overlay blending.
Definition Material.h:42
@ Darken
Chooses the darker color.
Definition Material.h:39
@ SoftLight
Soft light blending.
Definition Material.h:43
@ Base
The base material color.
Definition Material.h:34
@ Multiply
Multiplies colors.
Definition Material.h:37
@ Subtract
Subtracts colors.
Definition Material.h:36
virtual RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw)=0
Pure virtual function to calculate color based on surface parameters.
virtual ~Material()=default
Virtual destructor for proper cleanup in derived classes.
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