libdonut  2.3.2
Application framework for cross-platform game development in C++20
Shader3D.hpp
Go to the documentation of this file.
1 #ifndef DONUT_GRAPHICS_SHADER_3D_HPP
2 #define DONUT_GRAPHICS_SHADER_3D_HPP
3 
7 
8 namespace donut::graphics {
9 
10 class Renderer; // Forward declaration, to avoid a circular include of Renderer.hpp.
11 
20 };
21 
25 class Shader3D {
26 public:
32 
42  static const char* const FRAGMENT_SHADER_SOURCE_CODE_UNLIT;
43 
54  static const char* const FRAGMENT_SHADER_SOURCE_CODE_BLINN_PHONG;
55 
64  static Shader3D* const UNLIT;
65 
74  static Shader3D* const BLINN_PHONG;
75 
80 
85 
90 
95 
100  ShaderParameter viewProjectionMatrix{program, "viewProjectionMatrix"};
101 
107 
113 
119 
125 
131 
137 
143 
149 
155 
161 
167 
180  Shader3D(const ShaderProgramOptions& programOptions, const Shader3DOptions& options = {})
181  : options(options)
182  , program(programOptions) {}
183 
184 private:
185  friend Renderer;
186 
187  static void createSharedShaders();
188  static void destroySharedShaders() noexcept;
189 };
190 
191 } // namespace donut::graphics
192 
193 #endif
ShaderProgram specialized for rendering Model instances in 3D.
Definition: Shader3D.hpp:25
ShaderParameter emissiveMap
Identifier for the uniform shader variable for the texture unit of the active material's emissive map...
Definition: Shader3D.hpp:124
ShaderParameter diffuseMap
Identifier for the uniform shader variable for the texture unit of the active material's diffuse map.
Definition: Shader3D.hpp:106
ShaderParameter normalScale
Identifier for the uniform shader variable for the active material's normal scale.
Definition: Shader3D.hpp:142
static Shader3D *const BLINN_PHONG
Pointer to the statically allocated storage for the built-in blinn-phong shader.
Definition: Shader3D.hpp:74
Shader3DOptions options
Shader configuration that was supplied in the constructor.
Definition: Shader3D.hpp:79
Shader3D(const ShaderProgramOptions &programOptions, const Shader3DOptions &options={})
Compile and link a 3D shader program.
Definition: Shader3D.hpp:180
ShaderParameter emissiveColor
Identifier for the uniform shader variable for the active material's emissive color.
Definition: Shader3D.hpp:148
ShaderParameter normalMap
Identifier for the uniform shader variable for the texture unit of the active material's normal map.
Definition: Shader3D.hpp:118
static Shader3D *const UNLIT
Pointer to the statically allocated storage for the built-in unlit shader.
Definition: Shader3D.hpp:64
ShaderParameter occlusionFactor
Identifier for the uniform shader variable for the active material's occlusion factor.
Definition: Shader3D.hpp:166
static const char *const VERTEX_SHADER_SOURCE_CODE_INSTANCED_MODEL
Pointer to a statically allocated string containing the GLSL source code for a plain vertex shader.
Definition: Shader3D.hpp:31
ShaderParameter specularColor
Identifier for the uniform shader variable for the active material's specular color.
Definition: Shader3D.hpp:136
ShaderParameter viewProjectionMatrix
Identifier for the uniform shader variable for the combined view-projection matrix.
Definition: Shader3D.hpp:100
ShaderParameter diffuseColor
Identifier for the uniform shader variable for the active material's diffuse color.
Definition: Shader3D.hpp:130
static const char *const FRAGMENT_SHADER_SOURCE_CODE_BLINN_PHONG
Pointer to a statically allocated string containing the GLSL source code for a fragment shader that u...
Definition: Shader3D.hpp:54
ShaderParameter specularMap
Identifier for the uniform shader variable for the texture unit of the active material's specular map...
Definition: Shader3D.hpp:112
ShaderParameter dissolveFactor
Identifier for the uniform shader variable for the active material's specular exponent.
Definition: Shader3D.hpp:160
static const char *const FRAGMENT_SHADER_SOURCE_CODE_UNLIT
Pointer to a statically allocated string containing the GLSL source code for a fragment shader that u...
Definition: Shader3D.hpp:42
ShaderProgram program
Shader program.
Definition: Shader3D.hpp:84
ShaderParameter projectionMatrix
Identifier for the uniform shader variable for the projection matrix.
Definition: Shader3D.hpp:89
ShaderParameter specularExponent
Identifier for the uniform shader variable for the active material's specular exponent.
Definition: Shader3D.hpp:154
ShaderParameter viewMatrix
Identifier for the uniform shader variable for the view matrix.
Definition: Shader3D.hpp:94
Identifier for a uniform shader variable inside a ShaderProgram.
Definition: ShaderParameter.hpp:17
Compiled and linked GPU shader program.
Definition: ShaderProgram.hpp:46
Definition: Buffer.hpp:7
Configuration options for a Shader3D.
Definition: Shader3D.hpp:15
ShaderConfiguration configuration
Shader configuration options, see ShaderConfiguration.
Definition: Shader3D.hpp:19
Base configuration options for a shader.
Definition: ShaderConfiguration.hpp:299
Configuration options for a ShaderProgram.
Definition: ShaderProgram.hpp:23