libdonut  2.3.2
Application framework for cross-platform game development in C++20
Public Member Functions | Public Attributes | Static Public Attributes | List of all members
donut::graphics::Shader3D Class Reference

ShaderProgram specialized for rendering Model instances in 3D. More...

#include <donut/graphics/Shader3D.hpp>

Public Member Functions

 Shader3D (const ShaderProgramOptions &programOptions, const Shader3DOptions &options={})
 Compile and link a 3D shader program. More...
 

Public Attributes

Shader3DOptions options
 Shader configuration that was supplied in the constructor. More...
 
ShaderProgram program
 Shader program. More...
 
ShaderParameter projectionMatrix {program, "projectionMatrix"}
 Identifier for the uniform shader variable for the projection matrix. More...
 
ShaderParameter viewMatrix {program, "viewMatrix"}
 Identifier for the uniform shader variable for the view matrix. More...
 
ShaderParameter viewProjectionMatrix {program, "viewProjectionMatrix"}
 Identifier for the uniform shader variable for the combined view-projection matrix. More...
 
ShaderParameter diffuseMap {program, "diffuseMap"}
 Identifier for the uniform shader variable for the texture unit of the active material's diffuse map. More...
 
ShaderParameter specularMap {program, "specularMap"}
 Identifier for the uniform shader variable for the texture unit of the active material's specular map. More...
 
ShaderParameter normalMap {program, "normalMap"}
 Identifier for the uniform shader variable for the texture unit of the active material's normal map. More...
 
ShaderParameter emissiveMap {program, "emissiveMap"}
 Identifier for the uniform shader variable for the texture unit of the active material's emissive map. More...
 
ShaderParameter diffuseColor {program, "diffuseColor"}
 Identifier for the uniform shader variable for the active material's diffuse color. More...
 
ShaderParameter specularColor {program, "specularColor"}
 Identifier for the uniform shader variable for the active material's specular color. More...
 
ShaderParameter normalScale {program, "normalScale"}
 Identifier for the uniform shader variable for the active material's normal scale. More...
 
ShaderParameter emissiveColor {program, "emissiveColor"}
 Identifier for the uniform shader variable for the active material's emissive color. More...
 
ShaderParameter specularExponent {program, "specularExponent"}
 Identifier for the uniform shader variable for the active material's specular exponent. More...
 
ShaderParameter dissolveFactor {program, "dissolveFactor"}
 Identifier for the uniform shader variable for the active material's specular exponent. More...
 
ShaderParameter occlusionFactor {program, "occlusionFactor"}
 Identifier for the uniform shader variable for the active material's occlusion factor. More...
 

Static Public Attributes

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. More...
 
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 uses a fullbright shading model with no lights. More...
 
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 uses the Blinn-Phong shading model with a single basic point light at a fixed position. More...
 
static Shader3D *const UNLIT
 Pointer to the statically allocated storage for the built-in unlit shader. More...
 
static Shader3D *const BLINN_PHONG
 Pointer to the statically allocated storage for the built-in blinn-phong shader. More...
 

Detailed Description

ShaderProgram specialized for rendering Model instances in 3D.

Examples
example_game.cpp.

Constructor & Destructor Documentation

◆ Shader3D()

donut::graphics::Shader3D::Shader3D ( const ShaderProgramOptions programOptions,
const Shader3DOptions options = {} 
)
inline

Compile and link a 3D shader program.

Parameters
programOptionsbase options for the ShaderProgram, see ShaderProgramOptions.
optionsadditional options for the shader, see Shader3DOptions.
Exceptions
graphics::Erroron failure to create a shader object, create the shader program object, compile the shader code or link the shader program.
std::bad_allocon allocation failure.

Member Data Documentation

◆ VERTEX_SHADER_SOURCE_CODE_INSTANCED_MODEL

const char* const donut::graphics::Shader3D::VERTEX_SHADER_SOURCE_CODE_INSTANCED_MODEL
static

Pointer to a statically allocated string containing the GLSL source code for a plain vertex shader.

Examples
example_game.cpp.

◆ FRAGMENT_SHADER_SOURCE_CODE_UNLIT

const char* const donut::graphics::Shader3D::FRAGMENT_SHADER_SOURCE_CODE_UNLIT
static

Pointer to a statically allocated string containing the GLSL source code for a fragment shader that uses a fullbright shading model with no lights.

Note
This shader uses only the diffuse texture and renders it at 100% brightness without taking details such as specular highlights, normal mapping or emissive color into account.

◆ FRAGMENT_SHADER_SOURCE_CODE_BLINN_PHONG

const char* const donut::graphics::Shader3D::FRAGMENT_SHADER_SOURCE_CODE_BLINN_PHONG
static

Pointer to a statically allocated string containing the GLSL source code for a fragment shader that uses the Blinn-Phong shading model with a single basic point light at a fixed position.

Note
This basic shader should mainly be used for testing or debugging since the light parameters are completely arbitrary. Proper 3D applications should typically use a custom fragment shader that receives the light positions and colors as uniform data instead.

◆ UNLIT

Shader3D* const donut::graphics::Shader3D::UNLIT
static

Pointer to the statically allocated storage for the built-in unlit shader.

Warning
This pointer must not be dereferenced in application code. It is not guaranteed that the underlying shader will be present at all times.

◆ BLINN_PHONG

Shader3D* const donut::graphics::Shader3D::BLINN_PHONG
static

Pointer to the statically allocated storage for the built-in blinn-phong shader.

Warning
This pointer must not be dereferenced in application code. It is not guaranteed that the underlying shader will be present at all times.

◆ options

Shader3DOptions donut::graphics::Shader3D::options

Shader configuration that was supplied in the constructor.

◆ program

ShaderProgram donut::graphics::Shader3D::program

Shader program.

◆ projectionMatrix

ShaderParameter donut::graphics::Shader3D::projectionMatrix {program, "projectionMatrix"}

Identifier for the uniform shader variable for the projection matrix.

◆ viewMatrix

ShaderParameter donut::graphics::Shader3D::viewMatrix {program, "viewMatrix"}

Identifier for the uniform shader variable for the view matrix.

◆ viewProjectionMatrix

ShaderParameter donut::graphics::Shader3D::viewProjectionMatrix {program, "viewProjectionMatrix"}

Identifier for the uniform shader variable for the combined view-projection matrix.

◆ diffuseMap

ShaderParameter donut::graphics::Shader3D::diffuseMap {program, "diffuseMap"}

Identifier for the uniform shader variable for the texture unit of the active material's diffuse map.

◆ specularMap

ShaderParameter donut::graphics::Shader3D::specularMap {program, "specularMap"}

Identifier for the uniform shader variable for the texture unit of the active material's specular map.

◆ normalMap

ShaderParameter donut::graphics::Shader3D::normalMap {program, "normalMap"}

Identifier for the uniform shader variable for the texture unit of the active material's normal map.

◆ emissiveMap

ShaderParameter donut::graphics::Shader3D::emissiveMap {program, "emissiveMap"}

Identifier for the uniform shader variable for the texture unit of the active material's emissive map.

◆ diffuseColor

ShaderParameter donut::graphics::Shader3D::diffuseColor {program, "diffuseColor"}

Identifier for the uniform shader variable for the active material's diffuse color.

◆ specularColor

ShaderParameter donut::graphics::Shader3D::specularColor {program, "specularColor"}

Identifier for the uniform shader variable for the active material's specular color.

◆ normalScale

ShaderParameter donut::graphics::Shader3D::normalScale {program, "normalScale"}

Identifier for the uniform shader variable for the active material's normal scale.

◆ emissiveColor

ShaderParameter donut::graphics::Shader3D::emissiveColor {program, "emissiveColor"}

Identifier for the uniform shader variable for the active material's emissive color.

◆ specularExponent

ShaderParameter donut::graphics::Shader3D::specularExponent {program, "specularExponent"}

Identifier for the uniform shader variable for the active material's specular exponent.

◆ dissolveFactor

ShaderParameter donut::graphics::Shader3D::dissolveFactor {program, "dissolveFactor"}

Identifier for the uniform shader variable for the active material's specular exponent.

◆ occlusionFactor

ShaderParameter donut::graphics::Shader3D::occlusionFactor {program, "occlusionFactor"}

Identifier for the uniform shader variable for the active material's occlusion factor.


The documentation for this class was generated from the following file: