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:
Juan Linietsky 2020-04-16 23:52:00 -03:00
parent 30ab5c9baa
commit 0e1c66d9fc
49 changed files with 3124 additions and 69 deletions

View file

@ -1481,6 +1481,15 @@ Error Main::setup2(Thread::ID p_main_tid_override) {
// We could add more, and make the CLI arg require a comma-separated list of profilers.
EngineDebugger::get_singleton()->profiler_enable("scripts", true);
}
if (!project_manager) {
// If not running the project manager, and now that the engine is
// able to load resources, load the global shader variables.
// If running on editor, dont load the textures because the editor
// may want to import them first. Editor will reload those later.
rendering_server->global_variables_load_settings(!editor);
}
_start_success = true;
locale = String();
@ -2280,6 +2289,9 @@ void Main::cleanup() {
// Sync pending commands that may have been queued from a different thread during ScriptServer finalization
RenderingServer::get_singleton()->sync();
//clear global shader variables before scene and other graphics stuff is deinitialized.
rendering_server->global_variables_clear();
#ifdef TOOLS_ENABLED
EditorNode::unregister_editor_types();
#endif