9#include <IMaterialRendererServices.h>
29 const std::string &filename);
34 video::E_MATERIAL_TYPE
material = video::EMT_SOLID;
47 class IMaterialRendererServices;
67template <
typename T, std::
size_t count,
bool cache>
78 void set(
const T value[count], video::IMaterialRendererServices *services)
83 services->setPixelShaderConstant(services->getPixelShaderConstantID(
m_name), value, count);
85 services->setVertexShaderConstant(services->getVertexShaderConstantID(
m_name), value, count);
88 std::copy(value, value + count,
m_sent);
106#define SPECIALIZE(_type, _count_expr) \
107 template<typename T2 = T> \
108 std::enable_if_t<std::is_same_v<T, T2> && std::is_same_v<T2, _type> && (_count_expr)>
111 set(const
v2f value, video::IMaterialRendererServices *services)
113 float array[2] = { value.X, value.Y };
114 set(array, services);
118 set(const
v3f value, video::IMaterialRendererServices *services)
120 float array[3] = { value.X, value.Y, value.Z };
121 set(array, services);
125 set(const video::SColorf value, video::IMaterialRendererServices *services)
127 if constexpr (count == 3) {
128 float array[3] = { value.r, value.g, value.b };
129 set(array, services);
131 float array[4] = { value.r, value.g, value.b, value.a };
132 set(array, services);
137 set(const core::matrix4 &value, video::IMaterialRendererServices *services)
139 set(value.pointer(), services);
145template <
typename T, std::
size_t count = 1,
bool cache=true>
152template <
typename T, std::
size_t count = 1,
bool cache=true>
159template <
typename T, std::
size_t count,
bool cache,
bool is_pixel>
170 void set(
const T value[count], video::IMaterialRendererServices *services)
175 for (std::size_t i = 0; i < count; i++) {
176 std::string uniform_name = std::string(
m_name) +
"." +
m_fields[i];
179 services->setPixelShaderConstant(services->getPixelShaderConstantID(uniform_name.c_str()), value + i, 1);
181 services->setVertexShaderConstant(services->getVertexShaderConstantID(uniform_name.c_str()), value + i, 1);
185 std::copy(value, value + count,
m_sent);
191template<
typename T, std::
size_t count,
bool cache = true>
194template<
typename T, std::
size_t count,
bool cache = true>
220 const std::string &filename,
const std::string &program)=0;
230 const std::string &program_type, std::string_view program);
CachedPixelShaderSetting(const char *name)
Definition shader.h:148
bool is_pixel
Definition shader.h:72
CachedShaderSetting(const char *name, bool is_pixel)
Definition shader.h:74
T m_sent[count]
Definition shader.h:70
bool has_been_set
Definition shader.h:71
const char * m_name
Definition shader.h:69
void set(const T value[count], video::IMaterialRendererServices *services)
Definition shader.h:78
void set(const T value[count], video::IMaterialRendererServices *services)
Definition shader.h:170
T m_sent[count]
Definition shader.h:162
std::array< const char *, count > m_fields
Definition shader.h:164
bool has_been_set
Definition shader.h:163
CachedStructShaderSetting(const char *name, std::array< const char *, count > &&fields)
Definition shader.h:166
const char * m_name
Definition shader.h:161
CachedVertexShaderSetting(const char *name)
Definition shader.h:155
virtual ~IShaderConstantSetterFactory()=default
virtual IShaderConstantSetter * create()=0
virtual void onSetConstants(video::IMaterialRendererServices *services)=0
virtual void onSetMaterial(const video::SMaterial &material)
Definition shader.h:55
virtual ~IShaderConstantSetter()=default
virtual ShaderInfo getShaderInfo(u32 id)
Definition shader.h:208
virtual ~IShaderSource()=default
virtual u32 getShader(const std::string &name, MaterialType material_type, NodeDrawType drawtype=NDT_NORMAL)
Definition shader.h:209
virtual u32 getShaderIdDirect(const std::string &name, MaterialType material_type, NodeDrawType drawtype=NDT_NORMAL)
Definition shader.h:206
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:11
core::vector3df v3f
Definition irr_v3d.h:11
Definition clientmap.h:35
NodeDrawType
Definition nodedef.h:183
@ NDT_NORMAL
Definition nodedef.h:185
IWritableShaderSource * createShaderSource()
Definition shader.cpp:339
std::string getShaderPath(const std::string &name_of_shader, const std::string &filename)
Definition shader.cpp:45
#define SPECIALIZE(_type, _count_expr)
Definition shader.h:106
void dumpShaderProgram(std::ostream &output_stream, const std::string &program_type, std::string_view program)
Definition shader.cpp:769
std::string name
Definition shader.h:32
virtual ~ShaderInfo()=default
video::E_MATERIAL_TYPE base_material
Definition shader.h:33
MaterialType material_type
Definition shader.h:36
NodeDrawType drawtype
Definition shader.h:35
video::E_MATERIAL_TYPE material
Definition shader.h:34
MaterialType
Definition tile.h:12
@ TILE_MATERIAL_BASIC
Definition tile.h:13