diff options
author | Juan Linietsky <reduzio@gmail.com> | 2019-07-21 11:31:30 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2020-02-11 11:53:29 +0100 |
commit | 8bbbb973361f367a4888629c571fb6f43581269d (patch) | |
tree | 89724be2ee4a81111bedd383668665e0ae3bf276 /servers/visual/shader_language.h | |
parent | 50e9befb888480a3d6cb2fa46b58c0753b69bd86 (diff) |
Completed material/2D shader support (missing SCREEN_TEXTURE)
Diffstat (limited to 'servers/visual/shader_language.h')
-rw-r--r-- | servers/visual/shader_language.h | 43 |
1 files changed, 42 insertions, 1 deletions
diff --git a/servers/visual/shader_language.h b/servers/visual/shader_language.h index f7b02ab70b..3a1ded0547 100644 --- a/servers/visual/shader_language.h +++ b/servers/visual/shader_language.h @@ -155,6 +155,14 @@ public: TK_HINT_BLACK_ALBEDO_TEXTURE, TK_HINT_COLOR, TK_HINT_RANGE, + TK_FILTER_NEAREST, + TK_FILTER_LINEAR, + TK_FILTER_NEAREST_MIPMAP, + TK_FILTER_LINEAR_MIPMAP, + TK_FILTER_NEAREST_MIPMAP_ANISO, + TK_FILTER_LINEAR_MIPMAP_ANISO, + TK_REPEAT_ENABLE, + TK_REPEAT_DISABLE, TK_SHADER_TYPE, TK_CURSOR, TK_ERROR, @@ -284,6 +292,22 @@ public: TAG_ARRAY, }; + enum TextureFilter { + FILTER_NEAREST, + FILTER_LINEAR, + FILTER_NEAREST_MIPMAP, + FILTER_LINEAR_MIPMAP, + FILTER_NEAREST_MIPMAP_ANISO, + FILTER_LINEAR_MIPMAP_ANISO, + FILTER_DEFAULT, + }; + + enum TextureRepeat { + REPEAT_DISABLE, + REPEAT_ENABLE, + REPEAT_DEFAULT, + }; + struct Node { Node *next; @@ -485,11 +509,20 @@ public: }; struct FunctionNode : public Node { + struct Argument { ArgumentQualifier qualifier; StringName name; DataType type; DataPrecision precision; + //for passing textures as arguments + bool tex_argument_check; + TextureFilter tex_argument_filter; + TextureRepeat tex_argument_repeat; + bool tex_builtin_check; + StringName tex_builtin; + + Map<StringName, Set<int> > tex_argument_connect; }; StringName name; @@ -555,6 +588,8 @@ public: DataPrecision precision; Vector<ConstantNode::Value> default_value; Hint hint; + TextureFilter filter; + TextureRepeat repeat; float hint_range[3]; Uniform() : @@ -562,7 +597,9 @@ public: texture_order(0), type(TYPE_VOID), precision(PRECISION_DEFAULT), - hint(HINT_NONE) { + hint(HINT_NONE), + filter(FILTER_DEFAULT), + repeat(REPEAT_DEFAULT) { hint_range[0] = 0.0f; hint_range[1] = 1.0f; hint_range[2] = 0.001f; @@ -631,6 +668,8 @@ public: static bool is_scalar_type(DataType p_type); static bool is_sampler_type(DataType p_type); static Variant constant_value_to_variant(const Vector<ShaderLanguage::ConstantNode::Value> &p_value, DataType p_type, ShaderLanguage::ShaderNode::Uniform::Hint p_hint = ShaderLanguage::ShaderNode::Uniform::HINT_NONE); + static PropertyInfo uniform_to_property_info(const ShaderNode::Uniform &p_uniform); + static uint32_t get_type_size(DataType p_type); static void get_keyword_list(List<String> *r_keywords); static void get_builtin_funcs(List<String> *r_keywords); @@ -750,6 +789,8 @@ private: bool _validate_function_call(BlockNode *p_block, OperatorNode *p_func, DataType *r_ret_type); bool _parse_function_arguments(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types, OperatorNode *p_func, int *r_complete_arg = NULL); + bool _propagate_function_call_sampler_uniform_settings(StringName p_name, int p_argument, TextureFilter p_filter, TextureRepeat p_repeat); + bool _propagate_function_call_sampler_builtin_reference(StringName p_name, int p_argument, const StringName &p_builtin); Node *_parse_expression(BlockNode *p_block, const Map<StringName, BuiltInInfo> &p_builtin_types); ShaderLanguage::Node *_reduce_expression(BlockNode *p_block, ShaderLanguage::Node *p_node); |