]> git.tdb.fi Git - libs/gl.git/blobdiff - source/materials/material.h
Implement alpha cutoff for materials
[libs/gl.git] / source / materials / material.h
index 98baaa54ff2faf41b7975427dc4412306ac2e906..75ff972cd4e1312de7e6d63a74480bf3c3b0409a 100644 (file)
@@ -13,6 +13,9 @@ namespace GL {
 
 class Sampler;
 
+/**
+Base class for materials.  Subclasses provide different shading models.
+*/
 class Material
 {
 private:
@@ -24,6 +27,7 @@ private:
                virtual void init_actions();
 
        private:
+               void alpha_cutoff(float);
                void sampler(const std::string &);
        };
 
@@ -69,24 +73,34 @@ public:
 
 protected:
        const Sampler *sampler = 0;
+       float alpha_cutoff = 0.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::string, int> & = std::map<std::string, int>()) const;
 protected:
        virtual void fill_program_info(std::string &, std::map<std::string, int> &) 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 a);
+       float get_alpha_cutoff() const { return alpha_cutoff; }
+
        void set_debug_name(const std::string &);
 
        template<typename T>