diff options
author | reduz <reduzio@gmail.com> | 2020-10-24 12:15:43 -0300 |
---|---|---|
committer | reduz <reduzio@gmail.com> | 2020-10-24 15:57:25 -0300 |
commit | 84d734da0e4dc4f0076c61a7178d8ad7b9f3b616 (patch) | |
tree | f5b2f2ec923bf3eb1593531bc3d91c3dc1a1c0a1 /scene/2d | |
parent | b67ccf1a6f326c5d4d5fa1cc7cd15eff3573f8f7 (diff) |
Refactored 2D shader and lighting system
-Removed normal/specular properties from nodes
-Create CanvasTexture, which can contain normal/specular channels
-Refactored, optimized and simplified 2D shaders
-Use atlas for light textures.
-Use a shadow atlas for shadow textures.
-Use both items aboves to make light rendering stateless (faster).
-Reorganized uniform sets for more efficiency.
Diffstat (limited to 'scene/2d')
-rw-r--r-- | scene/2d/animated_sprite_2d.cpp | 41 | ||||
-rw-r--r-- | scene/2d/animated_sprite_2d.h | 43 | ||||
-rw-r--r-- | scene/2d/cpu_particles_2d.cpp | 20 | ||||
-rw-r--r-- | scene/2d/cpu_particles_2d.h | 4 | ||||
-rw-r--r-- | scene/2d/gpu_particles_2d.cpp | 19 | ||||
-rw-r--r-- | scene/2d/gpu_particles_2d.h | 4 | ||||
-rw-r--r-- | scene/2d/light_2d.cpp | 14 | ||||
-rw-r--r-- | scene/2d/light_2d.h | 4 | ||||
-rw-r--r-- | scene/2d/mesh_instance_2d.cpp | 2 | ||||
-rw-r--r-- | scene/2d/multimesh_instance_2d.cpp | 2 | ||||
-rw-r--r-- | scene/2d/polygon_2d.cpp | 58 | ||||
-rw-r--r-- | scene/2d/polygon_2d.h | 16 | ||||
-rw-r--r-- | scene/2d/sprite_2d.cpp | 57 | ||||
-rw-r--r-- | scene/2d/sprite_2d.h | 14 | ||||
-rw-r--r-- | scene/2d/tile_map.cpp | 5 |
15 files changed, 9 insertions, 294 deletions
diff --git a/scene/2d/animated_sprite_2d.cpp b/scene/2d/animated_sprite_2d.cpp index b3370863e1..127748cdd5 100644 --- a/scene/2d/animated_sprite_2d.cpp +++ b/scene/2d/animated_sprite_2d.cpp @@ -33,9 +33,6 @@ #include "core/os/os.h" #include "scene/scene_string_names.h" -#define NORMAL_SUFFIX "_normal" -#define SPECULAR_SUFFIX "_specular" - #ifdef TOOLS_ENABLED Dictionary AnimatedSprite2D::_edit_get_state() const { Dictionary state = Node2D::_edit_get_state(); @@ -152,8 +149,6 @@ void SpriteFrames::add_animation(const StringName &p_anim) { ERR_FAIL_COND_MSG(animations.has(p_anim), "SpriteFrames already has animation '" + p_anim + "'."); animations[p_anim] = Anim(); - animations[p_anim].normal_name = String(p_anim) + NORMAL_SUFFIX; - animations[p_anim].specular_name = String(p_anim) + SPECULAR_SUFFIX; } bool SpriteFrames::has_animation(const StringName &p_anim) const { @@ -171,8 +166,6 @@ void SpriteFrames::rename_animation(const StringName &p_prev, const StringName & Anim anim = animations[p_prev]; animations.erase(p_prev); animations[p_next] = anim; - animations[p_next].normal_name = String(p_next) + NORMAL_SUFFIX; - animations[p_next].specular_name = String(p_next) + SPECULAR_SUFFIX; } Vector<String> SpriteFrames::_get_animation_list() const { @@ -441,9 +434,6 @@ void AnimatedSprite2D::_notification(int p_what) { return; } - Ref<Texture2D> normal = frames->get_normal_frame(animation, frame); - Ref<Texture2D> specular = frames->get_specular_frame(animation, frame); - RID ci = get_canvas_item(); Size2i s; @@ -465,7 +455,7 @@ void AnimatedSprite2D::_notification(int p_what) { dst_rect.size.y = -dst_rect.size.y; } - texture->draw_rect_region(ci, dst_rect, Rect2(Vector2(), texture->get_size()), Color(1, 1, 1), false, normal, specular, Color(specular_color.r, specular_color.g, specular_color.b, shininess)); + texture->draw_rect_region(ci, dst_rect, Rect2(Vector2(), texture->get_size()), Color(1, 1, 1), false); } break; } @@ -672,24 +662,6 @@ String AnimatedSprite2D::get_configuration_warning() const { return warning; } -void AnimatedSprite2D::set_specular_color(const Color &p_color) { - specular_color = p_color; - update(); -} - -Color AnimatedSprite2D::get_specular_color() const { - return specular_color; -} - -void AnimatedSprite2D::set_shininess(float p_shininess) { - shininess = CLAMP(p_shininess, 0.0, 1.0); - update(); -} - -float AnimatedSprite2D::get_shininess() const { - return shininess; -} - void AnimatedSprite2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_sprite_frames", "sprite_frames"), &AnimatedSprite2D::set_sprite_frames); ClassDB::bind_method(D_METHOD("get_sprite_frames"), &AnimatedSprite2D::get_sprite_frames); @@ -722,12 +694,6 @@ void AnimatedSprite2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_speed_scale", "speed_scale"), &AnimatedSprite2D::set_speed_scale); ClassDB::bind_method(D_METHOD("get_speed_scale"), &AnimatedSprite2D::get_speed_scale); - ClassDB::bind_method(D_METHOD("set_specular_color", "color"), &AnimatedSprite2D::set_specular_color); - ClassDB::bind_method(D_METHOD("get_specular_color"), &AnimatedSprite2D::get_specular_color); - - ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &AnimatedSprite2D::set_shininess); - ClassDB::bind_method(D_METHOD("get_shininess"), &AnimatedSprite2D::get_shininess); - ADD_SIGNAL(MethodInfo("frame_changed")); ADD_SIGNAL(MethodInfo("animation_finished")); @@ -737,9 +703,6 @@ void AnimatedSprite2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::INT, "frame"), "set_frame", "get_frame"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "speed_scale"), "set_speed_scale", "get_speed_scale"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "playing"), "_set_playing", "_is_playing"); - ADD_GROUP("Lighting", ""); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "specular_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_specular_color", "get_specular_color"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "shininess", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_shininess", "get_shininess"); ADD_GROUP("Offset", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); @@ -759,6 +722,4 @@ AnimatedSprite2D::AnimatedSprite2D() { animation = "default"; timeout = 0; is_over = false; - specular_color = Color(1, 1, 1, 1); - shininess = 1.0; } diff --git a/scene/2d/animated_sprite_2d.h b/scene/2d/animated_sprite_2d.h index cefed56620..fddbf39be2 100644 --- a/scene/2d/animated_sprite_2d.h +++ b/scene/2d/animated_sprite_2d.h @@ -46,14 +46,8 @@ class SpriteFrames : public Resource { loop = true; speed = 5; } - - StringName normal_name; - StringName specular_name; }; - Color specular_color; - float shininess; - Map<StringName, Anim> animations; Array _get_frames() const; @@ -95,34 +89,6 @@ public: return E->get().frames[p_idx]; } - _FORCE_INLINE_ Ref<Texture2D> get_normal_frame(const StringName &p_anim, int p_idx) const { - const Map<StringName, Anim>::Element *E = animations.find(p_anim); - ERR_FAIL_COND_V_MSG(!E, Ref<Texture2D>(), "Animation '" + String(p_anim) + "' doesn't exist."); - ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>()); - - const Map<StringName, Anim>::Element *EN = animations.find(E->get().normal_name); - - if (!EN || p_idx >= EN->get().frames.size()) { - return Ref<Texture2D>(); - } - - return EN->get().frames[p_idx]; - } - - _FORCE_INLINE_ Ref<Texture2D> get_specular_frame(const StringName &p_anim, int p_idx) const { - const Map<StringName, Anim>::Element *E = animations.find(p_anim); - ERR_FAIL_COND_V(!E, Ref<Texture2D>()); - ERR_FAIL_COND_V(p_idx < 0, Ref<Texture2D>()); - - const Map<StringName, Anim>::Element *EN = animations.find(E->get().specular_name); - - if (!EN || p_idx >= EN->get().frames.size()) { - return Ref<Texture2D>(); - } - - return EN->get().frames[p_idx]; - } - void set_frame(const StringName &p_anim, int p_idx, const Ref<Texture2D> &p_frame) { Map<StringName, Anim>::Element *E = animations.find(p_anim); ERR_FAIL_COND_MSG(!E, "Animation '" + String(p_anim) + "' doesn't exist."); @@ -166,9 +132,6 @@ class AnimatedSprite2D : public Node2D { bool _is_playing() const; Rect2 _get_rect() const; - Color specular_color; - float shininess; - protected: static void _bind_methods(); void _notification(int p_what); @@ -216,12 +179,6 @@ public: void set_flip_v(bool p_flip); bool is_flipped_v() const; - void set_specular_color(const Color &p_color); - Color get_specular_color() const; - - void set_shininess(float p_shininess); - float get_shininess() const; - virtual String get_configuration_warning() const override; AnimatedSprite2D(); }; diff --git a/scene/2d/cpu_particles_2d.cpp b/scene/2d/cpu_particles_2d.cpp index 8d1162b7e3..ef2a9a4911 100644 --- a/scene/2d/cpu_particles_2d.cpp +++ b/scene/2d/cpu_particles_2d.cpp @@ -228,15 +228,6 @@ Ref<Texture2D> CPUParticles2D::get_texture() const { return texture; } -void CPUParticles2D::set_normalmap(const Ref<Texture2D> &p_normalmap) { - normalmap = p_normalmap; - update(); -} - -Ref<Texture2D> CPUParticles2D::get_normalmap() const { - return normalmap; -} - void CPUParticles2D::set_fixed_fps(int p_count) { fixed_fps = p_count; } @@ -1060,12 +1051,7 @@ void CPUParticles2D::_notification(int p_what) { texrid = texture->get_rid(); } - RID normrid; - if (normalmap.is_valid()) { - normrid = normalmap->get_rid(); - } - - RS::get_singleton()->canvas_item_add_multimesh(get_canvas_item(), multimesh, texrid, normrid); + RS::get_singleton()->canvas_item_add_multimesh(get_canvas_item(), multimesh, texrid); } if (p_what == NOTIFICATION_INTERNAL_PROCESS) { @@ -1214,9 +1200,6 @@ void CPUParticles2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture", "texture"), &CPUParticles2D::set_texture); ClassDB::bind_method(D_METHOD("get_texture"), &CPUParticles2D::get_texture); - ClassDB::bind_method(D_METHOD("set_normalmap", "normalmap"), &CPUParticles2D::set_normalmap); - ClassDB::bind_method(D_METHOD("get_normalmap"), &CPUParticles2D::get_normalmap); - ClassDB::bind_method(D_METHOD("restart"), &CPUParticles2D::restart); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "emitting"), "set_emitting", "is_emitting"); @@ -1236,7 +1219,6 @@ void CPUParticles2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::BOOL, "local_coords"), "set_use_local_coordinates", "get_use_local_coordinates"); ADD_PROPERTY(PropertyInfo(Variant::INT, "draw_order", PROPERTY_HINT_ENUM, "Index,Lifetime"), "set_draw_order", "get_draw_order"); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normalmap", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normalmap", "get_normalmap"); BIND_ENUM_CONSTANT(DRAW_ORDER_INDEX); BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME); diff --git a/scene/2d/cpu_particles_2d.h b/scene/2d/cpu_particles_2d.h index dfc875ceb0..5b405246e2 100644 --- a/scene/2d/cpu_particles_2d.h +++ b/scene/2d/cpu_particles_2d.h @@ -147,7 +147,6 @@ private: DrawOrder draw_order; Ref<Texture2D> texture; - Ref<Texture2D> normalmap; //////// @@ -232,9 +231,6 @@ public: void set_texture(const Ref<Texture2D> &p_texture); Ref<Texture2D> get_texture() const; - void set_normalmap(const Ref<Texture2D> &p_normalmap); - Ref<Texture2D> get_normalmap() const; - /////////////////// void set_direction(Vector2 p_direction); diff --git a/scene/2d/gpu_particles_2d.cpp b/scene/2d/gpu_particles_2d.cpp index 01da36ec34..a9fdb103b2 100644 --- a/scene/2d/gpu_particles_2d.cpp +++ b/scene/2d/gpu_particles_2d.cpp @@ -267,15 +267,6 @@ Ref<Texture2D> GPUParticles2D::get_texture() const { return texture; } -void GPUParticles2D::set_normal_map(const Ref<Texture2D> &p_normal_map) { - normal_map = p_normal_map; - update(); -} - -Ref<Texture2D> GPUParticles2D::get_normal_map() const { - return normal_map; -} - void GPUParticles2D::_validate_property(PropertyInfo &property) const { } @@ -290,12 +281,8 @@ void GPUParticles2D::_notification(int p_what) { if (texture.is_valid()) { texture_rid = texture->get_rid(); } - RID normal_rid; - if (normal_map.is_valid()) { - normal_rid = normal_map->get_rid(); - } - RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid, normal_rid); + RS::get_singleton()->canvas_item_add_particles(get_canvas_item(), particles, texture_rid); #ifdef TOOLS_ENABLED if (Engine::get_singleton()->is_editor_hint() && (this == get_tree()->get_edited_scene_root() || get_tree()->get_edited_scene_root()->is_a_parent_of(this))) { @@ -359,9 +346,6 @@ void GPUParticles2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture", "texture"), &GPUParticles2D::set_texture); ClassDB::bind_method(D_METHOD("get_texture"), &GPUParticles2D::get_texture); - ClassDB::bind_method(D_METHOD("set_normal_map", "texture"), &GPUParticles2D::set_normal_map); - ClassDB::bind_method(D_METHOD("get_normal_map"), &GPUParticles2D::get_normal_map); - ClassDB::bind_method(D_METHOD("capture_rect"), &GPUParticles2D::capture_rect); ClassDB::bind_method(D_METHOD("restart"), &GPUParticles2D::restart); @@ -385,7 +369,6 @@ void GPUParticles2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "process_material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial,ParticlesMaterial"), "set_process_material", "get_process_material"); ADD_GROUP("Textures", ""); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_map", "get_normal_map"); BIND_ENUM_CONSTANT(DRAW_ORDER_INDEX); BIND_ENUM_CONSTANT(DRAW_ORDER_LIFETIME); diff --git a/scene/2d/gpu_particles_2d.h b/scene/2d/gpu_particles_2d.h index 3258237f92..f1001a39fe 100644 --- a/scene/2d/gpu_particles_2d.h +++ b/scene/2d/gpu_particles_2d.h @@ -65,7 +65,6 @@ private: DrawOrder draw_order; Ref<Texture2D> texture; - Ref<Texture2D> normal_map; void _update_particle_emission_transform(); @@ -111,9 +110,6 @@ public: void set_texture(const Ref<Texture2D> &p_texture); Ref<Texture2D> get_texture() const; - void set_normal_map(const Ref<Texture2D> &p_normal_map); - Ref<Texture2D> get_normal_map() const; - virtual String get_configuration_warning() const override; void restart(); diff --git a/scene/2d/light_2d.cpp b/scene/2d/light_2d.cpp index 217a210342..4fc0882fdd 100644 --- a/scene/2d/light_2d.cpp +++ b/scene/2d/light_2d.cpp @@ -262,15 +262,6 @@ bool Light2D::is_shadow_enabled() const { return shadow; } -void Light2D::set_shadow_buffer_size(int p_size) { - shadow_buffer_size = p_size; - RS::get_singleton()->canvas_light_set_shadow_buffer_size(canvas_light, shadow_buffer_size); -} - -int Light2D::get_shadow_buffer_size() const { - return shadow_buffer_size; -} - void Light2D::set_shadow_filter(ShadowFilter p_filter) { ERR_FAIL_INDEX(p_filter, SHADOW_FILTER_MAX); shadow_filter = p_filter; @@ -380,9 +371,6 @@ void Light2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_shadow_enabled", "enabled"), &Light2D::set_shadow_enabled); ClassDB::bind_method(D_METHOD("is_shadow_enabled"), &Light2D::is_shadow_enabled); - ClassDB::bind_method(D_METHOD("set_shadow_buffer_size", "size"), &Light2D::set_shadow_buffer_size); - ClassDB::bind_method(D_METHOD("get_shadow_buffer_size"), &Light2D::get_shadow_buffer_size); - ClassDB::bind_method(D_METHOD("set_shadow_smooth", "smooth"), &Light2D::set_shadow_smooth); ClassDB::bind_method(D_METHOD("get_shadow_smooth"), &Light2D::get_shadow_smooth); @@ -411,7 +399,6 @@ void Light2D::_bind_methods() { ADD_GROUP("Shadow", "shadow_"); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "shadow_enabled"), "set_shadow_enabled", "is_shadow_enabled"); ADD_PROPERTY(PropertyInfo(Variant::COLOR, "shadow_color"), "set_shadow_color", "get_shadow_color"); - ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_buffer_size", PROPERTY_HINT_RANGE, "32,16384,1"), "set_shadow_buffer_size", "get_shadow_buffer_size"); ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_filter", PROPERTY_HINT_ENUM, "None,PCF5,PCF13"), "set_shadow_filter", "get_shadow_filter"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "shadow_filter_smooth", PROPERTY_HINT_RANGE, "0,64,0.1"), "set_shadow_smooth", "get_shadow_smooth"); ADD_PROPERTY(PropertyInfo(Variant::INT, "shadow_item_cull_mask", PROPERTY_HINT_LAYERS_2D_RENDER), "set_item_shadow_cull_mask", "get_item_shadow_cull_mask"); @@ -441,7 +428,6 @@ Light2D::Light2D() { item_mask = 1; item_shadow_mask = 1; mode = MODE_ADD; - shadow_buffer_size = 2048; energy = 1.0; shadow_color = Color(0, 0, 0, 0); shadow_filter = SHADOW_FILTER_NONE; diff --git a/scene/2d/light_2d.h b/scene/2d/light_2d.h index 45444800fe..095cb05635 100644 --- a/scene/2d/light_2d.h +++ b/scene/2d/light_2d.h @@ -67,7 +67,6 @@ private: int layer_max; int item_mask; int item_shadow_mask; - int shadow_buffer_size; float shadow_smooth; Mode mode; Ref<Texture2D> texture; @@ -142,9 +141,6 @@ public: void set_shadow_enabled(bool p_enabled); bool is_shadow_enabled() const; - void set_shadow_buffer_size(int p_size); - int get_shadow_buffer_size() const; - void set_shadow_filter(ShadowFilter p_filter); ShadowFilter get_shadow_filter() const; diff --git a/scene/2d/mesh_instance_2d.cpp b/scene/2d/mesh_instance_2d.cpp index 897595ad1f..037e423ce9 100644 --- a/scene/2d/mesh_instance_2d.cpp +++ b/scene/2d/mesh_instance_2d.cpp @@ -33,7 +33,7 @@ void MeshInstance2D::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { if (mesh.is_valid()) { - draw_mesh(mesh, texture, normal_map); + draw_mesh(mesh, texture); } } } diff --git a/scene/2d/multimesh_instance_2d.cpp b/scene/2d/multimesh_instance_2d.cpp index b99c0a3fa9..c258e30eab 100644 --- a/scene/2d/multimesh_instance_2d.cpp +++ b/scene/2d/multimesh_instance_2d.cpp @@ -33,7 +33,7 @@ void MultiMeshInstance2D::_notification(int p_what) { if (p_what == NOTIFICATION_DRAW) { if (multimesh.is_valid()) { - draw_multimesh(multimesh, texture, normal_map); + draw_multimesh(multimesh, texture); } } } diff --git a/scene/2d/polygon_2d.cpp b/scene/2d/polygon_2d.cpp index 13b62816a4..26340bb861 100644 --- a/scene/2d/polygon_2d.cpp +++ b/scene/2d/polygon_2d.cpp @@ -302,7 +302,7 @@ void Polygon2D::_notification(int p_what) { if (invert || polygons.size() == 0) { Vector<int> indices = Geometry2D::triangulate_polygon(points); if (indices.size()) { - RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1, normal_map.is_valid() ? normal_map->get_rid() : RID(), specular_map.is_valid() ? specular_map->get_rid() : RID(), Color(specular_color.r, specular_color.g, specular_color.b, shininess)); + RS::get_singleton()->canvas_item_add_triangle_array(get_canvas_item(), indices, points, colors, uvs, bones, weights, texture.is_valid() ? texture->get_rid() : RID(), -1); } } else { //draw individual polygons @@ -417,42 +417,6 @@ Ref<Texture2D> Polygon2D::get_texture() const { return texture; } -void Polygon2D::set_normal_map(const Ref<Texture2D> &p_normal_map) { - normal_map = p_normal_map; - update(); -} - -Ref<Texture2D> Polygon2D::get_normal_map() const { - return normal_map; -} - -void Polygon2D::set_specular_map(const Ref<Texture2D> &p_specular_map) { - specular_map = p_specular_map; - update(); -} - -Ref<Texture2D> Polygon2D::get_specular_map() const { - return specular_map; -} - -void Polygon2D::set_specular_color(const Color &p_specular_color) { - specular_color = p_specular_color; - update(); -} - -Color Polygon2D::get_specular_color() const { - return specular_color; -} - -void Polygon2D::set_shininess(float p_shininess) { - shininess = CLAMP(p_shininess, 0.0, 1.0); - update(); -} - -float Polygon2D::get_shininess() const { - return shininess; -} - void Polygon2D::set_texture_offset(const Vector2 &p_offset) { tex_ofs = p_offset; update(); @@ -616,18 +580,6 @@ void Polygon2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Polygon2D::set_texture); ClassDB::bind_method(D_METHOD("get_texture"), &Polygon2D::get_texture); - ClassDB::bind_method(D_METHOD("set_normal_map", "normal_map"), &Polygon2D::set_normal_map); - ClassDB::bind_method(D_METHOD("get_normal_map"), &Polygon2D::get_normal_map); - - ClassDB::bind_method(D_METHOD("set_specular_map", "specular_map"), &Polygon2D::set_specular_map); - ClassDB::bind_method(D_METHOD("get_specular_map"), &Polygon2D::get_specular_map); - - ClassDB::bind_method(D_METHOD("set_specular_color", "specular_color"), &Polygon2D::set_specular_color); - ClassDB::bind_method(D_METHOD("get_specular_color"), &Polygon2D::get_specular_color); - - ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &Polygon2D::set_shininess); - ClassDB::bind_method(D_METHOD("get_shininess"), &Polygon2D::get_shininess); - ClassDB::bind_method(D_METHOD("set_texture_offset", "texture_offset"), &Polygon2D::set_texture_offset); ClassDB::bind_method(D_METHOD("get_texture_offset"), &Polygon2D::get_texture_offset); @@ -680,11 +632,6 @@ void Polygon2D::_bind_methods() { ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "texture_scale"), "set_texture_scale", "get_texture_scale"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_rotation_degrees", PROPERTY_HINT_RANGE, "-360,360,0.1,or_lesser,or_greater"), "set_texture_rotation_degrees", "get_texture_rotation_degrees"); ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "texture_rotation", PROPERTY_HINT_NONE, "", 0), "set_texture_rotation", "get_texture_rotation"); - ADD_GROUP("Lighting", ""); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_map", "get_normal_map"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "specular_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_specular_map", "get_specular_map"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "specular_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_specular_color", "get_specular_color"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "shininess", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_shininess", "get_shininess"); ADD_GROUP("Skeleton", ""); ADD_PROPERTY(PropertyInfo(Variant::NODE_PATH, "skeleton", PROPERTY_HINT_NODE_PATH_VALID_TYPES, "Skeleton2D"), "set_skeleton", "get_skeleton"); @@ -711,7 +658,4 @@ Polygon2D::Polygon2D() { color = Color(1, 1, 1); rect_cache_dirty = true; internal_vertices = 0; - - specular_color = Color(1, 1, 1, 1); - shininess = 1.0; } diff --git a/scene/2d/polygon_2d.h b/scene/2d/polygon_2d.h index c5ff05aace..e2a8db414a 100644 --- a/scene/2d/polygon_2d.h +++ b/scene/2d/polygon_2d.h @@ -51,10 +51,6 @@ class Polygon2D : public Node2D { Color color; Ref<Texture2D> texture; - Ref<Texture2D> normal_map; - Ref<Texture2D> specular_map; - Color specular_color; - float shininess; Size2 tex_scale; Vector2 tex_ofs; @@ -115,18 +111,6 @@ public: void set_texture(const Ref<Texture2D> &p_texture); Ref<Texture2D> get_texture() const; - void set_normal_map(const Ref<Texture2D> &p_normal_map); - Ref<Texture2D> get_normal_map() const; - - void set_specular_map(const Ref<Texture2D> &p_specular_map); - Ref<Texture2D> get_specular_map() const; - - void set_specular_color(const Color &p_specular_color); - Color get_specular_color() const; - - void set_shininess(float p_shininess); - float get_shininess() const; - void set_texture_offset(const Vector2 &p_offset); Vector2 get_texture_offset() const; diff --git a/scene/2d/sprite_2d.cpp b/scene/2d/sprite_2d.cpp index d1be93e55d..5178d2f850 100644 --- a/scene/2d/sprite_2d.cpp +++ b/scene/2d/sprite_2d.cpp @@ -130,8 +130,8 @@ void Sprite2D::_notification(int p_what) { Rect2 src_rect, dst_rect; bool filter_clip; _get_rects(src_rect, dst_rect, filter_clip); - texture->draw_rect_region(ci, dst_rect, src_rect, Color(1, 1, 1), false, normal_map, specular, Color(specular_color.r, specular_color.g, specular_color.b, shininess), RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, filter_clip); + texture->draw_rect_region(ci, dst_rect, src_rect, Color(1, 1, 1), false, filter_clip); } break; } } @@ -157,42 +157,6 @@ void Sprite2D::set_texture(const Ref<Texture2D> &p_texture) { _change_notify("texture"); } -void Sprite2D::set_normal_map(const Ref<Texture2D> &p_texture) { - normal_map = p_texture; - update(); -} - -Ref<Texture2D> Sprite2D::get_normal_map() const { - return normal_map; -} - -void Sprite2D::set_specular_map(const Ref<Texture2D> &p_texture) { - specular = p_texture; - update(); -} - -Ref<Texture2D> Sprite2D::get_specular_map() const { - return specular; -} - -void Sprite2D::set_specular_color(const Color &p_color) { - specular_color = p_color; - update(); -} - -Color Sprite2D::get_specular_color() const { - return specular_color; -} - -void Sprite2D::set_shininess(float p_shininess) { - shininess = CLAMP(p_shininess, 0.0, 1.0); - update(); -} - -float Sprite2D::get_shininess() const { - return shininess; -} - Ref<Texture2D> Sprite2D::get_texture() const { return texture; } @@ -434,18 +398,6 @@ void Sprite2D::_bind_methods() { ClassDB::bind_method(D_METHOD("set_texture", "texture"), &Sprite2D::set_texture); ClassDB::bind_method(D_METHOD("get_texture"), &Sprite2D::get_texture); - ClassDB::bind_method(D_METHOD("set_normal_map", "normal_map"), &Sprite2D::set_normal_map); - ClassDB::bind_method(D_METHOD("get_normal_map"), &Sprite2D::get_normal_map); - - ClassDB::bind_method(D_METHOD("set_specular_map", "specular_map"), &Sprite2D::set_specular_map); - ClassDB::bind_method(D_METHOD("get_specular_map"), &Sprite2D::get_specular_map); - - ClassDB::bind_method(D_METHOD("set_specular_color", "specular_color"), &Sprite2D::set_specular_color); - ClassDB::bind_method(D_METHOD("get_specular_color"), &Sprite2D::get_specular_color); - - ClassDB::bind_method(D_METHOD("set_shininess", "shininess"), &Sprite2D::set_shininess); - ClassDB::bind_method(D_METHOD("get_shininess"), &Sprite2D::get_shininess); - ClassDB::bind_method(D_METHOD("set_centered", "centered"), &Sprite2D::set_centered); ClassDB::bind_method(D_METHOD("is_centered"), &Sprite2D::is_centered); @@ -487,11 +439,6 @@ void Sprite2D::_bind_methods() { ADD_SIGNAL(MethodInfo("texture_changed")); ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture"); - ADD_GROUP("Lighting", ""); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_normal_map", "get_normal_map"); - ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "specular_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_specular_map", "get_specular_map"); - ADD_PROPERTY(PropertyInfo(Variant::COLOR, "specular_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_specular_color", "get_specular_color"); - ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "shininess", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_shininess", "get_shininess"); ADD_GROUP("Offset", ""); ADD_PROPERTY(PropertyInfo(Variant::BOOL, "centered"), "set_centered", "is_centered"); ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "offset"), "set_offset", "get_offset"); @@ -515,8 +462,6 @@ Sprite2D::Sprite2D() { vflip = false; region = false; region_filter_clip = false; - shininess = 1.0; - specular_color = Color(1, 1, 1, 1); frame = 0; diff --git a/scene/2d/sprite_2d.h b/scene/2d/sprite_2d.h index f6b752575f..2875d333bb 100644 --- a/scene/2d/sprite_2d.h +++ b/scene/2d/sprite_2d.h @@ -38,8 +38,6 @@ class Sprite2D : public Node2D { GDCLASS(Sprite2D, Node2D); Ref<Texture2D> texture; - Ref<Texture2D> normal_map; - Ref<Texture2D> specular; Color specular_color; float shininess; @@ -87,18 +85,6 @@ public: void set_texture(const Ref<Texture2D> &p_texture); Ref<Texture2D> get_texture() const; - void set_normal_map(const Ref<Texture2D> &p_texture); - Ref<Texture2D> get_normal_map() const; - - void set_specular_map(const Ref<Texture2D> &p_texture); - Ref<Texture2D> get_specular_map() const; - - void set_specular_color(const Color &p_color); - Color get_specular_color() const; - - void set_shininess(float p_shininess); - float get_shininess() const; - void set_centered(bool p_center); bool is_centered() const; diff --git a/scene/2d/tile_map.cpp b/scene/2d/tile_map.cpp index 94ec0998fa..bff191a2bf 100644 --- a/scene/2d/tile_map.cpp +++ b/scene/2d/tile_map.cpp @@ -528,15 +528,14 @@ void TileMap::update_dirty_quadrants() { rect.position += tile_ofs; } - Ref<Texture2D> normal_map = tile_set->tile_get_normal_map(c.id); Color modulate = tile_set->tile_get_modulate(c.id); Color self_modulate = get_self_modulate(); modulate = Color(modulate.r * self_modulate.r, modulate.g * self_modulate.g, modulate.b * self_modulate.b, modulate.a * self_modulate.a); if (r == Rect2()) { - tex->draw_rect(canvas_item, rect, false, modulate, c.transpose, normal_map); + tex->draw_rect(canvas_item, rect, false, modulate, c.transpose); } else { - tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, normal_map, Ref<Texture2D>(), Color(1, 1, 1, 1), RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, clip_uv); + tex->draw_rect_region(canvas_item, rect, r, modulate, c.transpose, clip_uv); } Vector<TileSet::ShapeData> shapes = tile_set->tile_get_shapes(c.id); |