t
Loading...
Searching...
No Matches
SolidColor.hpp
1#include "materials/Material.hpp"
2
3#ifndef SOLIDCOLOR_HPP
4#define SOLIDCOLOR_HPP
5
6namespace t {
7
13class SolidColor : public Material {
14public:
17 ~SolidColor() override = default;
18
24 explicit SolidColor(Color _color) : color(_color) {}
25
26 Vector4 vertexShader(const Uniforms &uniforms,
27 const Attributes &attributes) override {
28 return uniforms.projectionMatrix * uniforms.modelViewMatrix *
29 Vector4(attributes.localPosition, 1.0);
30 }
31
33 const Uniforms &uniforms, const Varyings &varyings,
34 const std::vector<std::reference_wrapper<Light>> &lights) override {
35 return this->color;
36 }
37};
38
39} // namespace t
40
41#endif // SOLIDCOLOR_HPP
The color class.
Definition Color.hpp:18
The base material class.
Definition Material.hpp:24
A material that appears in one single color and is unaffected by lights.
Definition SolidColor.hpp:13
Color color
The color of this material.
Definition SolidColor.hpp:15
Color fragmentShader(const Uniforms &uniforms, const Varyings &varyings, const std::vector< std::reference_wrapper< Light > > &lights) override
The fragment shader of this material, which will be run for every fragment that the mesh covers on th...
Definition SolidColor.hpp:32
SolidColor(Color _color)
Creates a new solid color material.
Definition SolidColor.hpp:24
Vector4 vertexShader(const Uniforms &uniforms, const Attributes &attributes) override
The vertex shader of this material, which will be run for every vertex of the mesh's geometry.
Definition SolidColor.hpp:26
The 4D vector class.
Definition Vector4.hpp:20
The t software 3D graphics library namespace.
Definition algorithms.hpp:12
The attributes of a vertex, available to vertex shaders.
Definition Attributes.hpp:14
Vector3 & localPosition
The local position of the current vertex.
Definition Attributes.hpp:15
The uniforms available to vertex shaders and fragment shaders.
Definition Uniforms.hpp:19
Matrix4x4 & projectionMatrix
The projection matrix of the active camera.
Definition Uniforms.hpp:24
Matrix4x4 & modelViewMatrix
The product of the view matrix and the model matrix.
Definition Uniforms.hpp:21
The varyings available to fragment shaders.
Definition Varyings.hpp:19