3#include <Engine/RaEngine.hpp>
7#include <nlohmann/json.hpp>
10#include <Core/Utils/Color.hpp>
11#include <Core/Utils/EnumConverter.hpp>
12#include <Core/Utils/Log.hpp>
13#include <Core/Utils/StdOptional.hpp>
15#include <Core/Containers/VariableSet.hpp>
17#include <Engine/Data/ShaderProgram.hpp>
77 using VariableSet::setVariable;
81 VariableSet::setVariable( name,
std::ref( rp ) );
84 VariableSet::setVariable( name,
std::cref( rp ) );
93 visit( StaticParameterBinder {}, shader );
101 class StaticParameterBinder
105 using types = BindableTypes;
112 shader->
setUniform( name.
c_str(), Ra::Core::Utils::Color::VectorType( p ) );
118 const RenderParameters::TextureInfo& p,
120 auto [tex, texUnit] = p;
129 template <
typename T>
132 const Data::ShaderProgram* shader ) {
133 p.
get().bind( shader );
138 template <
typename T>
139 void operator()(
const std::string& name,
const T& p,
const Data::ShaderProgram* shader ) {
140 shader->setUniform( name.
c_str(), p );
160 static void loadMetaData(
const std::string& basename, nlohmann::json& destination );
175 virtual const RenderParameters& getParameters()
const {
return m_renderParameters; }
Heterogeneous container storing "Variables", that maps a name (std::string) to a value (of any type T...
Interface to define metadata (constraints, description, ...) for the editing of parameter set.
virtual nlohmann::json getParametersMetadata() const =0
Get a json containing metadata about the parameters.
Management of shader parameters with automatic binding of a named parameter to the corresponding glsl...
void setVariable(const std::string &name, RenderParameters &rp)
overload create ref wrapper for RenderParameters variable
void bind(const Data::ShaderProgram *shader) const
Bind the parameter uniform on the shader program.
void setTexture(const std::string &name, T *tex, int texUnit=-1)
Adding a texture parameter.
Core::Utils::TypeList< bool, Core::Utils::Color, int, uint, Scalar, TextureInfo, std::vector< int >, std::vector< uint >, std::vector< Scalar >, Core::Vector2, Core::Vector3, Core::Vector4, Core::Matrix2, Core::Matrix3, Core::Matrix4, std::reference_wrapper< RenderParameters >, std::reference_wrapper< const RenderParameters > > BindableTypes
List of bindable types, to be used with static visitors.
Shader program parameter provider.
virtual void updateFromParameters()
Update the attributes of the ShaderParameterProvider to their actual values stored in the renderParam...
virtual void updateGL()=0
Update the OpenGL states used by the ShaderParameterProvider.
virtual std::list< std::string > getPropertyList() const
Get the list of properties the provider might use in a shader.
void setUniform(const char *name, const T &value) const
Uniform setters.
void setUniformTexture(const char *name, Texture *tex) const
hepler function to manage enum as underlying types in VariableSet