diff options
-rw-r--r-- | AUTHORS.md | 29 | ||||
-rw-r--r-- | DONORS.md | 32 | ||||
-rw-r--r-- | drivers/gles3/shader_compiler_gles3.cpp | 1 | ||||
-rw-r--r-- | drivers/gles3/shaders/scene.glsl | 56 | ||||
-rw-r--r-- | editor/editor_node.cpp | 2 | ||||
-rw-r--r-- | editor/plugins/audio_stream_editor_plugin.cpp | 284 | ||||
-rw-r--r-- | editor/plugins/audio_stream_editor_plugin.h | 93 | ||||
-rw-r--r-- | scene/resources/material.cpp | 5 | ||||
-rw-r--r-- | scene/resources/material.h | 3 | ||||
-rw-r--r-- | servers/visual/shader_types.cpp | 1 |
10 files changed, 446 insertions, 60 deletions
diff --git a/AUTHORS.md b/AUTHORS.md index 12494a487d..d3f0592c89 100644 --- a/AUTHORS.md +++ b/AUTHORS.md @@ -40,14 +40,15 @@ name is available. Ben Brookshire (sheepandshepherd) Benjamin (Nallebeorn) Bernard Liebl (poke1024) - Bojidar Marinov (bojidar-bg) Błażej Szczygieł (zaps166) + Bojidar Marinov (bojidar-bg) + bruvzg Carl Olsson (not-surt) Dana Olson (adolson) Daniel J. Ramirez (djrm) Dmitry Koteroff (Krakean) - Дмитрий Сальников (DmitriySalnikov) Emmanuel Leblond (touilleMan) + est31 Fabio Alessandrelli (Faless) Ferenc Arn (tagcup) Franklin Sobrinho (TheHX) @@ -68,6 +69,7 @@ name is available. J08nY Jakub Grzesik (kubecz3k) Jérôme GULLY (Nutriz) + JFonS Johan Manuel (29jm) Joshua Grams (JoshuaGrams) Juan Linietsky (reduz) @@ -76,15 +78,18 @@ name is available. Kelly Thomas (KellyThomas) Kostadin Damyanov (Max-Might) Leon Krause (eska014) - Marc Gilleron (Zylann) + m4nu3lf Marcelo Fernandez (marcelofg55) + Marc Gilleron (Zylann) Mariano Javier Suligoy (MarianoGnu) Mario Schlack (hurikhan) Martin Sjursen (binbitten) + marynate Masoud BH (masoudbh3) Matthias Hölzl (hoelzl) Max Hilbrunner (mhilbrunner) Michael Alexsander Silva Dias (YeldhamDev) + mrezai Nathan Warden (NathanWarden) Nuno Donato (nunodonato) Ovnuniarchos @@ -102,28 +107,24 @@ name is available. Ray Koopa (RayKoopa) Rémi Verschelde (akien-mga) Roberto F. Arroyo (robfram) + romulox-x + rraallvv Ruslan Mustakov (endragor) Saniko (sanikoyes) SaracenOne + sersoong Theo Hallenius (TheoXD) Thomas Herzog (karroffel) Timo (toger5) - V. Vamsi Krishna (vkbsb) Vinzenz Feenstra (vinzenz) + 박한얼 (volzhs) + V. Vamsi Krishna (vkbsb) Wilhem Barbier (nounoursheureux) Will Nations (willnationsdev) Wilson E. Alvarez (Rubonnek) Xavier Cho (mysticfall) + yg2f (SuperUserNameMan) Yuri Roubinski (Chaosus) Zher Huei Lee (leezh) ZuBsPaCe - 박한얼 (volzhs) - bruvzg - est31 - m4nu3lf - marynate - mrezai - romulox-x - rraallvv - sersoong - yg2f (SuperUserNameMan) + Дмитрий Сальников (DmitriySalnikov) @@ -70,6 +70,7 @@ generous deed immortalized in the next stable release of Godot Engine. Johannes Wuensch Josep G. Camarasa Joshua Lesperance + Kyle Szklenski Libre-Dépanne Matthew Bennett Olafur Gislason @@ -87,21 +88,21 @@ generous deed immortalized in the next stable release of Godot Engine. David Churchill Dean Harmon Dexter Miguel - Guilherme Felipe de C. G. da Silva John Justo Delgado Baudí KTL Laurence Bannister + paul gruenbacher Rami Robert Willes Robin Arys + Rodrigo Loli Ronnie Ashlock Rufus Xavier Sarsaparilla ScottMakesGames Thomas Bjarnelöf William Connell Wojciech Chojnacki - Xavier Tan Zaq Poi Alessandra Pereyra @@ -113,13 +114,15 @@ generous deed immortalized in the next stable release of Godot Engine. Cody Parker Corey Auger D - Daniel Eliasinski E.G. + Eric Eric Monson flesk + floopf G Barnes GGGames.org Giovanni Solimeno + Guilherme Felipe de C. G. da Silva Hasen Judy Heath Hayes Jay Horton @@ -133,31 +136,32 @@ generous deed immortalized in the next stable release of Godot Engine. Markus Wiesner Marvin Mohammad Taleb + Neal Barry Nick Nikitin Pablo Cholaky Patrick Schnorbus Pete Goodwin Phyronnaz Ruben Soares Luis + Sindre Sømme Sofox Stoned Xander - Ted Tim Dalporto Trent McPheron - Vladimir ## Silver donors 1D_Inc Adam Carr Adam Smeltzer + Adisibio Alder Stefano Alessandro Senese - Álvaro Domínguez López Anders Jensen-Urstad Anthony Bongiovanni Arda Erol Arthur S. Muszynski + Artur Barichello Aubrey Falconer Avencherus Bailey @@ -168,6 +172,7 @@ generous deed immortalized in the next stable release of Godot Engine. Blair Allen Brandon Bryan Stevenson + Carl Winder Carwyn Edwards Casey Foote Chris Chapin @@ -175,7 +180,6 @@ generous deed immortalized in the next stable release of Godot Engine. Christian Winter Christopher Schmitt Collin Shooltz - Daniel Delgado Corona Daniel Johnson Daniel Kaplan DanielMaximiano @@ -186,6 +190,7 @@ generous deed immortalized in the next stable release of Godot Engine. Dominik Wetzel Duy Kevin Nguyen Edward Herbert + Edwin Acosta Eric Martini Fabian Becker fengjiongmax @@ -194,10 +199,10 @@ generous deed immortalized in the next stable release of Godot Engine. Gerrit Großkopf Gerrit Procee Gilberto K. Otubo + Guillaume Laforte Guldoman Gumichan01 Heribert Hirth - hubert jenkins Hunter Jones ialex32x Ivan Vodopiviz @@ -222,16 +227,15 @@ generous deed immortalized in the next stable release of Godot Engine. Kevin Kamper Meejach Petersen Klavdij Voncina Krzysztof Jankowski - Lars pfeffer Linus Lind Lundgren Luis Moraes Macil magodev Martin Eigel Martins Odabi - Matthew Fitzpatrick Max R.R. Collada Maxwell + Mertcan Mermerkaya mhilbrunner Michael Dürwald Michael Gringauz @@ -246,10 +250,8 @@ generous deed immortalized in the next stable release of Godot Engine. Niclas Eriksen Nicolas SAN AGUSTIN Niko Leopold - nivardus Noi Sek Oleg Tyshchenko - Oleksandr Yemets Pablo Seibelt Pan Ip Pat LaBine @@ -260,28 +262,28 @@ generous deed immortalized in the next stable release of Godot Engine. Pierre-Igor Berthet Pietro Vertechi Piotr Kaczmarski - Rea Rémi Verschelde Richman Stewart Roger Burgess Roger Smith Roman Tinkov Ryan Whited - Samuel El-Borai Sasori Olkof Sootstone Stefan Butucea Theo Cranmore Thibault Barbaroux Thomas Bell + Thomas Hermansen + Thomas Holmes Thomas Kurz - Tomasz Wacławek Tom Larrow Tyler Stafos UltyX Victor Victor Gonzalez Fernandez Viktor Ferenczi + waka nya werner mendizabal Wout Standaert Yu He diff --git a/drivers/gles3/shader_compiler_gles3.cpp b/drivers/gles3/shader_compiler_gles3.cpp index 9ad16ac2a2..3f6fe3ec61 100644 --- a/drivers/gles3/shader_compiler_gles3.cpp +++ b/drivers/gles3/shader_compiler_gles3.cpp @@ -913,6 +913,7 @@ ShaderCompilerGLES3::ShaderCompilerGLES3() { actions[VS::SHADER_SPATIAL].render_mode_defines["specular_toon"] = "#define SPECULAR_TOON\n"; actions[VS::SHADER_SPATIAL].render_mode_defines["specular_disabled"] = "#define SPECULAR_DISABLED\n"; actions[VS::SHADER_SPATIAL].render_mode_defines["shadows_disabled"] = "#define SHADOWS_DISABLED\n"; + actions[VS::SHADER_SPATIAL].render_mode_defines["ambient_light_disabled"] = "#define AMBIENT_LIGHT_DISABLED\n"; /* PARTICLES SHADER */ diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index ed8df04377..abb236138f 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -571,11 +571,6 @@ in vec3 normal_interp; /* PBR CHANNELS */ -//used on forward mainly -uniform bool no_ambient_light; - - - #ifdef USE_RADIANCE_MAP @@ -1752,42 +1747,43 @@ FRAGMENT_SHADER_CODE #ifdef USE_RADIANCE_MAP - if (no_ambient_light) { - ambient_light=vec3(0.0,0.0,0.0); - } else { - { - - { //read radiance from dual paraboloid +#ifdef AMBIENT_LIGHT_DISABLED + ambient_light=vec3(0.0,0.0,0.0); +#else + { - vec3 ref_vec = reflect(-eye_vec,normal); //2.0 * ndotv * normal - view; // reflect(v, n); - ref_vec=normalize((radiance_inverse_xform * vec4(ref_vec,0.0)).xyz); - vec3 radiance = textureDualParaboloid(radiance_map,ref_vec,roughness) * bg_energy; - env_reflection_light = radiance; + { //read radiance from dual paraboloid - } - //no longer a cubemap - //vec3 radiance = textureLod(radiance_cube, r, lod).xyz * ( brdf.x + brdf.y); + vec3 ref_vec = reflect(-eye_vec,normal); //2.0 * ndotv * normal - view; // reflect(v, n); + ref_vec=normalize((radiance_inverse_xform * vec4(ref_vec,0.0)).xyz); + vec3 radiance = textureDualParaboloid(radiance_map,ref_vec,roughness) * bg_energy; + env_reflection_light = radiance; } + //no longer a cubemap + //vec3 radiance = textureLod(radiance_cube, r, lod).xyz * ( brdf.x + brdf.y); + + } #ifndef USE_LIGHTMAP - { + { - vec3 ambient_dir=normalize((radiance_inverse_xform * vec4(normal,0.0)).xyz); - vec3 env_ambient=textureDualParaboloid(radiance_map,ambient_dir,1.0) * bg_energy; + vec3 ambient_dir=normalize((radiance_inverse_xform * vec4(normal,0.0)).xyz); + vec3 env_ambient=textureDualParaboloid(radiance_map,ambient_dir,1.0) * bg_energy; - ambient_light=mix(ambient_light_color.rgb,env_ambient,radiance_ambient_contribution); - //ambient_light=vec3(0.0,0.0,0.0); - } -#endif + ambient_light=mix(ambient_light_color.rgb,env_ambient,radiance_ambient_contribution); + //ambient_light=vec3(0.0,0.0,0.0); } +#endif +#endif //AMBIENT_LIGHT_DISABLED #else - if (no_ambient_light){ - ambient_light=vec3(0.0,0.0,0.0); - } else { - ambient_light=ambient_light_color.rgb; - } +#ifdef AMBIENT_LIGHT_DISABLED + ambient_light=vec3(0.0,0.0,0.0); +#else + ambient_light=ambient_light_color.rgb; +#endif //AMBIENT_LIGHT_DISABLED + #endif ambient_light*=ambient_energy; diff --git a/editor/editor_node.cpp b/editor/editor_node.cpp index cae9c34fe0..37f1626704 100644 --- a/editor/editor_node.cpp +++ b/editor/editor_node.cpp @@ -73,6 +73,7 @@ #include "editor/plugins/animation_state_machine_editor.h" #include "editor/plugins/animation_tree_editor_plugin.h" #include "editor/plugins/asset_library_editor_plugin.h" +#include "editor/plugins/audio_stream_editor_plugin.h" #include "editor/plugins/baked_lightmap_editor_plugin.h" #include "editor/plugins/camera_editor_plugin.h" #include "editor/plugins/canvas_item_editor_plugin.h" @@ -5445,6 +5446,7 @@ EditorNode::EditorNode() { add_editor_plugin(memnew(CollisionShape2DEditorPlugin(this))); add_editor_plugin(memnew(CurveEditorPlugin(this))); add_editor_plugin(memnew(TextureEditorPlugin(this))); + add_editor_plugin(memnew(AudioStreamEditorPlugin(this))); add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor))); add_editor_plugin(memnew(AudioBusesEditorPlugin(audio_bus_editor))); add_editor_plugin(memnew(SkeletonEditorPlugin(this))); diff --git a/editor/plugins/audio_stream_editor_plugin.cpp b/editor/plugins/audio_stream_editor_plugin.cpp new file mode 100644 index 0000000000..ddb03d0250 --- /dev/null +++ b/editor/plugins/audio_stream_editor_plugin.cpp @@ -0,0 +1,284 @@ +/*************************************************************************/ +/* audio_stream_editor_plugin.cpp */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#include "audio_stream_editor_plugin.h" + +#include "editor/editor_settings.h" +#include "io/resource_loader.h" +#include "project_settings.h" + +void AudioStreamEditor::_notification(int p_what) { + + if (p_what == NOTIFICATION_READY) { + AudioStreamPreviewGenerator::get_singleton()->connect("preview_updated", this, "_preview_changed"); + } + + if (p_what == NOTIFICATION_THEME_CHANGED || p_what == NOTIFICATION_ENTER_TREE) { + _play_button->set_icon(get_icon("MainPlay", "EditorIcons")); + _stop_button->set_icon(get_icon("Stop", "EditorIcons")); + _preview->set_frame_color(get_color("dark_color_2", "Editor")); + set_frame_color(get_color("dark_color_1", "Editor")); + + _indicator->update(); + _preview->update(); + } + + if (p_what == NOTIFICATION_PROCESS) { + _current = _player->get_playback_position(); + _indicator->update(); + _preview->update(); + } + + if (p_what == NOTIFICATION_VISIBILITY_CHANGED) { + if (!is_visible_in_tree()) { + _stop(); + } + } +} + +void AudioStreamEditor::_draw_preview() { + Rect2 rect = _preview->get_rect(); + Size2 size = get_size(); + + Ref<AudioStreamPreview> preview = AudioStreamPreviewGenerator::get_singleton()->generate_preview(stream); + float preview_len = preview->get_length(); + + Vector<Vector2> lines; + lines.resize(size.width * 2); + + for (int i = 0; i < size.width; i++) { + + float ofs = i * preview_len / size.width; + float ofs_n = (i + 1) * preview_len / size.width; + float max = preview->get_max(ofs, ofs_n) * 0.5 + 0.5; + float min = preview->get_min(ofs, ofs_n) * 0.5 + 0.5; + + int idx = i; + lines[idx * 2 + 0] = Vector2(i + 1, rect.position.y + min * rect.size.y); + lines[idx * 2 + 1] = Vector2(i + 1, rect.position.y + max * rect.size.y); + } + + Vector<Color> color; + color.push_back(get_color("contrast_color_2", "Editor")); + + VS::get_singleton()->canvas_item_add_multiline(_preview->get_canvas_item(), lines, color); +} + +void AudioStreamEditor::_preview_changed(ObjectID p_which) { + + if (stream.is_valid() && stream->get_instance_id() == p_which) { + _preview->update(); + } +} + +void AudioStreamEditor::_changed_callback(Object *p_changed, const char *p_prop) { + + if (!is_visible()) + return; + update(); +} + +void AudioStreamEditor::_play() { + + if (_player->is_playing()) { + _player->stop(); + _play_button->set_icon(get_icon("MainPlay", "EditorIcons")); + set_process(false); + } else { + _player->play(_current); + _play_button->set_icon(get_icon("Pause", "EditorIcons")); + set_process(true); + } +} + +void AudioStreamEditor::_stop() { + + _player->stop(); + _on_finished(); +} + +void AudioStreamEditor::_on_finished() { + + _play_button->set_icon(get_icon("MainPlay", "EditorIcons")); + _current = 0; + _indicator->update(); + set_process(false); +} + +void AudioStreamEditor::_draw_indicator() { + + if (!stream.is_valid()) { + return; + } + + Rect2 rect = _preview->get_rect(); + float len = stream->get_length(); + float ofs_x = _current / len * rect.size.width; + _indicator->draw_line(Point2(ofs_x, 0), Point2(ofs_x, rect.size.height), get_color("accent_color", "Editor"), 1); + + _current_label->set_text(String::num(_current, 2).pad_decimals(2) + " /"); +} + +void AudioStreamEditor::_on_input_indicator(Ref<InputEvent> p_event) { + Ref<InputEventMouseButton> mb = p_event; + + if (mb.is_valid()) { + if (mb->is_pressed()) { + _seek_to(mb->get_position().x); + } + _dragging = mb->is_pressed(); + } + + Ref<InputEventMouseMotion> mm = p_event; + + if (mm.is_valid()) { + if (_dragging) { + _seek_to(mm->get_position().x); + } + } +} + +void AudioStreamEditor::_seek_to(real_t p_x) { + _current = p_x / _preview->get_rect().size.x * stream->get_length(); + _current = CLAMP(_current, 0, stream->get_length()); + _player->seek(_current); + _indicator->update(); +} + +void AudioStreamEditor::edit(Ref<AudioStream> p_stream) { + + if (!stream.is_null()) + stream->remove_change_receptor(this); + + stream = p_stream; + _player->set_stream(stream); + _current = 0; + String text = String::num(stream->get_length(), 2).pad_decimals(2) + "s"; + _duration_label->set_text(text); + + if (!stream.is_null()) { + stream->add_change_receptor(this); + update(); + } else { + hide(); + } +} + +void AudioStreamEditor::_bind_methods() { + + ClassDB::bind_method(D_METHOD("_preview_changed"), &AudioStreamEditor::_preview_changed); + ClassDB::bind_method(D_METHOD("_play"), &AudioStreamEditor::_play); + ClassDB::bind_method(D_METHOD("_stop"), &AudioStreamEditor::_stop); + ClassDB::bind_method(D_METHOD("_on_finished"), &AudioStreamEditor::_on_finished); + ClassDB::bind_method(D_METHOD("_draw_preview"), &AudioStreamEditor::_draw_preview); + ClassDB::bind_method(D_METHOD("_draw_indicator"), &AudioStreamEditor::_draw_indicator); + ClassDB::bind_method(D_METHOD("_on_input_indicator"), &AudioStreamEditor::_on_input_indicator); +} + +AudioStreamEditor::AudioStreamEditor() { + + set_custom_minimum_size(Size2(1, 100)); + _current = 0; + _dragging = false; + + _player = memnew(AudioStreamPlayer); + _player->connect("finished", this, "_on_finished"); + add_child(_player); + + VBoxContainer *vbox = memnew(VBoxContainer); + vbox->set_anchors_and_margins_preset(PRESET_WIDE, PRESET_MODE_MINSIZE, 0); + add_child(vbox); + + _preview = memnew(ColorRect); + _preview->set_v_size_flags(SIZE_EXPAND_FILL); + _preview->connect("draw", this, "_draw_preview"); + vbox->add_child(_preview); + + _indicator = memnew(Control); + _indicator->set_anchors_and_margins_preset(PRESET_WIDE); + _indicator->connect("draw", this, "_draw_indicator"); + _indicator->connect("gui_input", this, "_on_input_indicator"); + _preview->add_child(_indicator); + + HBoxContainer *hbox = memnew(HBoxContainer); + hbox->add_constant_override("separation", 0); + vbox->add_child(hbox); + + _play_button = memnew(ToolButton); + hbox->add_child(_play_button); + _play_button->set_focus_mode(Control::FOCUS_NONE); + _play_button->connect("pressed", this, "_play"); + + _stop_button = memnew(ToolButton); + hbox->add_child(_stop_button); + _stop_button->set_focus_mode(Control::FOCUS_NONE); + _stop_button->connect("pressed", this, "_stop"); + + _current_label = memnew(Label); + _current_label->set_align(Label::ALIGN_RIGHT); + _current_label->set_h_size_flags(SIZE_EXPAND_FILL); + _current_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); + _current_label->set_modulate(Color(1, 1, 1, 0.5)); + hbox->add_child(_current_label); + + _duration_label = memnew(Label); + _duration_label->add_font_override("font", EditorNode::get_singleton()->get_gui_base()->get_font("status_source", "EditorFonts")); + hbox->add_child(_duration_label); +} + +void AudioStreamEditorPlugin::edit(Object *p_object) { + + AudioStream *s = Object::cast_to<AudioStream>(p_object); + if (!s) + return; + + audio_editor->edit(Ref<AudioStream>(s)); +} + +bool AudioStreamEditorPlugin::handles(Object *p_object) const { + + return p_object->is_class("AudioStream"); +} + +void AudioStreamEditorPlugin::make_visible(bool p_visible) { + + audio_editor->set_visible(p_visible); +} + +AudioStreamEditorPlugin::AudioStreamEditorPlugin(EditorNode *p_node) { + + editor = p_node; + audio_editor = memnew(AudioStreamEditor); + add_control_to_container(CONTAINER_PROPERTY_EDITOR_BOTTOM, audio_editor); + audio_editor->hide(); +} + +AudioStreamEditorPlugin::~AudioStreamEditorPlugin() { +} diff --git a/editor/plugins/audio_stream_editor_plugin.h b/editor/plugins/audio_stream_editor_plugin.h new file mode 100644 index 0000000000..1887874b74 --- /dev/null +++ b/editor/plugins/audio_stream_editor_plugin.h @@ -0,0 +1,93 @@ +/*************************************************************************/ +/* audio_stream_editor_plugin.h */ +/*************************************************************************/ +/* This file is part of: */ +/* GODOT ENGINE */ +/* https://godotengine.org */ +/*************************************************************************/ +/* Copyright (c) 2007-2018 Juan Linietsky, Ariel Manzur. */ +/* Copyright (c) 2014-2018 Godot Engine contributors (cf. AUTHORS.md) */ +/* */ +/* Permission is hereby granted, free of charge, to any person obtaining */ +/* a copy of this software and associated documentation files (the */ +/* "Software"), to deal in the Software without restriction, including */ +/* without limitation the rights to use, copy, modify, merge, publish, */ +/* distribute, sublicense, and/or sell copies of the Software, and to */ +/* permit persons to whom the Software is furnished to do so, subject to */ +/* the following conditions: */ +/* */ +/* The above copyright notice and this permission notice shall be */ +/* included in all copies or substantial portions of the Software. */ +/* */ +/* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, */ +/* EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF */ +/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.*/ +/* IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY */ +/* CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, */ +/* TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE */ +/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */ +/*************************************************************************/ + +#ifndef AUDIO_STREAM_EDITOR_PLUGIN_H +#define AUDIO_STREAM_EDITOR_PLUGIN_H + +#include "editor/editor_node.h" +#include "editor/editor_plugin.h" +#include "scene/audio/audio_player.h" +#include "scene/gui/color_rect.h" +#include "scene/resources/texture.h" + +class AudioStreamEditor : public ColorRect { + + GDCLASS(AudioStreamEditor, ColorRect); + + Ref<AudioStream> stream; + AudioStreamPlayer *_player; + ColorRect *_preview; + Control *_indicator; + Label *_current_label; + Label *_duration_label; + + ToolButton *_play_button; + ToolButton *_stop_button; + + float _current; + bool _dragging; + +protected: + void _notification(int p_what); + void _preview_changed(ObjectID p_which); + void _play(); + void _stop(); + void _on_finished(); + void _draw_preview(); + void _draw_indicator(); + void _on_input_indicator(Ref<InputEvent> p_event); + void _seek_to(real_t p_x); + void _changed_callback(Object *p_changed, const char *p_prop); + static void _bind_methods(); + +public: + void edit(Ref<AudioStream> p_stream); + AudioStreamEditor(); +}; + +class AudioStreamEditorPlugin : public EditorPlugin { + + GDCLASS(AudioStreamEditorPlugin, EditorPlugin); + + AudioStreamEditor *audio_editor; + EditorNode *editor; + +public: + virtual String get_name() const { return "Audio"; } + bool has_main_screen() const { return false; } + virtual void edit(Object *p_object); + virtual bool handles(Object *p_object) const; + virtual void make_visible(bool p_visible); + + AudioStreamEditorPlugin(EditorNode *p_node); + ~AudioStreamEditorPlugin(); +}; + +#endif // AUDIO_STREAM_EDITOR_PLUGIN_H diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 90e103c96b..56b3ee70bb 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -404,6 +404,9 @@ void SpatialMaterial::_update_shader() { if (flags[FLAG_DONT_RECEIVE_SHADOWS]) { code += ",shadows_disabled"; } + if (flags[FLAG_DISABLE_AMBIENT_LIGHT]) { + code += ",ambient_light_disabled"; + } if (flags[FLAG_ENSURE_CORRECT_NORMALS]) { code += ",ensure_correct_normals"; } @@ -1866,6 +1869,7 @@ void SpatialMaterial::_bind_methods() { ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_fixed_size"), "set_flag", "get_flag", FLAG_FIXED_SIZE); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_albedo_tex_force_srgb"), "set_flag", "get_flag", FLAG_ALBEDO_TEXTURE_FORCE_SRGB); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_do_not_receive_shadows"), "set_flag", "get_flag", FLAG_DONT_RECEIVE_SHADOWS); + ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_disable_ambient_light"), "set_flag", "get_flag", FLAG_DISABLE_AMBIENT_LIGHT); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flags_ensure_correct_normals"), "set_flag", "get_flag", FLAG_ENSURE_CORRECT_NORMALS); ADD_GROUP("Vertex Color", "vertex_color"); ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "vertex_color_use_as_albedo"), "set_flag", "get_flag", FLAG_ALBEDO_FROM_VERTEX_COLOR); @@ -2057,6 +2061,7 @@ void SpatialMaterial::_bind_methods() { BIND_ENUM_CONSTANT(FLAG_TRIPLANAR_USE_WORLD); BIND_ENUM_CONSTANT(FLAG_ALBEDO_TEXTURE_FORCE_SRGB); BIND_ENUM_CONSTANT(FLAG_DONT_RECEIVE_SHADOWS); + BIND_ENUM_CONSTANT(FLAG_DISABLE_AMBIENT_LIGHT); BIND_ENUM_CONSTANT(FLAG_ENSURE_CORRECT_NORMALS); BIND_ENUM_CONSTANT(FLAG_MAX); diff --git a/scene/resources/material.h b/scene/resources/material.h index 3b9d1be260..84f1005b03 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -192,6 +192,7 @@ public: FLAG_ALBEDO_TEXTURE_FORCE_SRGB, FLAG_DONT_RECEIVE_SHADOWS, FLAG_ENSURE_CORRECT_NORMALS, + FLAG_DISABLE_AMBIENT_LIGHT, FLAG_MAX }; @@ -240,7 +241,7 @@ private: uint64_t blend_mode : 2; uint64_t depth_draw_mode : 2; uint64_t cull_mode : 2; - uint64_t flags : 16; + uint64_t flags : 17; uint64_t detail_blend_mode : 2; uint64_t diffuse_mode : 3; uint64_t specular_mode : 2; diff --git a/servers/visual/shader_types.cpp b/servers/visual/shader_types.cpp index 92786ea740..0de8676f32 100644 --- a/servers/visual/shader_types.cpp +++ b/servers/visual/shader_types.cpp @@ -176,6 +176,7 @@ ShaderTypes::ShaderTypes() { shader_modes[VS::SHADER_SPATIAL].modes.push_back("ensure_correct_normals"); shader_modes[VS::SHADER_SPATIAL].modes.push_back("shadows_disabled"); + shader_modes[VS::SHADER_SPATIAL].modes.push_back("ambient_light_disabled"); shader_modes[VS::SHADER_SPATIAL].modes.push_back("vertex_lighting"); |