diff options
author | Yuri Roubinsky <chaosus89@gmail.com> | 2020-03-19 17:58:39 +0300 |
---|---|---|
committer | Yuri Roubinsky <chaosus89@gmail.com> | 2020-03-19 17:58:39 +0300 |
commit | dbffa2e0bb0969ebc9416cc813cd8f73ce7cce57 (patch) | |
tree | 2219c35e49cdfa871b45e99dcabf975abba72c71 /servers | |
parent | af0b7f90bcdf1fca334932be2888d30aaef7bb75 (diff) |
Makes shader 'TIME' available in custom functions by default
Diffstat (limited to 'servers')
-rw-r--r-- | servers/visual/shader_language.cpp | 6 | ||||
-rw-r--r-- | servers/visual/shader_types.cpp | 5 |
2 files changed, 11 insertions, 0 deletions
diff --git a/servers/visual/shader_language.cpp b/servers/visual/shader_language.cpp index e73f8b8fc4..713b54e1ba 100644 --- a/servers/visual/shader_language.cpp +++ b/servers/visual/shader_language.cpp @@ -6284,6 +6284,12 @@ Error ShaderLanguage::_parse_shader(const Map<StringName, FunctionInfo> &p_funct builtin_types = p_functions[name].built_ins; } + if (p_functions.has("global")) { // Adds global variables: 'TIME' + for (Map<StringName, BuiltInInfo>::Element *E = p_functions["global"].built_ins.front(); E; E = E->next()) { + builtin_types.insert(E->key(), E->value()); + } + } + ShaderNode::Function function; function.callable = !p_functions.has(name); diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index 5cd5f0b7bb..dd798f2d54 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -56,6 +56,8 @@ ShaderTypes::ShaderTypes() { /*************** SPATIAL ***********************/ + shader_modes[VS::SHADER_SPATIAL].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["NORMAL"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_SPATIAL].functions["vertex"].built_ins["TANGENT"] = ShaderLanguage::TYPE_VEC3; @@ -200,6 +202,8 @@ ShaderTypes::ShaderTypes() { /************ CANVAS ITEM **************************/ + shader_modes[VS::SHADER_CANVAS_ITEM].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); + shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["VERTEX"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["UV"] = ShaderLanguage::TYPE_VEC2; shader_modes[VS::SHADER_CANVAS_ITEM].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; @@ -267,6 +271,7 @@ ShaderTypes::ShaderTypes() { /************ PARTICLES **************************/ + shader_modes[VS::SHADER_PARTICLES].functions["global"].built_ins["TIME"] = constt(ShaderLanguage::TYPE_FLOAT); shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["COLOR"] = ShaderLanguage::TYPE_VEC4; shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["VELOCITY"] = ShaderLanguage::TYPE_VEC3; shader_modes[VS::SHADER_PARTICLES].functions["vertex"].built_ins["MASS"] = ShaderLanguage::TYPE_FLOAT; |