X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Fmaterials%2Fmaterial.h;h=3210c96612fcfc2739d7fb99134f086c0c3761f9;hb=5593d59bfe30fd7eecc55bc3580d87fcb91f0248;hp=98baaa54ff2faf41b7975427dc4412306ac2e906;hpb=38712d8ecc57d043a2419ffbaeeb57f7a6586f14;p=libs%2Fgl.git diff --git a/source/materials/material.h b/source/materials/material.h index 98baaa54..3210c966 100644 --- a/source/materials/material.h +++ b/source/materials/material.h @@ -13,6 +13,9 @@ namespace GL { class Sampler; +/** +Base class for materials. Subclasses provide different shading models. +*/ class Material { private: @@ -24,6 +27,8 @@ private: virtual void init_actions(); private: + void alpha_cutoff(float); + void alpha_cutoff_feather(float, float); void sampler(const std::string &); }; @@ -69,24 +74,37 @@ public: protected: const Sampler *sampler = 0; + float alpha_cutoff = 0.0f; + float alpha_feather = 1.0f; ProgramData shdata; - Material() = default; + Material(); public: virtual ~Material() = default; + /** Returns a shader appropriate for this material. The same shader is + returned for materials with the same set of features. Additional + specialization values can be passed in to customize the shader. */ virtual const Program *create_compatible_shader(const std::map & = std::map()) const; protected: virtual void fill_program_info(std::string &, std::map &) const = 0; public: - /** Returns the uniforms for the material. */ + /** Returns the uniform values for the material. */ const ProgramData &get_shader_data() const { return shdata; } + /** Returns texture tags used by the material. The returned array is + terminated by an empty tag. */ virtual const Tag *get_texture_tags() const = 0; + virtual const Texture *get_texture(Tag) const = 0; virtual const Sampler *get_sampler(Tag) const { return sampler; } + void set_alpha_cutoff(float); + void set_alpha_feather(float); + float get_alpha_cutoff() const { return alpha_cutoff; } + float get_alpha_feather() const { return alpha_feather; } + void set_debug_name(const std::string &); template