diff options
Diffstat (limited to 'scene/resources/shader.h')
-rw-r--r-- | scene/resources/shader.h | 44 |
1 files changed, 40 insertions, 4 deletions
diff --git a/scene/resources/shader.h b/scene/resources/shader.h index fff6f1d28a..4a380d455b 100644 --- a/scene/resources/shader.h +++ b/scene/resources/shader.h @@ -31,7 +31,7 @@ #include "resource.h" #include "io/resource_loader.h" - +#include "scene/resources/texture.h" class Shader : public Resource { OBJ_TYPE(Shader,Resource); @@ -48,6 +48,9 @@ class Shader : public Resource { // convertion fast and save memory. mutable bool params_cache_dirty; mutable Map<StringName,StringName> params_cache; //map a shader param to a material param.. + Map<StringName,Ref<Texture> > default_textures; + + protected: @@ -58,10 +61,11 @@ public: MODE_MATERIAL, MODE_CANVAS_ITEM, - MODE_POST_PROCESS + MODE_POST_PROCESS, + MODE_MAX }; - void set_mode(Mode p_mode); + //void set_mode(Mode p_mode); Mode get_mode() const; void set_code( const String& p_vertex, const String& p_fragment, const String& p_light,int p_fragment_ofs=0,int p_light_ofs=0); @@ -72,15 +76,47 @@ public: void get_param_list(List<PropertyInfo> *p_params) const; bool has_param(const StringName& p_param) const; + void set_default_texture_param(const StringName& p_param, const Ref<Texture> &p_texture); + Ref<Texture> get_default_texture_param(const StringName& p_param) const; + void get_default_texture_param_list(List<StringName>* r_textures) const; + + _FORCE_INLINE_ StringName remap_param(const StringName& p_param) const { + if (params_cache_dirty) + get_param_list(NULL); + + const Map<StringName,StringName>::Element *E=params_cache.find(p_param); + if (E) + return E->get(); + return StringName(); + } + virtual RID get_rid() const; - Shader(); + Shader(Mode p_mode); ~Shader(); }; VARIANT_ENUM_CAST( Shader::Mode ); +class MaterialShader : public Shader { + + OBJ_TYPE(MaterialShader,Shader); + +public: + + MaterialShader() : Shader(MODE_MATERIAL) {}; +}; + +class CanvasItemShader : public Shader { + + OBJ_TYPE(CanvasItemShader,Shader); + +public: + + CanvasItemShader() : Shader(MODE_CANVAS_ITEM) {}; +}; + class ResourceFormatLoaderShader : public ResourceFormatLoader { |