|
Oxygen Engine
Modern C++ 3D Engine using OpenGL
|
#include <OxygenEngine/render/shader_base.h>
Inheritance diagram for oe::render::ShaderBase:
Collaboration diagram for oe::render::ShaderBase:Public Member Functions | |
| ShaderBase (const std::string &name="") | |
| Create a new shader instance. | |
| template<typename T > | |
| void | define (const std::string &name, const T &value) |
| Define a shader constant. | |
| void | define (const std::string &name, const char *value) |
| Define a shader constant. | |
| void | define (const std::string &name, const std::string &value) |
| Define a shader constant. | |
| void | define (const std::string &name) |
| Define a shader constant without value. | |
| const std::string & | getName () const |
| Get shader name. | |
| void | compile (const GeometryPass vertex_pass, const RenderingPass fragment_pass) |
| Compile / link the shader using the graphic API. | |
| void | bind (const GeometryPass vertex_pass, const RenderingPass fragment_pass) |
| Use the shader in graphic API. | |
| void | fillFromCamera (const scene::Camera &camera) noexcept |
| Fill uniforms from camera (mainly position + transform matrices) | |
| void | fillTextures (const std::map< std::string, std::pair< uint32_t, std::shared_ptr< oe::render::Texture > > > &textures) |
| Fill textures uniforms + bind textures. | |
| void | fillCubemaps (const std::map< std::string, std::pair< uint32_t, std::shared_ptr< oe::render::Cubemap > > > &cubemaps) |
| Fill cubemaps uniforms + bind cubemaps. | |
| void | fillFromMaterial (const scene::Material *material) |
| Fill uniforms from material. | |
| void | unbind () |
| Tell the graphic API to release this shader. | |
| void | setInt (const std::string &name, const int32_t value) |
| Send an int uniform to the shader. | |
| void | setUInt (const std::string &name, const uint32_t value) |
| Send an unsigned int uniform to the shader. | |
| void | setFloat (const std::string &name, const float value) |
| Send a float uniform to the shader. | |
| void | setDouble (const std::string &name, const double value) |
| Send a double uniform to the shader. | |
| void | setMat3 (const std::string &name, const glm::mat3 &value) |
| Send a 3x3 matrix uniform to the shader. | |
| void | setMat4 (const std::string &name, const glm::mat4 &value) |
| Send a 4x4 matrix uniform to the shader. | |
| void | setVec2i (const std::string &name, const glm::ivec2 &value) |
| Send an ivec2 uniform to the shader. | |
| void | setVec2 (const std::string &name, const glm::vec2 &value) |
| Send a vec2 uniform to the shader. | |
| void | setVec3 (const std::string &name, const glm::vec3 &value) |
| Send a vec3 uniform to the shader. | |
| void | setVec4 (const std::string &name, const glm::vec4 &value) |
| Send a vec4 uniform to the shader. | |
| void | setIntArray (const std::string &name, const std::vector< int32_t > &values) |
| Send an array of int uniforms to the shader. | |
| void | setUIntArray (const std::string &name, const std::vector< uint32_t > &values) |
| Send a array of unsigned int uniforms to the shader. | |
| void | setFloatArray (const std::string &name, const std::vector< float > &values) |
| Send an array of float uniforms to the shader. | |
| void | setDoubleArray (const std::string &name, const std::vector< double > &values) |
| Send an array of double uniforms to the shader. | |
| void | setVec2iArray (const std::string &name, const std::vector< glm::ivec2 > &values) |
| Send an array of ivec2 uniforms to the shader. | |
| void | setVec2Array (const std::string &name, const std::vector< glm::vec2 > &values) |
| Send an array of vec2 uniforms to the shader. | |
| void | setVec3Array (const std::string &name, const std::vector< glm::vec3 > &values) |
| Send an array of vec3 uniforms to the shader. | |
| void | setVec4Array (const std::string &name, const std::vector< glm::vec4 > &values) |
| Send an array of vec4 uniforms to the shader. | |
| void | setMat4Array (const std::string &name, const std::vector< glm::mat4 > &values) |
| Send an array of matrix uniforms to the shader. | |
Protected Attributes | |
| std::unordered_map< GeometryPass, std::string > | _vertex_shader_sources |
| std::unordered_map< RenderingPass, std::string > | _fragment_shader_sources |
| std::string | _header |
Additional Inherited Members | |
Protected Member Functions inherited from oe::util::NonCopyable | |
| NonCopyable (NonCopyable &&)=default | |
| NonCopyable & | operator= (NonCopyable &&)=default |
Shader class.
| oe::render::ShaderBase::ShaderBase | ( | const std::string & | name = "" | ) |
Create a new shader instance.
| name | Name of the shader (will be used in error messages) |
| void oe::render::ShaderBase::bind | ( | const GeometryPass | vertex_pass, |
| const RenderingPass | fragment_pass | ||
| ) |
Use the shader in graphic API.
| void oe::render::ShaderBase::compile | ( | const GeometryPass | vertex_pass, |
| const RenderingPass | fragment_pass | ||
| ) |
Compile / link the shader using the graphic API.
| Exception | if compilation / linking failed or pass combination not available |
|
inline |
Define a shader constant without value.
Same behavior as if you added #define MY_CONSTANT in the shader code
| name | Constant name |
|
inline |
Define a shader constant.
Overload for a C-style string
|
inline |
Define a shader constant.
Overload for string
|
inline |
Define a shader constant.
Same behavior as if you added #define MY_CONSTANT VALUE in the shader code
| name | Constant name |
| value | Constant value |
|
noexcept |
Fill uniforms from camera (mainly position + transform matrices)
These uniforms will be filled from the camera:
vec3 uEyePos : World space camera positionmat4 uTransform : Matrix to conert from world space to clip space | void oe::render::ShaderBase::fillFromMaterial | ( | const scene::Material * | material | ) |
Fill uniforms from material.
| Uniform name | Description |
|---|---|
float uAlphaCutoff | Alpha threshold |
vec2 uTextureUVTilling | Texture tiling data |
vec2 uTextureUVOffset | Texture offset |
float uTransmission | Transmissive factor |
float uThickness | Thickness |
|
inline |
Get shader name.
| void oe::render::ShaderBase::setDouble | ( | const std::string & | name, |
| const double | value | ||
| ) |
Send a double uniform to the shader.
| name | Uniform name in shader |
| value | Uniform value to send |
| void oe::render::ShaderBase::setDoubleArray | ( | const std::string & | name, |
| const std::vector< double > & | values | ||
| ) |
Send an array of double uniforms to the shader.
| name | Uniform name in shader |
| values | Uniform values to send |
| void oe::render::ShaderBase::setFloat | ( | const std::string & | name, |
| const float | value | ||
| ) |
Send a float uniform to the shader.
| name | Uniform name in shader |
| value | Uniform value to send |
| void oe::render::ShaderBase::setFloatArray | ( | const std::string & | name, |
| const std::vector< float > & | values | ||
| ) |
Send an array of float uniforms to the shader.
| name | Uniform name in shader |
| values | Uniform values to send |
| void oe::render::ShaderBase::setInt | ( | const std::string & | name, |
| const int32_t | value | ||
| ) |
Send an int uniform to the shader.
| name | Uniform name in shader |
| value | Uniform value to send |
| void oe::render::ShaderBase::setIntArray | ( | const std::string & | name, |
| const std::vector< int32_t > & | values | ||
| ) |
Send an array of int uniforms to the shader.
| name | Uniform name in shader |
| values | Uniform values to send |
| void oe::render::ShaderBase::setMat3 | ( | const std::string & | name, |
| const glm::mat3 & | value | ||
| ) |
Send a 3x3 matrix uniform to the shader.
| name | Uniform name in shader |
| value | Uniform value to send |
| void oe::render::ShaderBase::setMat4 | ( | const std::string & | name, |
| const glm::mat4 & | value | ||
| ) |
Send a 4x4 matrix uniform to the shader.
| name | Uniform name in shader |
| value | Uniform value to send |
| void oe::render::ShaderBase::setMat4Array | ( | const std::string & | name, |
| const std::vector< glm::mat4 > & | values | ||
| ) |
Send an array of matrix uniforms to the shader.
| name | Uniform name in shader |
| values | Uniform values to send |
| void oe::render::ShaderBase::setUInt | ( | const std::string & | name, |
| const uint32_t | value | ||
| ) |
Send an unsigned int uniform to the shader.
| name | Uniform name in shader |
| value | Uniform value to send |
| void oe::render::ShaderBase::setUIntArray | ( | const std::string & | name, |
| const std::vector< uint32_t > & | values | ||
| ) |
Send a array of unsigned int uniforms to the shader.
| name | Uniform name in shader |
| values | Uniform values to send |
| void oe::render::ShaderBase::setVec2 | ( | const std::string & | name, |
| const glm::vec2 & | value | ||
| ) |
Send a vec2 uniform to the shader.
| name | Uniform name in shader |
| value | Uniform value to send |
| void oe::render::ShaderBase::setVec2Array | ( | const std::string & | name, |
| const std::vector< glm::vec2 > & | values | ||
| ) |
Send an array of vec2 uniforms to the shader.
| name | Uniform name in shader |
| values | Uniform values to send |
| void oe::render::ShaderBase::setVec2i | ( | const std::string & | name, |
| const glm::ivec2 & | value | ||
| ) |
Send an ivec2 uniform to the shader.
| name | Uniform name in shader |
| value | Uniform value to send |
| void oe::render::ShaderBase::setVec2iArray | ( | const std::string & | name, |
| const std::vector< glm::ivec2 > & | values | ||
| ) |
Send an array of ivec2 uniforms to the shader.
| name | Uniform name in shader |
| values | Uniform values to send |
| void oe::render::ShaderBase::setVec3 | ( | const std::string & | name, |
| const glm::vec3 & | value | ||
| ) |
Send a vec3 uniform to the shader.
| name | Uniform name in shader |
| value | Uniform value to send |
| void oe::render::ShaderBase::setVec3Array | ( | const std::string & | name, |
| const std::vector< glm::vec3 > & | values | ||
| ) |
Send an array of vec3 uniforms to the shader.
| name | Uniform name in shader |
| values | Uniform values to send |
| void oe::render::ShaderBase::setVec4 | ( | const std::string & | name, |
| const glm::vec4 & | value | ||
| ) |
Send a vec4 uniform to the shader.
| name | Uniform name in shader |
| value | Uniform value to send |
| void oe::render::ShaderBase::setVec4Array | ( | const std::string & | name, |
| const std::vector< glm::vec4 > & | values | ||
| ) |
Send an array of vec4 uniforms to the shader.
| name | Uniform name in shader |
| values | Uniform values to send |