Its only property are now stored in a struct to match other material
types. This allows using the name "color" without conflicting with the
vertex attribute. The texture uniform was also renamed in order to
avoid clashing with the texture() function.
import msp_interface;
import common;
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)
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)
+virtual vec4 get_color()
+ vec4 result = unlit_material.color;
- result *= texture(texture, texcoord.xy);
+ result *= texture(color_tex, texcoord.xy);
if(use_vertex_color)
result *= color;
return result;
if(use_vertex_color)
result *= color;
return result;
texture(0),
vertex_color(false)
{
texture(0),
vertex_color(false)
{
+ set_color(Color(1.0f));
}
void UnlitMaterial::fill_program_info(string &module_name, map<string, int> &spec_values) const
}
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
{
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)
}
void UnlitMaterial::set_texture(const 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)
}
void UnlitMaterial::set_vertex_color(bool vc)
{
Material::PropertyLoader<UnlitMaterial>::init_actions();
add("texture", &Loader::property_texture, &UnlitMaterial::set_texture);
{
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);
}
add("vertex_color", &UnlitMaterial::vertex_color);
}
private:
const Texture *texture;
private:
const Texture *texture;
bool vertex_color;
public:
bool vertex_color;
public:
virtual void attach_textures_to(Texturing &, ProgramData &) const;
void set_texture(const Texture *);
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);
};
void set_vertex_color(bool);
};