ProtoTracer  1.0
Real-time 3D rendering and animation engine
Loading...
Searching...
No Matches
DepthMaterial.cpp
Go to the documentation of this file.
1#include "DepthMaterial.h"
2
3DepthMaterial::DepthMaterial(Axis axis, float depth, float zOffset){
4 this->axis = axis;
5 this->depth = depth;
6 this->zOffset = zOffset;
7}
8
9RGBColor DepthMaterial::GetRGB(const Vector3D& position, const Vector3D& normal, const Vector3D& uvw) {
10 float axisValue = 0.0f;
11
12 switch (axis) {
13 case X:
14 axisValue = position.X;
15 break;
16 case Y:
17 axisValue = position.Y;
18 break;
19 case Z:
20 axisValue = position.Z;
21 break;
22 default:
23 break;
24 }
25
26 float pos = Mathematics::Map(axisValue, -depth / 2.0f + zOffset, depth / 2.0f + zOffset, 0.0f, 1.0f);
27
28 return gNoiseMat.GetRGB(Vector3D(pos, 0, 0), Vector3D(), Vector3D());
29}
Defines a material that maps depth along a specified axis to RGB values.
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.
DepthMaterial(Axis axis, float depth, float zOffset)
Constructs a DepthMaterial instance.
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.
RGBColor GetRGB(const Vector3D &position, const Vector3D &normal, const Vector3D &uvw) override
Gets the RGB color for a given position in the gradient.
static T Map(T value, T inLow, T inMax, T outMin, T outMax)
Maps a value from one range to another.
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
float Z
The Z-component of the 3D vector.
Definition Vector3D.h:30
float X
The X-component of the 3D vector.
Definition Vector3D.h:28
float Y
The Y-component of the 3D vector.
Definition Vector3D.h:29