24#include <IMaterialRendererServices.h>
44 const std::string &filename);
49 video::E_MATERIAL_TYPE
material = video::EMT_SOLID;
62 class IMaterialRendererServices;
82template <
typename T, std::
size_t count,
bool cache>
93 void set(
const T value[count], video::IMaterialRendererServices *services)
98 services->setPixelShaderConstant(services->getPixelShaderConstantID(
m_name), value, count);
100 services->setVertexShaderConstant(services->getVertexShaderConstantID(
m_name), value, count);
103 std::copy(value, value + count,
m_sent);
121#define SPECIALIZE(_type, _count_expr) \
122 template<typename T2 = T> \
123 std::enable_if_t<std::is_same_v<T, T2> && std::is_same_v<T2, _type> && (_count_expr)>
126 set(const
v2f value, video::IMaterialRendererServices *services)
128 float array[2] = { value.X, value.Y };
129 set(array, services);
133 set(const
v3f value, video::IMaterialRendererServices *services)
135 float array[3] = { value.X, value.Y, value.Z };
136 set(array, services);
140 set(const video::SColorf value, video::IMaterialRendererServices *services)
142 if constexpr (count == 3) {
143 float array[3] = { value.r, value.g, value.b };
144 set(array, services);
146 float array[4] = { value.r, value.g, value.b, value.a };
147 set(array, services);
152 set(const core::matrix4 &value, video::IMaterialRendererServices *services)
154 set(value.pointer(), services);
160template <
typename T, std::
size_t count = 1,
bool cache=true>
167template <
typename T, std::
size_t count = 1,
bool cache=true>
174template <
typename T, std::
size_t count,
bool cache,
bool is_pixel>
185 void set(
const T value[count], video::IMaterialRendererServices *services)
190 for (std::size_t i = 0; i < count; i++) {
191 std::string uniform_name = std::string(
m_name) +
"." +
m_fields[i];
194 services->setPixelShaderConstant(services->getPixelShaderConstantID(uniform_name.c_str()), value + i, 1);
196 services->setVertexShaderConstant(services->getVertexShaderConstantID(uniform_name.c_str()), value + i, 1);
200 std::copy(value, value + count,
m_sent);
206template<
typename T, std::
size_t count,
bool cache = true>
209template<
typename T, std::
size_t count,
bool cache = true>
235 const std::string &filename,
const std::string &program)=0;
245 const std::string &program_type, std::string_view program);
CachedPixelShaderSetting(const char *name)
Definition shader.h:163
bool is_pixel
Definition shader.h:87
CachedShaderSetting(const char *name, bool is_pixel)
Definition shader.h:89
T m_sent[count]
Definition shader.h:85
bool has_been_set
Definition shader.h:86
const char * m_name
Definition shader.h:84
void set(const T value[count], video::IMaterialRendererServices *services)
Definition shader.h:93
void set(const T value[count], video::IMaterialRendererServices *services)
Definition shader.h:185
T m_sent[count]
Definition shader.h:177
std::array< const char *, count > m_fields
Definition shader.h:179
bool has_been_set
Definition shader.h:178
CachedStructShaderSetting(const char *name, std::array< const char *, count > &&fields)
Definition shader.h:181
const char * m_name
Definition shader.h:176
CachedVertexShaderSetting(const char *name)
Definition shader.h:170
virtual ~IShaderConstantSetterFactory()=default
virtual IShaderConstantSetter * create()=0
virtual void onSetConstants(video::IMaterialRendererServices *services)=0
virtual void onSetMaterial(const video::SMaterial &material)
Definition shader.h:70
virtual ~IShaderConstantSetter()=default
virtual ShaderInfo getShaderInfo(u32 id)
Definition shader.h:223
virtual ~IShaderSource()=default
virtual u32 getShader(const std::string &name, MaterialType material_type, NodeDrawType drawtype=NDT_NORMAL)
Definition shader.h:224
virtual u32 getShaderIdDirect(const std::string &name, MaterialType material_type, NodeDrawType drawtype=NDT_NORMAL)
Definition shader.h:221
virtual void rebuildShaders()=0
virtual ~IWritableShaderSource()=default
IWritableShaderSource()=default
virtual void insertSourceShader(const std::string &name_of_shader, const std::string &filename, const std::string &program)=0
virtual void processQueue()=0
virtual void addShaderConstantSetterFactory(IShaderConstantSetterFactory *setter)=0
core::vector2d< f32 > v2f
Definition irr_v2d.h:26
core::vector3df v3f
Definition irr_v3d.h:26
NodeDrawType
Definition nodedef.h:198
@ NDT_NORMAL
Definition nodedef.h:200
IWritableShaderSource * createShaderSource()
Definition shader.cpp:351
std::string getShaderPath(const std::string &name_of_shader, const std::string &filename)
Definition shader.cpp:60
#define SPECIALIZE(_type, _count_expr)
Definition shader.h:121
void dumpShaderProgram(std::ostream &output_stream, const std::string &program_type, std::string_view program)
Definition shader.cpp:758
std::string name
Definition shader.h:47
virtual ~ShaderInfo()=default
video::E_MATERIAL_TYPE base_material
Definition shader.h:48
MaterialType material_type
Definition shader.h:51
NodeDrawType drawtype
Definition shader.h:50
video::E_MATERIAL_TYPE material
Definition shader.h:49
MaterialType
Definition tile.h:27
@ TILE_MATERIAL_BASIC
Definition tile.h:28