mirror of
https://github.com/godotengine/godot.git
synced 2025-10-20 00:13:30 +00:00
Implement global and per instance shader uniforms.
Adds two keywords to shader language for uniforms: -'global' -'instance' This allows them to reference values outside the material.
This commit is contained in:
parent
30ab5c9baa
commit
0e1c66d9fc
49 changed files with 3124 additions and 69 deletions
|
@ -2261,6 +2261,12 @@ void VisualShaderEditor::_show_preview_text() {
|
|||
}
|
||||
}
|
||||
|
||||
static ShaderLanguage::DataType _get_global_variable_type(const StringName &p_variable) {
|
||||
|
||||
RS::GlobalVariableType gvt = RS::get_singleton()->global_variable_get_type(p_variable);
|
||||
return RS::global_variable_type_get_shader_datatype(gvt);
|
||||
}
|
||||
|
||||
void VisualShaderEditor::_update_preview() {
|
||||
|
||||
if (!preview_showed) {
|
||||
|
@ -2274,7 +2280,7 @@ void VisualShaderEditor::_update_preview() {
|
|||
|
||||
ShaderLanguage sl;
|
||||
|
||||
Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types());
|
||||
Error err = sl.compile(code, ShaderTypes::get_singleton()->get_functions(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_modes(RenderingServer::ShaderMode(visual_shader->get_mode())), ShaderTypes::get_singleton()->get_types(), _get_global_variable_type);
|
||||
|
||||
for (int i = 0; i < preview_text->get_line_count(); i++) {
|
||||
preview_text->set_line_as_marked(i, false);
|
||||
|
@ -3291,7 +3297,7 @@ void EditorInspectorShaderModePlugin::parse_begin(Object *p_object) {
|
|||
//do none
|
||||
}
|
||||
|
||||
bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage) {
|
||||
bool EditorInspectorShaderModePlugin::parse_property(Object *p_object, Variant::Type p_type, const String &p_path, PropertyHint p_hint, const String &p_hint_text, int p_usage, bool p_wide) {
|
||||
|
||||
if (p_path == "mode" && p_object->is_class("VisualShader") && p_type == Variant::INT) {
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue