t
Loading...
Searching...
No Matches
NormalColor.hpp
1#include "materials/Material.hpp"
2
3#ifndef NORMALCOLOR_HPP
4#define NORMALCOLOR_HPP
5
6namespace t {
7
13class NormalColor : public Material {
14public:
15 Vector4 vertexShader(const Uniforms &uniforms,
16 const Attributes &attributes) override {
17 return uniforms.projectionMatrix * uniforms.modelViewMatrix *
18 Vector4(attributes.localPosition, 1.0);
19 }
20
22 const Uniforms &uniforms, const Varyings &varyings,
23 const std::vector<std::reference_wrapper<Light>> &lights) override {
24 return Color(varyings.localNormal.absolute());
25 }
26};
27
28} // namespace t
29
30#endif // NORMALCOLOR_HPP
The color class.
Definition Color.hpp:18
The base material class.
Definition Material.hpp:24
A material that maps the mesh's normal vectors to normalized RGB colors.
Definition NormalColor.hpp:13
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 NormalColor.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 NormalColor.hpp:21
Vector3 absolute() const
Returns a new 3D vector with the absolute values of the components of this 3D vector.
Definition Vector3.hpp:171
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
Vector3 & localNormal
The normal vector in local space associated with the current fragment.
Definition Varyings.hpp:22