ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
NormalMaterial.cpp
Go to the documentation of this file.
1#include "NormalMaterial.h"
2
4
5RGBColor NormalMaterial::GetRGB(const Vector3D& position, const Vector3D& normal, const Vector3D& uvw) {
6 Vector3D normalL = normal;
7
8 normalL = normalL.UnitSphere();
9
10 normalL = (normalL + 1.0f) * 0.5f * 255.0f;
11
12 return RGBColor(normalL);
13}
A material class that visualizes surface normals.
RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
Calculates the RGB color based on the surface normal vector.
NormalMaterial()
Constructs a NormalMaterial object.
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
Vector3D UnitSphere() const
Normalizes this vector such that its magnitude is 1 (if non-zero).
Definition Vector3D.cpp:106