You've already forked godot
mirror of
https://github.com/godotengine/godot.git
synced 2025-11-04 12:00:25 +00:00
Fix shader type detection
This commit is contained in:
@@ -66,20 +66,6 @@ void Shader::set_code(const String &p_code) {
|
|||||||
E->disconnect(SNAME("changed"), callable_mp(this, &Shader::_dependency_changed));
|
E->disconnect(SNAME("changed"), callable_mp(this, &Shader::_dependency_changed));
|
||||||
}
|
}
|
||||||
|
|
||||||
String type = ShaderLanguage::get_shader_type(p_code);
|
|
||||||
|
|
||||||
if (type == "canvas_item") {
|
|
||||||
mode = MODE_CANVAS_ITEM;
|
|
||||||
} else if (type == "particles") {
|
|
||||||
mode = MODE_PARTICLES;
|
|
||||||
} else if (type == "sky") {
|
|
||||||
mode = MODE_SKY;
|
|
||||||
} else if (type == "fog") {
|
|
||||||
mode = MODE_FOG;
|
|
||||||
} else {
|
|
||||||
mode = MODE_SPATIAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
code = p_code;
|
code = p_code;
|
||||||
String pp_code = p_code;
|
String pp_code = p_code;
|
||||||
|
|
||||||
@@ -100,6 +86,21 @@ void Shader::set_code(const String &p_code) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Try to get the shader type from the final, fully preprocessed shader code.
|
||||||
|
String type = ShaderLanguage::get_shader_type(pp_code);
|
||||||
|
|
||||||
|
if (type == "canvas_item") {
|
||||||
|
mode = MODE_CANVAS_ITEM;
|
||||||
|
} else if (type == "particles") {
|
||||||
|
mode = MODE_PARTICLES;
|
||||||
|
} else if (type == "sky") {
|
||||||
|
mode = MODE_SKY;
|
||||||
|
} else if (type == "fog") {
|
||||||
|
mode = MODE_FOG;
|
||||||
|
} else {
|
||||||
|
mode = MODE_SPATIAL;
|
||||||
|
}
|
||||||
|
|
||||||
for (const Ref<ShaderInclude> &E : include_dependencies) {
|
for (const Ref<ShaderInclude> &E : include_dependencies) {
|
||||||
E->connect(SNAME("changed"), callable_mp(this, &Shader::_dependency_changed));
|
E->connect(SNAME("changed"), callable_mp(this, &Shader::_dependency_changed));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user