X-Git-Url: http://git.tdb.fi/?p=libs%2Fgl.git;a=blobdiff_plain;f=source%2Fmaterials%2Frendermethod.h;h=9d9ae6725437161355c605250bb00128d95c26f9;hp=bf35aac57db1177e0a06ee229fe22a3197f64cf2;hb=HEAD;hpb=ae45c0397e2cb8f0a01f2f31d01c95ff3870271e diff --git a/source/materials/rendermethod.h b/source/materials/rendermethod.h index bf35aac5..8fd289fe 100644 --- a/source/materials/rendermethod.h +++ b/source/materials/rendermethod.h @@ -3,6 +3,7 @@ #include #include +#include "blend.h" #include "cullface.h" #include "material.h" @@ -16,8 +17,11 @@ class Sampler; class Texture; /** -Encapsulates the data that determines the appearance of a rendered surface. -This includes shader and data for it, material and texturing. +Describes the appearance of a surface with a shader, uniform values and +textures. + +A Material can be used to automatically populate most of the fields of a +RenderMethod. */ class RenderMethod { @@ -40,6 +44,8 @@ public: private: virtual void finish(); + void blend(); + void blend_factors(BlendFactor, BlendFactor); void material_inline(); void material(const std::string &); void shader(const std::string &); @@ -72,41 +78,61 @@ private: TextureSlot(Tag t): tag(t), texture(0), sampler(0) { } }; - const Program *shprog; - bool shprog_from_material; + const Program *shprog = 0; + bool shprog_from_material = false; RefPtr shdata; std::map uniform_slots; - const Material *material; + const Material *material = 0; std::string material_slot; std::vector textures; - CullMode face_cull; - bool receive_shadows; - bool image_based_lighting; - -public: - RenderMethod(); + CullMode face_cull = NO_CULL; + Blend blend; + bool receive_shadows = false; + bool image_based_lighting = false; + bool instancing = false; -private: void maybe_create_material_shader(); void set_material_textures(); public: + /** Sets the shader program and uniform values. */ void set_shader_program(const Program *, const ProgramData *); + const Program *get_shader_program() const { return shprog; } const ProgramData *get_shader_data() const { return shdata.get(); } Tag get_slotted_uniform_tag(Tag) const; + + /** Sets a Material to use as a basis for the render method. If a shader + has not been explicitly set, the material's shader will be used. */ void set_material(const Material *); + const Material *get_material() const { return material; } const std::string &get_material_slot_name() const { return material_slot; } void set_texture(Tag, const Texture *, const Sampler * = 0); Tag get_texture_tag(const std::string &) const; void set_face_cull(CullMode); CullMode get_face_cull() const { return face_cull; } + void set_blend(const Blend &); + const Blend &get_blend() const { return blend; } + + /** Toggles shadows on objects using this render method. Only affects + shaders created from materials. A ShadowMap effect is required. */ void set_receive_shadows(bool); + bool get_receive_shadows() const { return receive_shadows; } + + /** Toggles the use of an environment map as a light source. Only affects + shaders created from materials. An EnvironmentMap effect is required. */ void set_image_based_lighting(bool); + bool get_image_based_lighting() const { return image_based_lighting; } + /** Toggles instanced rendering. Only affects shaders created from + materials. Should be used with InstanceArray. */ + void set_instancing(bool); + + bool get_instancing() const { return instancing; } + void apply(Renderer &) const; void set_debug_name(const std::string &);