import msp_interface;
import common;
-uniform sampler2D texture;
-uniform vec4 tint;
+struct UnlitMaterialParameters
+{
+ vec4 color;
+};
+
+uniform UnlitMaterial
+{
+ UnlitMaterialParameters unlit_material;
+};
+
+uniform sampler2D color_tex;
layout(constant_id=auto) const bool use_texture = false;
layout(constant_id=auto) const bool use_vertex_color = false;
layout(constant_id=auto) const bool use_fog = false;
#pragma MSP stage(fragment)
-vec4 get_color()
+virtual vec4 get_color()
{
- vec4 result = tint;
+ vec4 result = unlit_material.color;
if(use_texture)
- result *= texture(texture, texcoord.xy);
+ result *= texture(color_tex, texcoord.xy);
if(use_vertex_color)
result *= color;
return result;
texture(0),
vertex_color(false)
{
- set_tint(Color(1.0f));
+ set_color(Color(1.0f));
}
void UnlitMaterial::fill_program_info(string &module_name, map<string, int> &spec_values) const
void UnlitMaterial::attach_textures_to(Texturing &texturing, ProgramData &tex_shdata) const
{
- attach_texture_to(texture, texturing, tex_shdata, "texture");
+ attach_texture_to(texture, texturing, tex_shdata, "color_tex");
}
void UnlitMaterial::set_texture(const Texture *tex)
texture = tex;
}
-void UnlitMaterial::set_tint(const Color &t)
+void UnlitMaterial::set_color(const Color &c)
{
- tint = t;
- shdata.uniform("tint", tint);
+ color = c;
+ shdata.uniform("unlit_material.color", color);
}
void UnlitMaterial::set_vertex_color(bool vc)
{
Material::PropertyLoader<UnlitMaterial>::init_actions();
add("texture", &Loader::property_texture, &UnlitMaterial::set_texture);
- add_property("tint", &UnlitMaterial::set_tint, 0, true);
+ add_property("color", &UnlitMaterial::set_color, 0, true);
add("vertex_color", &UnlitMaterial::vertex_color);
}
private:
const Texture *texture;
- Color tint;
+ Color color;
bool vertex_color;
public:
virtual void attach_textures_to(Texturing &, ProgramData &) const;
void set_texture(const Texture *);
- void set_tint(const Color &);
+ void set_color(const Color &);
void set_vertex_color(bool);
};