summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/animation.h2
-rw-r--r--scene/resources/bit_map.h4
-rw-r--r--scene/resources/camera_effects.h4
-rw-r--r--scene/resources/curve.h2
-rw-r--r--scene/resources/dynamic_font.cpp19
-rw-r--r--scene/resources/dynamic_font.h2
-rw-r--r--scene/resources/environment.cpp95
-rw-r--r--scene/resources/environment.h14
-rw-r--r--scene/resources/font.cpp3
-rw-r--r--scene/resources/font.h4
-rw-r--r--scene/resources/gradient.cpp20
-rw-r--r--scene/resources/gradient.h2
-rw-r--r--scene/resources/material.cpp170
-rw-r--r--scene/resources/material.h142
-rw-r--r--scene/resources/mesh.cpp2
-rw-r--r--scene/resources/mesh.h2
-rw-r--r--scene/resources/mesh_library.h4
-rw-r--r--scene/resources/packed_scene.cpp4
-rw-r--r--scene/resources/packed_scene.h2
-rw-r--r--scene/resources/particles_material.h2
-rw-r--r--scene/resources/physics_material.h2
-rw-r--r--scene/resources/polygon_path_finder.h2
-rw-r--r--scene/resources/resource_format_text.cpp2
-rw-r--r--scene/resources/resource_format_text.h2
-rw-r--r--scene/resources/shader.h2
-rw-r--r--scene/resources/shape_2d.h2
-rw-r--r--scene/resources/shape_3d.h2
-rw-r--r--scene/resources/skin.h2
-rw-r--r--scene/resources/sky_material.h2
-rw-r--r--scene/resources/style_box.cpp23
-rw-r--r--scene/resources/style_box.h6
-rw-r--r--scene/resources/surface_tool.cpp2
-rw-r--r--scene/resources/syntax_highlighter.cpp2
-rw-r--r--scene/resources/syntax_highlighter.h2
-rw-r--r--scene/resources/texture.cpp116
-rw-r--r--scene/resources/texture.h38
-rw-r--r--scene/resources/theme.cpp2
-rw-r--r--scene/resources/theme.h2
-rw-r--r--scene/resources/tile_set.cpp22
-rw-r--r--scene/resources/tile_set.h8
-rw-r--r--scene/resources/visual_shader.cpp46
-rw-r--r--scene/resources/visual_shader.h32
-rw-r--r--scene/resources/visual_shader_nodes.cpp84
-rw-r--r--scene/resources/visual_shader_nodes.h33
-rw-r--r--scene/resources/world_2d.cpp2
-rw-r--r--scene/resources/world_2d.h4
-rw-r--r--scene/resources/world_3d.h2
47 files changed, 625 insertions, 318 deletions
diff --git a/scene/resources/animation.h b/scene/resources/animation.h
index 722a400fd6..c52431f5f6 100644
--- a/scene/resources/animation.h
+++ b/scene/resources/animation.h
@@ -31,7 +31,7 @@
#ifndef ANIMATION_H
#define ANIMATION_H
-#include "core/resource.h"
+#include "core/io/resource.h"
class Animation : public Resource {
GDCLASS(Animation, Resource);
diff --git a/scene/resources/bit_map.h b/scene/resources/bit_map.h
index 59f3b4dc3c..56ff72c094 100644
--- a/scene/resources/bit_map.h
+++ b/scene/resources/bit_map.h
@@ -31,9 +31,9 @@
#ifndef BIT_MAP_H
#define BIT_MAP_H
-#include "core/image.h"
+#include "core/io/image.h"
+#include "core/io/resource.h"
#include "core/io/resource_loader.h"
-#include "core/resource.h"
class BitMap : public Resource {
GDCLASS(BitMap, Resource);
diff --git a/scene/resources/camera_effects.h b/scene/resources/camera_effects.h
index 99fd4eb37c..9a26f3d0b2 100644
--- a/scene/resources/camera_effects.h
+++ b/scene/resources/camera_effects.h
@@ -31,8 +31,8 @@
#ifndef CAMERA_EFFECTS_H
#define CAMERA_EFFECTS_H
-#include "core/resource.h"
-#include "core/rid.h"
+#include "core/io/resource.h"
+#include "core/templates/rid.h"
class CameraEffects : public Resource {
GDCLASS(CameraEffects, Resource);
diff --git a/scene/resources/curve.h b/scene/resources/curve.h
index 57ddaf897d..6c5f4b7057 100644
--- a/scene/resources/curve.h
+++ b/scene/resources/curve.h
@@ -31,7 +31,7 @@
#ifndef CURVE_H
#define CURVE_H
-#include "core/resource.h"
+#include "core/io/resource.h"
// y(x) curve
class Curve : public Resource {
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index bc983c1d7e..d76d364737 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -347,7 +347,7 @@ float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, char3
modulate.r = modulate.g = modulate.b = 1.0;
}
RID texture = font->textures[ch->texture_idx].texture->get_rid();
- RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), texture, ch->rect_uv, modulate, false, RID(), RID(), Color(1, 1, 1, 1), false);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, ch->rect.size), texture, ch->rect_uv, modulate, false, false);
}
advance = ch->advance;
@@ -458,8 +458,21 @@ DynamicFontAtSize::TexturePosition DynamicFontAtSize::_find_texture_pos_for_glyp
//zero texture
uint8_t *w = tex.imgdata.ptrw();
ERR_FAIL_COND_V(texsize * texsize * p_color_size > tex.imgdata.size(), ret);
- for (int i = 0; i < texsize * texsize * p_color_size; i++) {
- w[i] = 0;
+
+ // Initialize the texture to all-white pixels to prevent artifacts when the
+ // font is displayed at a non-default scale with filtering enabled.
+ if (p_color_size == 2) {
+ for (int i = 0; i < texsize * texsize * p_color_size; i += 2) {
+ w[i + 0] = 255;
+ w[i + 1] = 0;
+ }
+ } else {
+ for (int i = 0; i < texsize * texsize * p_color_size; i += 4) {
+ w[i + 0] = 255;
+ w[i + 1] = 255;
+ w[i + 2] = 255;
+ w[i + 3] = 0;
+ }
}
}
tex.offsets.resize(texsize);
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index a881e21da8..73ba42f8a7 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -37,7 +37,7 @@
#include "core/io/resource_loader.h"
#include "core/os/mutex.h"
#include "core/os/thread_safe.h"
-#include "core/pair.h"
+#include "core/templates/pair.h"
#include "scene/resources/font.h"
#include <ft2build.h>
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index ee8e63266d..bacdb6be54 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -30,7 +30,7 @@
#include "environment.h"
-#include "core/project_settings.h"
+#include "core/config/project_settings.h"
#include "servers/rendering_server.h"
#include "texture.h"
@@ -44,6 +44,9 @@ void Environment::set_background(BGMode p_bg) {
bg_mode = p_bg;
RS::get_singleton()->environment_set_background(environment, RS::EnvironmentBG(p_bg));
_change_notify();
+ if (bg_mode != BG_SKY) {
+ set_fog_aerial_perspective(0.0);
+ }
}
Environment::BGMode Environment::get_background() const {
@@ -578,22 +581,28 @@ bool Environment::is_glow_enabled() const {
return glow_enabled;
}
-void Environment::set_glow_level_enabled(int p_level, bool p_enabled) {
+void Environment::set_glow_level(int p_level, float p_intensity) {
ERR_FAIL_INDEX(p_level, RS::MAX_GLOW_LEVELS);
- if (p_enabled) {
- glow_levels |= (1 << p_level);
- } else {
- glow_levels &= ~(1 << p_level);
- }
+ glow_levels.write[p_level] = p_intensity;
_update_glow();
}
-bool Environment::is_glow_level_enabled(int p_level) const {
+float Environment::get_glow_level(int p_level) const {
ERR_FAIL_INDEX_V(p_level, RS::MAX_GLOW_LEVELS, false);
- return glow_levels & (1 << p_level);
+ return glow_levels[p_level];
+}
+
+void Environment::set_glow_normalized(bool p_normalized) {
+ glow_normalize_levels = p_normalized;
+
+ _update_glow();
+}
+
+bool Environment::is_glow_normalized() const {
+ return glow_normalize_levels;
}
void Environment::set_glow_intensity(float p_intensity) {
@@ -670,10 +679,24 @@ float Environment::get_glow_hdr_luminance_cap() const {
}
void Environment::_update_glow() {
+ Vector<float> normalized_levels;
+ if (glow_normalize_levels) {
+ normalized_levels.resize(7);
+ float size = 0.0;
+ for (int i = 0; i < glow_levels.size(); i++) {
+ size += glow_levels[i];
+ }
+ for (int i = 0; i < glow_levels.size(); i++) {
+ normalized_levels.write[i] = glow_levels[i] / size;
+ }
+ } else {
+ normalized_levels = glow_levels;
+ }
+
RS::get_singleton()->environment_set_glow(
environment,
glow_enabled,
- glow_levels,
+ normalized_levels,
glow_intensity,
glow_strength,
glow_mix,
@@ -739,6 +762,14 @@ float Environment::get_fog_height_density() const {
return fog_height_density;
}
+void Environment::set_fog_aerial_perspective(float p_aerial_perspective) {
+ fog_aerial_perspective = p_aerial_perspective;
+ _update_fog();
+}
+float Environment::get_fog_aerial_perspective() const {
+ return fog_aerial_perspective;
+}
+
void Environment::_update_fog() {
RS::get_singleton()->environment_set_fog(
environment,
@@ -748,7 +779,8 @@ void Environment::_update_fog() {
fog_sun_scatter,
fog_density,
fog_height,
- fog_height_density);
+ fog_height_density,
+ fog_aerial_perspective);
}
// Volumetric Fog
@@ -887,6 +919,12 @@ void Environment::_validate_property(PropertyInfo &property) const {
}
}
+ if (property.name == "fog_aerial_perspective") {
+ if (bg_mode != BG_SKY) {
+ property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
+ }
+ }
+
if (property.name == "glow_intensity" && glow_blend_mode == GLOW_BLEND_MODE_MIX) {
property.usage = PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL;
}
@@ -1162,8 +1200,10 @@ void Environment::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_glow_enabled", "enabled"), &Environment::set_glow_enabled);
ClassDB::bind_method(D_METHOD("is_glow_enabled"), &Environment::is_glow_enabled);
- ClassDB::bind_method(D_METHOD("set_glow_level_enabled", "idx", "enabled"), &Environment::set_glow_level_enabled);
- ClassDB::bind_method(D_METHOD("is_glow_level_enabled", "idx"), &Environment::is_glow_level_enabled);
+ ClassDB::bind_method(D_METHOD("set_glow_level", "idx", "intensity"), &Environment::set_glow_level);
+ ClassDB::bind_method(D_METHOD("get_glow_level", "idx"), &Environment::get_glow_level);
+ ClassDB::bind_method(D_METHOD("set_glow_normalized", "normalize"), &Environment::set_glow_normalized);
+ ClassDB::bind_method(D_METHOD("is_glow_normalized"), &Environment::is_glow_normalized);
ClassDB::bind_method(D_METHOD("set_glow_intensity", "intensity"), &Environment::set_glow_intensity);
ClassDB::bind_method(D_METHOD("get_glow_intensity"), &Environment::get_glow_intensity);
ClassDB::bind_method(D_METHOD("set_glow_strength", "strength"), &Environment::set_glow_strength);
@@ -1183,13 +1223,14 @@ void Environment::_bind_methods() {
ADD_GROUP("Glow", "glow_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_enabled"), "set_glow_enabled", "is_glow_enabled");
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/1"), "set_glow_level_enabled", "is_glow_level_enabled", 0);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/2"), "set_glow_level_enabled", "is_glow_level_enabled", 1);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/3"), "set_glow_level_enabled", "is_glow_level_enabled", 2);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/4"), "set_glow_level_enabled", "is_glow_level_enabled", 3);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/5"), "set_glow_level_enabled", "is_glow_level_enabled", 4);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/6"), "set_glow_level_enabled", "is_glow_level_enabled", 5);
- ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "glow_levels/7"), "set_glow_level_enabled", "is_glow_level_enabled", 6);
+ ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/1", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 0);
+ ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/2", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 1);
+ ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/3", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 2);
+ ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/4", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 3);
+ ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/5", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 4);
+ ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/6", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 5);
+ ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "glow_levels/7", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_glow_level", "get_glow_level", 6);
+ ADD_PROPERTY(PropertyInfo(Variant::BOOL, "glow_normalized"), "set_glow_normalized", "is_glow_normalized");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_intensity", PROPERTY_HINT_RANGE, "0.0,8.0,0.01"), "set_glow_intensity", "get_glow_intensity");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_strength", PROPERTY_HINT_RANGE, "0.0,2.0,0.01"), "set_glow_strength", "get_glow_strength");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "glow_mix", PROPERTY_HINT_RANGE, "0.0,1.0,0.001"), "set_glow_mix", "get_glow_mix");
@@ -1219,6 +1260,9 @@ void Environment::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_fog_height_density", "height_density"), &Environment::set_fog_height_density);
ClassDB::bind_method(D_METHOD("get_fog_height_density"), &Environment::get_fog_height_density);
+ ClassDB::bind_method(D_METHOD("set_fog_aerial_perspective", "aerial_perspective"), &Environment::set_fog_aerial_perspective);
+ ClassDB::bind_method(D_METHOD("get_fog_aerial_perspective"), &Environment::get_fog_aerial_perspective);
+
ADD_GROUP("Fog", "fog_");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "fog_enabled"), "set_fog_enabled", "is_fog_enabled");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "fog_light_color", PROPERTY_HINT_COLOR_NO_ALPHA), "set_fog_light_color", "get_fog_light_color");
@@ -1226,6 +1270,7 @@ void Environment::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_sun_scatter", PROPERTY_HINT_RANGE, "0,1,0.01,or_greater"), "set_fog_sun_scatter", "get_fog_sun_scatter");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_density", PROPERTY_HINT_RANGE, "0,16,0.0001"), "set_fog_density", "get_fog_density");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_aerial_perspective", PROPERTY_HINT_RANGE, "0,1,0.001"), "set_fog_aerial_perspective", "get_fog_aerial_perspective");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_height", PROPERTY_HINT_RANGE, "-1024,1024,0.01,or_lesser,or_greater"), "set_fog_height", "get_fog_height");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "fog_height_density", PROPERTY_HINT_RANGE, "0,128,0.001,or_greater"), "set_fog_height_density", "get_fog_height_density");
@@ -1329,6 +1374,16 @@ Environment::Environment() {
environment = RS::get_singleton()->environment_create();
set_camera_feed_id(bg_camera_feed_id);
+
+ glow_levels.resize(7);
+ glow_levels.write[0] = 0.0;
+ glow_levels.write[1] = 0.0;
+ glow_levels.write[2] = 1.0;
+ glow_levels.write[3] = 0.0;
+ glow_levels.write[4] = 1.0;
+ glow_levels.write[5] = 0.0;
+ glow_levels.write[6] = 0.0;
+
_update_ambient_light();
_update_tonemap();
_update_ssr();
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index d4d84f31aa..23c7f5180c 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -31,7 +31,7 @@
#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
-#include "core/resource.h"
+#include "core/io/resource.h"
#include "scene/resources/sky.h"
#include "scene/resources/texture.h"
#include "servers/rendering_server.h"
@@ -171,7 +171,8 @@ private:
// Glow
bool glow_enabled = false;
- int glow_levels = (1 << 2) | (1 << 4);
+ Vector<float> glow_levels;
+ bool glow_normalize_levels = false;
float glow_intensity = 0.8;
float glow_strength = 1.0;
float glow_mix = 0.05;
@@ -190,6 +191,7 @@ private:
float fog_density = 0.001;
float fog_height = 0.0;
float fog_height_density = 0.0; //can be negative to invert effect
+ float fog_aerial_perspective = 0.0;
void _update_fog();
@@ -332,8 +334,10 @@ public:
// Glow
void set_glow_enabled(bool p_enabled);
bool is_glow_enabled() const;
- void set_glow_level_enabled(int p_level, bool p_enabled);
- bool is_glow_level_enabled(int p_level) const;
+ void set_glow_level(int p_level, float p_intensity);
+ float get_glow_level(int p_level) const;
+ void set_glow_normalized(bool p_normalized);
+ bool is_glow_normalized() const;
void set_glow_intensity(float p_intensity);
float get_glow_intensity() const;
void set_glow_strength(float p_strength);
@@ -368,6 +372,8 @@ public:
float get_fog_height() const;
void set_fog_height_density(float p_amount);
float get_fog_height_density() const;
+ void set_fog_aerial_perspective(float p_aerial_perspective);
+ float get_fog_aerial_perspective() const;
// Volumetric Fog
void set_volumetric_fog_enabled(bool p_enable);
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 7cc39f661d..7bda889e46 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -31,7 +31,6 @@
#include "font.h"
#include "core/io/resource_loader.h"
-#include "core/method_bind_ext.gen.inc"
#include "core/os/file_access.h"
void Font::draw_halign(RID p_canvas_item, const Point2 &p_pos, HAlign p_align, float p_width, const String &p_text, const Color &p_modulate, const Color &p_outline_modulate) const {
@@ -550,7 +549,7 @@ float BitmapFont::draw_char(RID p_canvas_item, const Point2 &p_pos, char32_t p_c
cpos.x += c->h_align;
cpos.y -= ascent;
cpos.y += c->v_align;
- RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate, false, RID(), RID(), Color(1, 1, 1, 1), false);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(cpos, c->rect.size), textures[c->texture_idx]->get_rid(), c->rect, p_modulate, false, false);
}
return get_char_size(p_char, p_next).width;
diff --git a/scene/resources/font.h b/scene/resources/font.h
index c739520da3..d8c350bb41 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -31,8 +31,8 @@
#ifndef FONT_H
#define FONT_H
-#include "core/map.h"
-#include "core/resource.h"
+#include "core/io/resource.h"
+#include "core/templates/map.h"
#include "scene/resources/texture.h"
class Font : public Resource {
diff --git a/scene/resources/gradient.cpp b/scene/resources/gradient.cpp
index b720653f91..6b41b97e45 100644
--- a/scene/resources/gradient.cpp
+++ b/scene/resources/gradient.cpp
@@ -32,14 +32,8 @@
#include "core/core_string_names.h"
-//setter and getter names for property serialization
-#define COLOR_RAMP_GET_OFFSETS "get_offsets"
-#define COLOR_RAMP_GET_COLORS "get_colors"
-#define COLOR_RAMP_SET_OFFSETS "set_offsets"
-#define COLOR_RAMP_SET_COLORS "set_colors"
-
Gradient::Gradient() {
- //Set initial color ramp transition from black to white
+ //Set initial gradient transition from black to white
points.resize(2);
points.write[0].color = Color(0, 0, 0, 1);
points.write[0].offset = 0;
@@ -65,14 +59,14 @@ void Gradient::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_point_count"), &Gradient::get_points_count);
- ClassDB::bind_method(D_METHOD(COLOR_RAMP_SET_OFFSETS, "offsets"), &Gradient::set_offsets);
- ClassDB::bind_method(D_METHOD(COLOR_RAMP_GET_OFFSETS), &Gradient::get_offsets);
+ ClassDB::bind_method(D_METHOD("set_offsets", "offsets"), &Gradient::set_offsets);
+ ClassDB::bind_method(D_METHOD("get_offsets"), &Gradient::get_offsets);
- ClassDB::bind_method(D_METHOD(COLOR_RAMP_SET_COLORS, "colors"), &Gradient::set_colors);
- ClassDB::bind_method(D_METHOD(COLOR_RAMP_GET_COLORS), &Gradient::get_colors);
+ ClassDB::bind_method(D_METHOD("set_colors", "colors"), &Gradient::set_colors);
+ ClassDB::bind_method(D_METHOD("get_colors"), &Gradient::get_colors);
- ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT32_ARRAY, "offsets"), COLOR_RAMP_SET_OFFSETS, COLOR_RAMP_GET_OFFSETS);
- ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "colors"), COLOR_RAMP_SET_COLORS, COLOR_RAMP_GET_COLORS);
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_FLOAT32_ARRAY, "offsets"), "set_offsets", "get_offsets");
+ ADD_PROPERTY(PropertyInfo(Variant::PACKED_COLOR_ARRAY, "colors"), "set_colors", "get_colors");
}
Vector<float> Gradient::get_offsets() const {
diff --git a/scene/resources/gradient.h b/scene/resources/gradient.h
index 6518b13ee8..e839909770 100644
--- a/scene/resources/gradient.h
+++ b/scene/resources/gradient.h
@@ -31,7 +31,7 @@
#ifndef GRADIENT_H
#define GRADIENT_H
-#include "core/resource.h"
+#include "core/io/resource.h"
class Gradient : public Resource {
GDCLASS(Gradient, Resource);
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 1e95a35726..35c967ce27 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -30,7 +30,7 @@
#include "material.h"
-#include "core/engine.h"
+#include "core/config/engine.h"
#ifdef TOOLS_ENABLED
#include "editor/editor_settings.h"
@@ -324,7 +324,6 @@ void BaseMaterial3D::init_shaders() {
shader_names->rim_texture_channel = "rim_texture_channel";
shader_names->heightmap_texture_channel = "heightmap_texture_channel";
shader_names->refraction_texture_channel = "refraction_texture_channel";
- shader_names->alpha_scissor_threshold = "alpha_scissor_threshold";
shader_names->transmittance_color = "transmittance_color";
shader_names->transmittance_curve = "transmittance_curve";
@@ -349,6 +348,12 @@ void BaseMaterial3D::init_shaders() {
shader_names->texture_names[TEXTURE_DETAIL_ALBEDO] = "texture_detail_albedo";
shader_names->texture_names[TEXTURE_DETAIL_NORMAL] = "texture_detail_normal";
shader_names->texture_names[TEXTURE_ORM] = "texture_orm";
+
+ shader_names->alpha_scissor_threshold = "alpha_scissor_threshold";
+ shader_names->alpha_hash_scale = "alpha_hash_scale";
+
+ shader_names->alpha_antialiasing_edge = "alpha_antialiasing_edge";
+ shader_names->albedo_texture_size = "albedo_texture_size";
}
Ref<StandardMaterial3D> BaseMaterial3D::materials_for_2d[BaseMaterial3D::MAX_MATERIALS_FOR_2D];
@@ -435,6 +440,8 @@ void BaseMaterial3D::_update_shader() {
case BLEND_MODE_MUL:
code += "blend_mul";
break;
+ case BLEND_MODE_MAX:
+ break; // Internal value, skip.
}
DepthDrawMode ddm = depth_draw_mode;
@@ -452,10 +459,8 @@ void BaseMaterial3D::_update_shader() {
case DEPTH_DRAW_DISABLED:
code += ",depth_draw_never";
break;
- }
-
- if (transparency == TRANSPARENCY_ALPHA_DEPTH_PRE_PASS) {
- code += ",depth_prepass_alpha";
+ case DEPTH_DRAW_MAX:
+ break; // Internal value, skip.
}
switch (cull_mode) {
@@ -468,6 +473,8 @@ void BaseMaterial3D::_update_shader() {
case CULL_DISABLED:
code += ",cull_disabled";
break;
+ case CULL_MAX:
+ break; // Internal value, skip.
}
switch (diffuse_mode) {
case DIFFUSE_BURLEY:
@@ -485,6 +492,8 @@ void BaseMaterial3D::_update_shader() {
case DIFFUSE_TOON:
code += ",diffuse_toon";
break;
+ case DIFFUSE_MAX:
+ break; // Internal value, skip.
}
switch (specular_mode) {
case SPECULAR_SCHLICK_GGX:
@@ -502,6 +511,8 @@ void BaseMaterial3D::_update_shader() {
case SPECULAR_DISABLED:
code += ",specular_disabled";
break;
+ case SPECULAR_MAX:
+ break; // Internal value, skip.
}
if (features[FEATURE_SUBSURFACE_SCATTERING] && flags[FLAG_SUBSURFACE_MODE_SKIN]) {
code += ",sss_mode_skin";
@@ -525,6 +536,23 @@ void BaseMaterial3D::_update_shader() {
if (flags[FLAG_USE_SHADOW_TO_OPACITY]) {
code += ",shadow_to_opacity";
}
+
+ if (transparency == TRANSPARENCY_ALPHA_DEPTH_PRE_PASS) {
+ code += ",depth_prepass_alpha";
+ }
+
+ // Although its technically possible to do alpha antialiasing without using alpha hash or alpha scissor,
+ // it is restricted in the base material because it has no use, and abusing it with regular Alpha blending can
+ // saturate the MSAA mask
+ if (transparency == TRANSPARENCY_ALPHA_HASH || transparency == TRANSPARENCY_ALPHA_SCISSOR) {
+ // alpha antialiasing is only useful in ALPHA_HASH or ALPHA_SCISSOR
+ if (alpha_antialiasing_mode == ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE) {
+ code += ",alpha_to_coverage";
+ } else if (alpha_antialiasing_mode == ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE_AND_TO_ONE) {
+ code += ",alpha_to_coverage_and_one";
+ }
+ }
+
code += ";\n";
code += "uniform vec4 albedo : hint_color;\n";
@@ -541,8 +569,18 @@ void BaseMaterial3D::_update_shader() {
code += "uniform float distance_fade_max;\n";
}
+ // alpha scissor is only valid if there is not antialiasing edge
+ // alpha hash is valid whenever, but not with alpha scissor
if (transparency == TRANSPARENCY_ALPHA_SCISSOR) {
code += "uniform float alpha_scissor_threshold;\n";
+ } else if (transparency == TRANSPARENCY_ALPHA_HASH) {
+ code += "uniform float alpha_hash_scale;\n";
+ }
+ // if alpha antialiasing isn't off, add in the edge variable
+ if (alpha_antialiasing_mode != ALPHA_ANTIALIASING_OFF &&
+ (transparency == TRANSPARENCY_ALPHA_SCISSOR || transparency == TRANSPARENCY_ALPHA_HASH)) {
+ code += "uniform float alpha_antialiasing_edge;\n";
+ code += "uniform ivec2 albedo_texture_size;\n";
}
code += "uniform float point_size : hint_range(0,128);\n";
@@ -568,6 +606,8 @@ void BaseMaterial3D::_update_shader() {
case TEXTURE_CHANNEL_GRAYSCALE: {
code += "uniform sampler2D texture_roughness : hint_roughness_gray," + texfilter_str + ";\n";
} break;
+ case TEXTURE_CHANNEL_MAX:
+ break; // Internal value, skip.
}
code += "uniform float specular;\n";
@@ -731,6 +771,8 @@ void BaseMaterial3D::_update_shader() {
code += "\tUV /= vec2(h_frames, v_frames);\n";
code += "\tUV += vec2(mod(particle_frame, h_frames) / h_frames, floor(particle_frame / h_frames) / v_frames);\n";
} break;
+ case BILLBOARD_MAX:
+ break; // Internal value, skip.
}
if (flags[FLAG_FIXED_SIZE]) {
@@ -903,6 +945,8 @@ void BaseMaterial3D::_update_shader() {
case TEXTURE_CHANNEL_GRAYSCALE: {
code += "\tvec4 roughness_texture_channel = vec4(0.333333,0.333333,0.333333,0.0);\n";
} break;
+ case TEXTURE_CHANNEL_MAX:
+ break; // Internal value, skip.
}
if (flags[FLAG_UV1_USE_TRIPLANAR]) {
@@ -970,10 +1014,17 @@ void BaseMaterial3D::_update_shader() {
code += "\tALBEDO *= 1.0 - ref_amount;\n";
code += "\tALPHA = 1.0;\n";
- } else if (transparency == TRANSPARENCY_ALPHA || transparency == TRANSPARENCY_ALPHA_DEPTH_PRE_PASS || flags[FLAG_USE_SHADOW_TO_OPACITY] || (distance_fade == DISTANCE_FADE_PIXEL_ALPHA) || proximity_fade_enabled) {
+ } else if (transparency != TRANSPARENCY_DISABLED || flags[FLAG_USE_SHADOW_TO_OPACITY] || (distance_fade == DISTANCE_FADE_PIXEL_ALPHA) || proximity_fade_enabled) {
code += "\tALPHA = albedo.a * albedo_tex.a;\n";
+ }
+ if (transparency == TRANSPARENCY_ALPHA_HASH) {
+ code += "\tALPHA_HASH_SCALE = alpha_hash_scale;\n";
} else if (transparency == TRANSPARENCY_ALPHA_SCISSOR) {
- code += "\tif (albedo.a * albedo_tex.a < alpha_scissor_threshold) discard;\n";
+ code += "\tALPHA_SCISSOR_THRESHOLD = alpha_scissor_threshold;\n";
+ }
+ if (alpha_antialiasing_mode != ALPHA_ANTIALIASING_OFF && (transparency == TRANSPARENCY_ALPHA_HASH || transparency == TRANSPARENCY_ALPHA_SCISSOR)) {
+ code += "\tALPHA_ANTIALIASING_EDGE = alpha_antialiasing_edge;\n";
+ code += "\tALPHA_TEXTURE_COORDINATE = UV * vec2(albedo_texture_size);\n";
}
if (proximity_fade_enabled) {
@@ -1143,6 +1194,8 @@ void BaseMaterial3D::_update_shader() {
case BLEND_MODE_MUL: {
code += "\tvec3 detail = mix(ALBEDO.rgb,ALBEDO.rgb*detail_tex.rgb,detail_tex.a);\n";
} break;
+ case BLEND_MODE_MAX:
+ break; // Internal value, skip.
}
code += "\tvec3 detail_norm = mix(NORMALMAP,detail_norm_tex.rgb,detail_tex.a);\n";
@@ -1424,6 +1477,20 @@ BaseMaterial3D::Transparency BaseMaterial3D::get_transparency() const {
return transparency;
}
+void BaseMaterial3D::set_alpha_antialiasing(AlphaAntiAliasing p_alpha_aa) {
+ if (alpha_antialiasing_mode == p_alpha_aa) {
+ return;
+ }
+
+ alpha_antialiasing_mode = p_alpha_aa;
+ _queue_shader_change();
+ _change_notify();
+}
+
+BaseMaterial3D::AlphaAntiAliasing BaseMaterial3D::get_alpha_antialiasing() const {
+ return alpha_antialiasing_mode;
+}
+
void BaseMaterial3D::set_shading_mode(ShadingMode p_shading_mode) {
if (shading_mode == p_shading_mode) {
return;
@@ -1530,6 +1597,10 @@ void BaseMaterial3D::set_texture(TextureParam p_param, const Ref<Texture2D> &p_t
textures[p_param] = p_texture;
RID rid = p_texture.is_valid() ? p_texture->get_rid() : RID();
RS::get_singleton()->material_set_param(_get_material(), shader_names->texture_names[p_param], rid);
+ if (p_texture.is_valid() && p_param == TEXTURE_ALBEDO) {
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->albedo_texture_size,
+ Vector2i(p_texture->get_width(), p_texture->get_height()));
+ }
_change_notify();
_queue_shader_change();
}
@@ -1605,10 +1676,34 @@ void BaseMaterial3D::_validate_property(PropertyInfo &property) const {
property.usage = 0;
}
+ // you can only enable anti-aliasing (in mataerials) on alpha scissor and alpha hash
+ const bool can_select_aa = (transparency == TRANSPARENCY_ALPHA_SCISSOR || transparency == TRANSPARENCY_ALPHA_HASH);
+ // alpha anti aliasiasing is only enabled when you can select aa
+ const bool alpha_aa_enabled = (alpha_antialiasing_mode != ALPHA_ANTIALIASING_OFF) && can_select_aa;
+
+ // alpha scissor slider isn't needed when alpha antialiasing is enabled
if (property.name == "alpha_scissor_threshold" && transparency != TRANSPARENCY_ALPHA_SCISSOR) {
property.usage = 0;
}
+ // alpha hash scale slider is only needed if transparency is alpha hash
+ if (property.name == "alpha_hash_scale" && transparency != TRANSPARENCY_ALPHA_HASH) {
+ property.usage = 0;
+ }
+
+ if (property.name == "alpha_antialiasing_mode" && !can_select_aa) {
+ property.usage = 0;
+ }
+
+ // we cant choose an antialiasing mode if alpha isnt possible
+ if (property.name == "alpha_antialiasing_edge" && !alpha_aa_enabled) {
+ property.usage = 0;
+ }
+
+ if (property.name == "blend_mode" && alpha_aa_enabled) {
+ property.usage = 0;
+ }
+
if ((property.name == "heightmap_min_layers" || property.name == "heightmap_max_layers") && !deep_parallax) {
property.usage = 0;
}
@@ -1845,6 +1940,24 @@ float BaseMaterial3D::get_alpha_scissor_threshold() const {
return alpha_scissor_threshold;
}
+void BaseMaterial3D::set_alpha_hash_scale(float p_scale) {
+ alpha_hash_scale = p_scale;
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->alpha_hash_scale, p_scale);
+}
+
+float BaseMaterial3D::get_alpha_hash_scale() const {
+ return alpha_hash_scale;
+}
+
+void BaseMaterial3D::set_alpha_antialiasing_edge(float p_edge) {
+ alpha_antialiasing_edge = p_edge;
+ RS::get_singleton()->material_set_param(_get_material(), shader_names->alpha_antialiasing_edge, p_edge);
+}
+
+float BaseMaterial3D::get_alpha_antialiasing_edge() const {
+ return alpha_antialiasing_edge;
+}
+
void BaseMaterial3D::set_grow(float p_grow) {
grow = p_grow;
RS::get_singleton()->material_set_param(_get_material(), shader_names->grow, p_grow);
@@ -2033,6 +2146,12 @@ void BaseMaterial3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_transparency", "transparency"), &BaseMaterial3D::set_transparency);
ClassDB::bind_method(D_METHOD("get_transparency"), &BaseMaterial3D::get_transparency);
+ ClassDB::bind_method(D_METHOD("set_alpha_antialiasing", "alpha_aa"), &BaseMaterial3D::set_alpha_antialiasing);
+ ClassDB::bind_method(D_METHOD("get_alpha_antialiasing"), &BaseMaterial3D::get_alpha_antialiasing);
+
+ ClassDB::bind_method(D_METHOD("set_alpha_antialiasing_edge", "edge"), &BaseMaterial3D::set_alpha_antialiasing_edge);
+ ClassDB::bind_method(D_METHOD("get_alpha_antialiasing_edge"), &BaseMaterial3D::get_alpha_antialiasing_edge);
+
ClassDB::bind_method(D_METHOD("set_shading_mode", "shading_mode"), &BaseMaterial3D::set_shading_mode);
ClassDB::bind_method(D_METHOD("get_shading_mode"), &BaseMaterial3D::get_shading_mode);
@@ -2186,6 +2305,9 @@ void BaseMaterial3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_alpha_scissor_threshold", "threshold"), &BaseMaterial3D::set_alpha_scissor_threshold);
ClassDB::bind_method(D_METHOD("get_alpha_scissor_threshold"), &BaseMaterial3D::get_alpha_scissor_threshold);
+ ClassDB::bind_method(D_METHOD("set_alpha_hash_scale", "threshold"), &BaseMaterial3D::set_alpha_hash_scale);
+ ClassDB::bind_method(D_METHOD("get_alpha_hash_scale"), &BaseMaterial3D::get_alpha_hash_scale);
+
ClassDB::bind_method(D_METHOD("set_grow_enabled", "enable"), &BaseMaterial3D::set_grow_enabled);
ClassDB::bind_method(D_METHOD("is_grow_enabled"), &BaseMaterial3D::is_grow_enabled);
@@ -2217,8 +2339,11 @@ void BaseMaterial3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_distance_fade_min_distance"), &BaseMaterial3D::get_distance_fade_min_distance);
ADD_GROUP("Transparency", "");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "transparency", PROPERTY_HINT_ENUM, "Disabled,Alpha,AlphaScissor,DepthPrePass"), "set_transparency", "get_transparency");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "transparency", PROPERTY_HINT_ENUM, "Disabled,Alpha,Alpha Scissor,Alpha Hash,Depth PrePass"), "set_transparency", "get_transparency");
ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "alpha_scissor_threshold", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_alpha_scissor_threshold", "get_alpha_scissor_threshold");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "alpha_hash_scale", PROPERTY_HINT_RANGE, "0,2,0.01"), "set_alpha_hash_scale", "get_alpha_hash_scale");
+ ADD_PROPERTY(PropertyInfo(Variant::INT, "alpha_antialiasing_mode", PROPERTY_HINT_ENUM, "Disabled,Alpha Edge Blend,Alpha Edge Clip"), "set_alpha_antialiasing", "get_alpha_antialiasing");
+ ADD_PROPERTY(PropertyInfo(Variant::FLOAT, "alpha_antialiasing_edge", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_alpha_antialiasing_edge", "get_alpha_antialiasing_edge");
ADD_PROPERTY(PropertyInfo(Variant::INT, "blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), "set_blend_mode", "get_blend_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "cull_mode", PROPERTY_HINT_ENUM, "Back,Front,Disabled"), "set_cull_mode", "get_cull_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "depth_draw_mode", PROPERTY_HINT_ENUM, "Opaque Only,Always,Never"), "set_depth_draw_mode", "get_depth_draw_mode");
@@ -2414,6 +2539,7 @@ void BaseMaterial3D::_bind_methods() {
BIND_ENUM_CONSTANT(TRANSPARENCY_DISABLED);
BIND_ENUM_CONSTANT(TRANSPARENCY_ALPHA);
BIND_ENUM_CONSTANT(TRANSPARENCY_ALPHA_SCISSOR);
+ BIND_ENUM_CONSTANT(TRANSPARENCY_ALPHA_HASH);
BIND_ENUM_CONSTANT(TRANSPARENCY_ALPHA_DEPTH_PRE_PASS);
BIND_ENUM_CONSTANT(TRANSPARENCY_MAX);
@@ -2441,6 +2567,10 @@ void BaseMaterial3D::_bind_methods() {
BIND_ENUM_CONSTANT(BLEND_MODE_SUB);
BIND_ENUM_CONSTANT(BLEND_MODE_MUL);
+ BIND_ENUM_CONSTANT(ALPHA_ANTIALIASING_OFF);
+ BIND_ENUM_CONSTANT(ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE);
+ BIND_ENUM_CONSTANT(ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE_AND_TO_ONE);
+
BIND_ENUM_CONSTANT(DEPTH_DRAW_OPAQUE_ONLY);
BIND_ENUM_CONSTANT(DEPTH_DRAW_ALWAYS);
BIND_ENUM_CONSTANT(DEPTH_DRAW_DISABLED);
@@ -2506,8 +2636,9 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) :
element(this) {
orm = p_orm;
// Initialize to the same values as the shader
- transparency = TRANSPARENCY_DISABLED;
shading_mode = SHADING_MODE_PER_PIXEL;
+ transparency = TRANSPARENCY_DISABLED;
+ alpha_antialiasing_mode = ALPHA_ANTIALIASING_OFF;
set_albedo(Color(1.0, 1.0, 1.0, 1.0));
set_specular(0.5);
set_roughness(1.0);
@@ -2539,9 +2670,14 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) :
set_particles_anim_h_frames(1);
set_particles_anim_v_frames(1);
set_particles_anim_loop(false);
- set_alpha_scissor_threshold(0.98);
emission_op = EMISSION_OP_ADD;
+ set_transparency(TRANSPARENCY_DISABLED);
+ set_alpha_antialiasing(ALPHA_ANTIALIASING_OFF);
+ set_alpha_scissor_threshold(0.05);
+ set_alpha_hash_scale(1.0);
+ set_alpha_antialiasing_edge(0.3);
+
proximity_fade_enabled = false;
distance_fade = DISTANCE_FADE_DISABLED;
set_proximity_fade_distance(1);
@@ -2582,10 +2718,8 @@ BaseMaterial3D::BaseMaterial3D(bool p_orm) :
features[i] = false;
}
- current_key.key0 = 0;
- current_key.key1 = 0;
- current_key.invalid_key = 1;
texture_filter = TEXTURE_FILTER_LINEAR_WITH_MIPMAPS;
+
_queue_shader_change();
}
@@ -2633,6 +2767,12 @@ bool StandardMaterial3D::_set(const StringName &p_name, const Variant &p_value)
set_transparency(TRANSPARENCY_ALPHA_SCISSOR);
}
return true;
+ } else if (p_name == "params_use_alpha_hash") {
+ bool use_hash = p_value;
+ if (use_hash) {
+ set_transparency(TRANSPARENCY_ALPHA_HASH);
+ }
+ return true;
} else if (p_name == "params_depth_draw_mode") {
int mode = p_value;
if (mode == 3) {
@@ -2667,6 +2807,8 @@ bool StandardMaterial3D::_set(const StringName &p_name, const Variant &p_value)
{ "params_grow", "grow" },
{ "params_grow_amount", "grow_amount" },
{ "params_alpha_scissor_threshold", "alpha_scissor_threshold" },
+ { "params_alpha_hash_scale", "alpha_hash_scale" },
+ { "params_alpha_antialiasing_edge", "alpha_antialiasing_edge" },
{ "depth_scale", "heightmap_scale" },
{ "depth_deep_parallax", "heightmap_deep_parallax" },
diff --git a/scene/resources/material.h b/scene/resources/material.h
index b5bdd77eb5..caf28eea18 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -31,8 +31,8 @@
#ifndef MATERIAL_H
#define MATERIAL_H
-#include "core/resource.h"
-#include "core/self_list.h"
+#include "core/io/resource.h"
+#include "core/templates/self_list.h"
#include "scene/resources/shader.h"
#include "scene/resources/texture.h"
#include "servers/rendering/shader_language.h"
@@ -145,17 +145,26 @@ public:
enum DetailUV {
DETAIL_UV_1,
- DETAIL_UV_2
+ DETAIL_UV_2,
+ DETAIL_UV_MAX
};
enum Transparency {
TRANSPARENCY_DISABLED,
TRANSPARENCY_ALPHA,
TRANSPARENCY_ALPHA_SCISSOR,
+ TRANSPARENCY_ALPHA_HASH,
TRANSPARENCY_ALPHA_DEPTH_PRE_PASS,
TRANSPARENCY_MAX,
};
+ enum AlphaAntiAliasing {
+ ALPHA_ANTIALIASING_OFF,
+ ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE,
+ ALPHA_ANTIALIASING_ALPHA_TO_COVERAGE_AND_TO_ONE,
+ ALPHA_ANTIALIASING_MAX
+ };
+
enum ShadingMode {
SHADING_MODE_UNSHADED,
SHADING_MODE_PER_PIXEL,
@@ -184,18 +193,21 @@ public:
BLEND_MODE_ADD,
BLEND_MODE_SUB,
BLEND_MODE_MUL,
+ BLEND_MODE_MAX
};
enum DepthDrawMode {
DEPTH_DRAW_OPAQUE_ONLY,
DEPTH_DRAW_ALWAYS,
DEPTH_DRAW_DISABLED,
+ DEPTH_DRAW_MAX
};
enum CullMode {
CULL_BACK,
CULL_FRONT,
- CULL_DISABLED
+ CULL_DISABLED,
+ CULL_MAX
};
enum Flags {
@@ -227,6 +239,7 @@ public:
DIFFUSE_LAMBERT_WRAP,
DIFFUSE_OREN_NAYAR,
DIFFUSE_TOON,
+ DIFFUSE_MAX
};
enum SpecularMode {
@@ -235,6 +248,7 @@ public:
SPECULAR_PHONG,
SPECULAR_TOON,
SPECULAR_DISABLED,
+ SPECULAR_MAX
};
enum BillboardMode {
@@ -242,6 +256,7 @@ public:
BILLBOARD_ENABLED,
BILLBOARD_FIXED_Y,
BILLBOARD_PARTICLES,
+ BILLBOARD_MAX
};
enum TextureChannel {
@@ -249,12 +264,14 @@ public:
TEXTURE_CHANNEL_GREEN,
TEXTURE_CHANNEL_BLUE,
TEXTURE_CHANNEL_ALPHA,
- TEXTURE_CHANNEL_GRAYSCALE
+ TEXTURE_CHANNEL_GRAYSCALE,
+ TEXTURE_CHANNEL_MAX
};
enum EmissionOperator {
EMISSION_OP_ADD,
- EMISSION_OP_MULTIPLY
+ EMISSION_OP_MULTIPLY,
+ EMISSION_OP_MAX
};
enum DistanceFadeMode {
@@ -262,43 +279,47 @@ public:
DISTANCE_FADE_PIXEL_ALPHA,
DISTANCE_FADE_PIXEL_DITHER,
DISTANCE_FADE_OBJECT_DITHER,
+ DISTANCE_FADE_MAX
};
private:
- union MaterialKey {
- struct {
- uint64_t feature_mask : FEATURE_MAX;
- uint64_t detail_uv : 1;
- uint64_t blend_mode : 2;
- uint64_t depth_draw_mode : 2;
- uint64_t cull_mode : 2;
- uint64_t flags : FLAG_MAX;
- uint64_t detail_blend_mode : 2;
- uint64_t diffuse_mode : 3;
- uint64_t specular_mode : 3;
- uint64_t invalid_key : 1;
- uint64_t deep_parallax : 1;
- uint64_t billboard_mode : 2;
- uint64_t grow : 1;
- uint64_t proximity_fade : 1;
- uint64_t distance_fade : 2;
- uint64_t emission_op : 1;
- uint64_t texture_filter : 3;
- uint64_t transparency : 2;
- uint64_t shading_mode : 2;
- uint64_t roughness_channel : 3;
- };
-
- struct {
- uint64_t key0;
- uint64_t key1;
- };
+ struct MaterialKey {
+ // enum values
+ uint64_t texture_filter : get_num_bits(TEXTURE_FILTER_MAX - 1);
+ uint64_t detail_uv : get_num_bits(DETAIL_UV_MAX - 1);
+ uint64_t transparency : get_num_bits(TRANSPARENCY_MAX - 1);
+ uint64_t alpha_antialiasing_mode : get_num_bits(ALPHA_ANTIALIASING_MAX - 1);
+ uint64_t shading_mode : get_num_bits(SHADING_MODE_MAX - 1);
+ uint64_t blend_mode : get_num_bits(BLEND_MODE_MAX - 1);
+ uint64_t depth_draw_mode : get_num_bits(DEPTH_DRAW_MAX - 1);
+ uint64_t cull_mode : get_num_bits(CULL_MAX - 1);
+ uint64_t diffuse_mode : get_num_bits(DIFFUSE_MAX - 1);
+ uint64_t specular_mode : get_num_bits(SPECULAR_MAX - 1);
+ uint64_t billboard_mode : get_num_bits(BILLBOARD_MAX - 1);
+ uint64_t detail_blend_mode : get_num_bits(BLEND_MODE_MAX - 1);
+ uint64_t roughness_channel : get_num_bits(TEXTURE_CHANNEL_MAX - 1);
+ uint64_t emission_op : get_num_bits(EMISSION_OP_MAX - 1);
+ uint64_t distance_fade : get_num_bits(DISTANCE_FADE_MAX - 1);
+
+ // flag bitfield
+ uint64_t feature_mask : FEATURE_MAX - 1;
+ uint64_t flags : FLAG_MAX - 1;
+
+ // booleans
+ uint64_t deep_parallax : 1;
+ uint64_t grow : 1;
+ uint64_t proximity_fade : 1;
+
+ MaterialKey() {
+ memset(this, 0, sizeof(MaterialKey));
+ }
bool operator==(const MaterialKey &p_key) const {
- return (key0 == p_key.key0) && (key1 == p_key.key1);
+ return memcmp(this, &p_key, sizeof(MaterialKey)) == 0;
}
+
bool operator<(const MaterialKey &p_key) const {
- return (key0 == p_key.key0) ? (key1 < p_key.key1) : (key0 < p_key.key0);
+ return memcmp(this, &p_key, sizeof(MaterialKey)) < 0;
}
};
@@ -313,13 +334,7 @@ private:
_FORCE_INLINE_ MaterialKey _compute_key() const {
MaterialKey mk;
- mk.key0 = 0;
- mk.key1 = 0;
- for (int i = 0; i < FEATURE_MAX; i++) {
- if (features[i]) {
- mk.feature_mask |= ((uint64_t)1 << i);
- }
- }
+
mk.detail_uv = detail_uv;
mk.blend_mode = blend_mode;
mk.depth_draw_mode = depth_draw_mode;
@@ -328,20 +343,28 @@ private:
mk.transparency = transparency;
mk.shading_mode = shading_mode;
mk.roughness_channel = roughness_texture_channel;
- for (int i = 0; i < FLAG_MAX; i++) {
- if (flags[i]) {
- mk.flags |= ((uint64_t)1 << i);
- }
- }
mk.detail_blend_mode = detail_blend_mode;
mk.diffuse_mode = diffuse_mode;
mk.specular_mode = specular_mode;
mk.billboard_mode = billboard_mode;
- mk.deep_parallax = deep_parallax ? 1 : 0;
+ mk.deep_parallax = deep_parallax;
mk.grow = grow_enabled;
mk.proximity_fade = proximity_fade_enabled;
mk.distance_fade = distance_fade;
mk.emission_op = emission_op;
+ mk.alpha_antialiasing_mode = alpha_antialiasing_mode;
+
+ for (int i = 0; i < FEATURE_MAX; i++) {
+ if (features[i]) {
+ mk.feature_mask |= ((uint64_t)1 << i);
+ }
+ }
+
+ for (int i = 0; i < FLAG_MAX; i++) {
+ if (flags[i]) {
+ mk.flags |= ((uint64_t)1 << i);
+ }
+ }
return mk;
}
@@ -392,9 +415,14 @@ private:
StringName rim_texture_channel;
StringName heightmap_texture_channel;
StringName refraction_texture_channel;
- StringName alpha_scissor_threshold;
StringName texture_names[TEXTURE_MAX];
+
+ StringName alpha_scissor_threshold;
+ StringName alpha_hash_scale;
+
+ StringName alpha_antialiasing_edge;
+ StringName albedo_texture_size;
};
static Mutex material_mutex;
@@ -433,6 +461,8 @@ private:
float refraction;
float point_size;
float alpha_scissor_threshold;
+ float alpha_hash_scale;
+ float alpha_antialiasing_edge;
bool grow_enabled;
float ao_light_affect;
float grow;
@@ -482,6 +512,8 @@ private:
TextureChannel ao_texture_channel;
TextureChannel refraction_texture_channel;
+ AlphaAntiAliasing alpha_antialiasing_mode;
+
bool features[FEATURE_MAX];
Ref<Texture2D> textures[TEXTURE_MAX];
@@ -584,6 +616,12 @@ public:
void set_transparency(Transparency p_transparency);
Transparency get_transparency() const;
+ void set_alpha_antialiasing(AlphaAntiAliasing p_alpha_aa);
+ AlphaAntiAliasing get_alpha_antialiasing() const;
+
+ void set_alpha_antialiasing_edge(float p_edge);
+ float get_alpha_antialiasing_edge() const;
+
void set_shading_mode(ShadingMode p_shading_mode);
ShadingMode get_shading_mode() const;
@@ -660,6 +698,9 @@ public:
void set_alpha_scissor_threshold(float p_threshold);
float get_alpha_scissor_threshold() const;
+ void set_alpha_hash_scale(float p_scale);
+ float get_alpha_hash_scale() const;
+
void set_on_top_of_alpha();
void set_proximity_fade(bool p_enable);
@@ -707,6 +748,7 @@ VARIANT_ENUM_CAST(BaseMaterial3D::TextureParam)
VARIANT_ENUM_CAST(BaseMaterial3D::TextureFilter)
VARIANT_ENUM_CAST(BaseMaterial3D::ShadingMode)
VARIANT_ENUM_CAST(BaseMaterial3D::Transparency)
+VARIANT_ENUM_CAST(BaseMaterial3D::AlphaAntiAliasing)
VARIANT_ENUM_CAST(BaseMaterial3D::DetailUV)
VARIANT_ENUM_CAST(BaseMaterial3D::Feature)
VARIANT_ENUM_CAST(BaseMaterial3D::BlendMode)
diff --git a/scene/resources/mesh.cpp b/scene/resources/mesh.cpp
index e9606e03e6..060846d5b6 100644
--- a/scene/resources/mesh.cpp
+++ b/scene/resources/mesh.cpp
@@ -30,7 +30,7 @@
#include "mesh.h"
-#include "core/pair.h"
+#include "core/templates/pair.h"
#include "scene/resources/concave_polygon_shape_3d.h"
#include "scene/resources/convex_polygon_shape_3d.h"
#include "surface_tool.h"
diff --git a/scene/resources/mesh.h b/scene/resources/mesh.h
index b0a30a5627..81c18eea2d 100644
--- a/scene/resources/mesh.h
+++ b/scene/resources/mesh.h
@@ -31,9 +31,9 @@
#ifndef MESH_H
#define MESH_H
+#include "core/io/resource.h"
#include "core/math/face3.h"
#include "core/math/triangle_mesh.h"
-#include "core/resource.h"
#include "scene/resources/material.h"
#include "scene/resources/shape_3d.h"
#include "servers/rendering_server.h"
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index 450e2c16e3..0d5fb3005b 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -31,8 +31,8 @@
#ifndef MESH_LIBRARY_H
#define MESH_LIBRARY_H
-#include "core/map.h"
-#include "core/resource.h"
+#include "core/io/resource.h"
+#include "core/templates/map.h"
#include "mesh.h"
#include "scene/3d/navigation_region_3d.h"
#include "shape_3d.h"
diff --git a/scene/resources/packed_scene.cpp b/scene/resources/packed_scene.cpp
index 5e8bfd9387..5ce253f970 100644
--- a/scene/resources/packed_scene.cpp
+++ b/scene/resources/packed_scene.cpp
@@ -30,10 +30,10 @@
#include "packed_scene.h"
+#include "core/config/engine.h"
+#include "core/config/project_settings.h"
#include "core/core_string_names.h"
-#include "core/engine.h"
#include "core/io/resource_loader.h"
-#include "core/project_settings.h"
#include "scene/2d/node_2d.h"
#include "scene/3d/node_3d.h"
#include "scene/gui/control.h"
diff --git a/scene/resources/packed_scene.h b/scene/resources/packed_scene.h
index 004758afa5..b8b3f84ecc 100644
--- a/scene/resources/packed_scene.h
+++ b/scene/resources/packed_scene.h
@@ -31,7 +31,7 @@
#ifndef PACKED_SCENE_H
#define PACKED_SCENE_H
-#include "core/resource.h"
+#include "core/io/resource.h"
#include "scene/main/node.h"
class SceneState : public Reference {
diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h
index 7aca708889..12fa53ef29 100644
--- a/scene/resources/particles_material.h
+++ b/scene/resources/particles_material.h
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "core/rid.h"
+#include "core/templates/rid.h"
#include "scene/resources/material.h"
#ifndef PARTICLES_MATERIAL_H
diff --git a/scene/resources/physics_material.h b/scene/resources/physics_material.h
index 34aa7066df..e9222ffa1b 100644
--- a/scene/resources/physics_material.h
+++ b/scene/resources/physics_material.h
@@ -31,7 +31,7 @@
#ifndef PHYSICS_MATERIAL_H
#define PHYSICS_MATERIAL_H
-#include "core/resource.h"
+#include "core/io/resource.h"
#include "servers/physics_server_3d.h"
class PhysicsMaterial : public Resource {
diff --git a/scene/resources/polygon_path_finder.h b/scene/resources/polygon_path_finder.h
index baee4dc20d..44a97b4294 100644
--- a/scene/resources/polygon_path_finder.h
+++ b/scene/resources/polygon_path_finder.h
@@ -31,7 +31,7 @@
#ifndef POLYGON_PATH_FINDER_H
#define POLYGON_PATH_FINDER_H
-#include "core/resource.h"
+#include "core/io/resource.h"
class PolygonPathFinder : public Resource {
GDCLASS(PolygonPathFinder, Resource);
diff --git a/scene/resources/resource_format_text.cpp b/scene/resources/resource_format_text.cpp
index ba39593690..1d5f29ab14 100644
--- a/scene/resources/resource_format_text.cpp
+++ b/scene/resources/resource_format_text.cpp
@@ -30,9 +30,9 @@
#include "resource_format_text.h"
+#include "core/config/project_settings.h"
#include "core/io/resource_format_binary.h"
#include "core/os/dir_access.h"
-#include "core/project_settings.h"
#include "core/version.h"
//version 2: changed names for basis, aabb, Vectors, etc.
diff --git a/scene/resources/resource_format_text.h b/scene/resources/resource_format_text.h
index cf522c9364..ca7b0b021f 100644
--- a/scene/resources/resource_format_text.h
+++ b/scene/resources/resource_format_text.h
@@ -34,7 +34,7 @@
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
#include "core/os/file_access.h"
-#include "core/variant_parser.h"
+#include "core/variant/variant_parser.h"
#include "scene/resources/packed_scene.h"
class ResourceLoaderText {
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 7dcec7811a..f2ea582ff0 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -31,9 +31,9 @@
#ifndef SHADER_H
#define SHADER_H
+#include "core/io/resource.h"
#include "core/io/resource_loader.h"
#include "core/io/resource_saver.h"
-#include "core/resource.h"
#include "scene/resources/texture.h"
class Shader : public Resource {
diff --git a/scene/resources/shape_2d.h b/scene/resources/shape_2d.h
index bb4688a02d..495ffdd38b 100644
--- a/scene/resources/shape_2d.h
+++ b/scene/resources/shape_2d.h
@@ -31,7 +31,7 @@
#ifndef SHAPE_2D_H
#define SHAPE_2D_H
-#include "core/resource.h"
+#include "core/io/resource.h"
class Shape2D : public Resource {
GDCLASS(Shape2D, Resource);
diff --git a/scene/resources/shape_3d.h b/scene/resources/shape_3d.h
index eb9607e3a6..5a9c2e3b9c 100644
--- a/scene/resources/shape_3d.h
+++ b/scene/resources/shape_3d.h
@@ -31,7 +31,7 @@
#ifndef SHAPE_3D_H
#define SHAPE_3D_H
-#include "core/resource.h"
+#include "core/io/resource.h"
class ArrayMesh;
diff --git a/scene/resources/skin.h b/scene/resources/skin.h
index 57aaf1afd4..e6ed4f1768 100644
--- a/scene/resources/skin.h
+++ b/scene/resources/skin.h
@@ -31,7 +31,7 @@
#ifndef SKIN_H
#define SKIN_H
-#include "core/resource.h"
+#include "core/io/resource.h"
class Skin : public Resource {
GDCLASS(Skin, Resource)
diff --git a/scene/resources/sky_material.h b/scene/resources/sky_material.h
index 5e23020d66..5411994b7d 100644
--- a/scene/resources/sky_material.h
+++ b/scene/resources/sky_material.h
@@ -28,7 +28,7 @@
/* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
/*************************************************************************/
-#include "core/rid.h"
+#include "core/templates/rid.h"
#include "scene/resources/material.h"
#ifndef SKY_MATERIAL_H
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index cdb0ec5111..a8bf44c5c0 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -130,18 +130,6 @@ Ref<Texture2D> StyleBoxTexture::get_texture() const {
return texture;
}
-void StyleBoxTexture::set_normal_map(Ref<Texture2D> p_normal_map) {
- if (normal_map == p_normal_map) {
- return;
- }
- normal_map = p_normal_map;
- emit_changed();
-}
-
-Ref<Texture2D> StyleBoxTexture::get_normal_map() const {
- return normal_map;
-}
-
void StyleBoxTexture::set_margin_size(Margin p_margin, float p_size) {
ERR_FAIL_INDEX((int)p_margin, 4);
@@ -187,12 +175,7 @@ void StyleBoxTexture::draw(RID p_canvas_item, const Rect2 &p_rect) const {
rect.size.x += expand_margin[MARGIN_LEFT] + expand_margin[MARGIN_RIGHT];
rect.size.y += expand_margin[MARGIN_TOP] + expand_margin[MARGIN_BOTTOM];
- RID normal_rid;
- if (normal_map.is_valid()) {
- normal_rid = normal_map->get_rid();
- }
-
- RenderingServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center, modulate, normal_rid);
+ RenderingServer::get_singleton()->canvas_item_add_nine_patch(p_canvas_item, rect, src_rect, texture->get_rid(), Vector2(margin[MARGIN_LEFT], margin[MARGIN_TOP]), Vector2(margin[MARGIN_RIGHT], margin[MARGIN_BOTTOM]), RS::NinePatchAxisMode(axis_h), RS::NinePatchAxisMode(axis_v), draw_center, modulate);
}
void StyleBoxTexture::set_draw_center(bool p_enabled) {
@@ -288,9 +271,6 @@ void StyleBoxTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_texture", "texture"), &StyleBoxTexture::set_texture);
ClassDB::bind_method(D_METHOD("get_texture"), &StyleBoxTexture::get_texture);
- ClassDB::bind_method(D_METHOD("set_normal_map", "normal_map"), &StyleBoxTexture::set_normal_map);
- ClassDB::bind_method(D_METHOD("get_normal_map"), &StyleBoxTexture::get_normal_map);
-
ClassDB::bind_method(D_METHOD("set_margin_size", "margin", "size"), &StyleBoxTexture::set_margin_size);
ClassDB::bind_method(D_METHOD("get_margin_size", "margin"), &StyleBoxTexture::get_margin_size);
@@ -317,7 +297,6 @@ void StyleBoxTexture::_bind_methods() {
ADD_SIGNAL(MethodInfo("texture_changed"));
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");
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region_rect"), "set_region_rect", "get_region_rect");
ADD_GROUP("Margin", "margin_");
ADD_PROPERTYI(PropertyInfo(Variant::FLOAT, "margin_left", PROPERTY_HINT_RANGE, "0,2048,1"), "set_margin_size", "get_margin_size", MARGIN_LEFT);
diff --git a/scene/resources/style_box.h b/scene/resources/style_box.h
index 3d29e3bd0f..a1237776c6 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -31,7 +31,7 @@
#ifndef STYLE_BOX_H
#define STYLE_BOX_H
-#include "core/resource.h"
+#include "core/io/resource.h"
#include "scene/resources/texture.h"
#include "servers/rendering_server.h"
@@ -90,7 +90,6 @@ private:
float margin[4];
Rect2 region_rect;
Ref<Texture2D> texture;
- Ref<Texture2D> normal_map;
bool draw_center;
Color modulate;
AxisStretchMode axis_h;
@@ -115,9 +114,6 @@ public:
void set_texture(Ref<Texture2D> p_texture);
Ref<Texture2D> get_texture() const;
- void set_normal_map(Ref<Texture2D> p_normal_map);
- Ref<Texture2D> get_normal_map() const;
-
void set_draw_center(bool p_enabled);
bool is_draw_center_enabled() const;
virtual Size2 get_center_size() const override;
diff --git a/scene/resources/surface_tool.cpp b/scene/resources/surface_tool.cpp
index 1a2dcc84bb..ff14a5a292 100644
--- a/scene/resources/surface_tool.cpp
+++ b/scene/resources/surface_tool.cpp
@@ -30,8 +30,6 @@
#include "surface_tool.h"
-#include "core/method_bind_ext.gen.inc"
-
#define _VERTEX_SNAP 0.0001
#define EQ_VERTEX_DIST 0.00001
diff --git a/scene/resources/syntax_highlighter.cpp b/scene/resources/syntax_highlighter.cpp
index e7b49892d8..e3e4373fa9 100644
--- a/scene/resources/syntax_highlighter.cpp
+++ b/scene/resources/syntax_highlighter.cpp
@@ -30,7 +30,7 @@
#include "syntax_highlighter.h"
-#include "core/script_language.h"
+#include "core/object/script_language.h"
#include "scene/gui/text_edit.h"
Dictionary SyntaxHighlighter::get_line_syntax_highlighting(int p_line) {
diff --git a/scene/resources/syntax_highlighter.h b/scene/resources/syntax_highlighter.h
index 720227a256..62865920d3 100644
--- a/scene/resources/syntax_highlighter.h
+++ b/scene/resources/syntax_highlighter.h
@@ -31,7 +31,7 @@
#ifndef SYNTAX_HIGHLIGHTER_H
#define SYNTAX_HIGHLIGHTER_H
-#include "core/resource.h"
+#include "core/io/resource.h"
class TextEdit;
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 39237e1a33..39ef6eeafa 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -32,7 +32,6 @@
#include "core/core_string_names.h"
#include "core/io/image_loader.h"
-#include "core/method_bind_ext.gen.inc"
#include "core/os/os.h"
#include "mesh.h"
#include "scene/resources/bit_map.h"
@@ -46,28 +45,21 @@ bool Texture2D::is_pixel_opaque(int p_x, int p_y) const {
return true;
}
-void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+void Texture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose);
}
-void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+void Texture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose);
}
-void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
+void Texture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) const {
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, p_clip_uv);
}
bool Texture2D::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
r_rect = p_rect;
r_src_rect = p_src_rect;
-
return true;
}
@@ -76,9 +68,9 @@ void Texture2D::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_height"), &Texture2D::get_height);
ClassDB::bind_method(D_METHOD("get_size"), &Texture2D::get_size);
ClassDB::bind_method(D_METHOD("has_alpha"), &Texture2D::has_alpha);
- ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT));
- ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT));
- ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "specular_map", "specular_color_shininess", "texture_filter", "texture_repeat", "clip_uv"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(Variant()), DEFVAL(Color(1, 1, 1, 1)), DEFVAL(RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT), DEFVAL(RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false));
+ ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "clip_uv"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(true));
ClassDB::bind_method(D_METHOD("get_data"), &Texture2D::get_data);
ADD_GROUP("", "");
@@ -233,31 +225,25 @@ bool ImageTexture::has_alpha() const {
return (format == Image::FORMAT_LA8 || format == Image::FORMAT_RGBA8);
}
-void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+void ImageTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
if ((w | h) == 0) {
return;
}
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose);
}
-void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
if ((w | h) == 0) {
return;
}
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose);
}
-void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void ImageTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) const {
if ((w | h) == 0) {
return;
}
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, p_clip_uv);
}
bool ImageTexture::is_pixel_opaque(int p_x, int p_y) const {
@@ -652,31 +638,25 @@ RID StreamTexture2D::get_rid() const {
return texture;
}
-void StreamTexture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+void StreamTexture2D::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
if ((w | h) == 0) {
return;
}
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose);
}
-void StreamTexture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+void StreamTexture2D::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
if ((w | h) == 0) {
return;
}
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose);
}
-void StreamTexture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void StreamTexture2D::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) const {
if ((w | h) == 0) {
return;
}
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, p_clip_uv, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, texture, p_src_rect, p_modulate, p_transpose, p_clip_uv);
}
bool StreamTexture2D::has_alpha() const {
@@ -1204,7 +1184,7 @@ void AtlasTexture::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "filter_clip"), "set_filter_clip", "has_filter_clip");
}
-void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
if (!atlas.is_valid()) {
return;
}
@@ -1219,12 +1199,10 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
rc.size.height = atlas->get_height();
}
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat);
+ RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, Rect2(p_pos + margin.position, rc.size), atlas->get_rid(), rc, p_modulate, p_transpose, filter_clip);
}
-void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
if (!atlas.is_valid()) {
return;
}
@@ -1242,12 +1220,10 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
Vector2 scale = p_rect.size / (region.size + margin.size);
Rect2 dr(p_rect.position + margin.position * scale, rc.size * scale);
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat);
+ RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, filter_clip);
}
-void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) const {
//this might not necessarily work well if using a rect, needs to be fixed properly
if (!atlas.is_valid()) {
return;
@@ -1257,9 +1233,7 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
Rect2 src_c;
get_rect_region(p_rect, p_src_rect, dr, src_c);
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose, normal_rid, specular_rid, p_specular_color_shininess, filter_clip, p_texture_filter, p_texture_repeat);
+ RS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), src_c, p_modulate, p_transpose, filter_clip);
}
bool AtlasTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
@@ -1364,7 +1338,7 @@ Ref<Texture2D> MeshTexture::get_base_texture() const {
return base_texture;
}
-void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
if (mesh.is_null() || base_texture.is_null()) {
return;
}
@@ -1374,12 +1348,10 @@ void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_mo
SWAP(xform.elements[0][1], xform.elements[1][0]);
SWAP(xform.elements[0][0], xform.elements[1][1]);
}
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid());
}
-void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
if (mesh.is_null() || base_texture.is_null()) {
return;
}
@@ -1398,12 +1370,10 @@ void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile,
SWAP(xform.elements[0][1], xform.elements[1][0]);
SWAP(xform.elements[0][0], xform.elements[1][1]);
}
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid());
}
-void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) const {
if (mesh.is_null() || base_texture.is_null()) {
return;
}
@@ -1422,9 +1392,7 @@ void MeshTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const
SWAP(xform.elements[0][1], xform.elements[1][0]);
SWAP(xform.elements[0][0], xform.elements[1][1]);
}
- RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
- RID specular_rid = p_specular_map.is_valid() ? p_specular_map->get_rid() : RID();
- RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_rid, specular_rid, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ RenderingServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid());
}
bool MeshTexture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
@@ -1569,14 +1537,14 @@ void LargeTexture::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR | PROPERTY_USAGE_INTERNAL), "_set_data", "_get_data");
}
-void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose) const {
for (int i = 0; i < pieces.size(); i++) {
// TODO
- pieces[i].texture->draw(p_canvas_item, pieces[i].offset + p_pos, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ pieces[i].texture->draw(p_canvas_item, pieces[i].offset + p_pos, p_modulate, p_transpose);
}
}
-void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat) const {
+void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose) const {
//tiling not supported for this
if (size.x == 0 || size.y == 0) {
return;
@@ -1586,11 +1554,11 @@ void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
for (int i = 0; i < pieces.size(); i++) {
// TODO
- pieces[i].texture->draw_rect(p_canvas_item, Rect2(pieces[i].offset * scale + p_rect.position, pieces[i].texture->get_size() * scale), false, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, p_texture_filter, p_texture_repeat);
+ pieces[i].texture->draw_rect(p_canvas_item, Rect2(pieces[i].offset * scale + p_rect.position, pieces[i].texture->get_size() * scale), false, p_modulate, p_transpose);
}
}
-void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map, const Ref<Texture2D> &p_specular_map, const Color &p_specular_color_shininess, RS::CanvasItemTextureFilter p_texture_filter, RS::CanvasItemTextureRepeat p_texture_repeat, bool p_clip_uv) const {
+void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate, bool p_transpose, bool p_clip_uv) const {
//tiling not supported for this
if (p_src_rect.size.x == 0 || p_src_rect.size.y == 0) {
return;
@@ -1609,7 +1577,7 @@ void LargeTexture::draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, cons
target.size *= scale;
target.position = p_rect.position + (p_src_rect.position + rect.position) * scale;
local.position -= rect.position;
- pieces[i].texture->draw_rect_region(p_canvas_item, target, local, p_modulate, p_transpose, p_normal_map, p_specular_map, p_specular_color_shininess, p_texture_filter, p_texture_repeat, false);
+ pieces[i].texture->draw_rect_region(p_canvas_item, target, local, p_modulate, p_transpose, false);
}
}
@@ -1739,12 +1707,6 @@ CurveTexture::~CurveTexture() {
//////////////////
-//setter and getter names for property serialization
-#define COLOR_RAMP_GET_OFFSETS "get_offsets"
-#define COLOR_RAMP_GET_COLORS "get_colors"
-#define COLOR_RAMP_SET_OFFSETS "set_offsets"
-#define COLOR_RAMP_SET_COLORS "set_colors"
-
GradientTexture::GradientTexture() {
update_pending = false;
width = 2048;
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index eebbf4f233..3bc1ca8463 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -31,13 +31,13 @@
#ifndef TEXTURE_H
#define TEXTURE_H
+#include "core/io/resource.h"
#include "core/io/resource_loader.h"
#include "core/math/rect2.h"
#include "core/os/file_access.h"
#include "core/os/mutex.h"
#include "core/os/rw_lock.h"
#include "core/os/thread_safe.h"
-#include "core/resource.h"
#include "scene/resources/curve.h"
#include "scene/resources/gradient.h"
#include "servers/camera_server.h"
@@ -66,9 +66,9 @@ public:
virtual bool has_alpha() const = 0;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, bool p_clip_uv = true) const;
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const;
virtual Ref<Image> get_data() const { return Ref<Image>(); }
@@ -115,9 +115,9 @@ public:
virtual RID get_rid() const override;
bool has_alpha() const override;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const override;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const override;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const override;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const override;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const override;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, bool p_clip_uv = true) const override;
bool is_pixel_opaque(int p_x, int p_y) const override;
@@ -194,9 +194,9 @@ public:
virtual void set_path(const String &p_path, bool p_take_over) override;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const override;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const override;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const override;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const override;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const override;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, bool p_clip_uv = true) const override;
virtual bool has_alpha() const override;
bool is_pixel_opaque(int p_x, int p_y) const override;
@@ -246,9 +246,9 @@ public:
void set_filter_clip(const bool p_enable);
bool has_filter_clip() const;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const override;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const override;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const override;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const override;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const override;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, bool p_clip_uv = true) const override;
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const override;
bool is_pixel_opaque(int p_x, int p_y) const override;
@@ -285,9 +285,9 @@ public:
void set_base_texture(const Ref<Texture2D> &p_texture);
Ref<Texture2D> get_base_texture() const;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const override;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const override;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const override;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const override;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const override;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, bool p_clip_uv = true) const override;
virtual bool get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const override;
bool is_pixel_opaque(int p_x, int p_y) const override;
@@ -331,9 +331,9 @@ public:
Ref<Texture2D> get_piece_texture(int p_idx) const;
Ref<Image> to_image() const;
- virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const override;
- virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT) const override;
- virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, const Ref<Texture2D> &p_normal_map = Ref<Texture2D>(), const Ref<Texture2D> &p_specular_map = Ref<Texture2D>(), const Color &p_specular_color_shininess = Color(1, 1, 1, 1), RS::CanvasItemTextureFilter p_texture_filter = RS::CANVAS_ITEM_TEXTURE_FILTER_DEFAULT, RS::CanvasItemTextureRepeat p_texture_repeat = RS::CANVAS_ITEM_TEXTURE_REPEAT_DEFAULT, bool p_clip_uv = true) const override;
+ virtual void draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const override;
+ virtual void draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile = false, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false) const override;
+ virtual void draw_rect_region(RID p_canvas_item, const Rect2 &p_rect, const Rect2 &p_src_rect, const Color &p_modulate = Color(1, 1, 1), bool p_transpose = false, bool p_clip_uv = true) const override;
bool is_pixel_opaque(int p_x, int p_y) const override;
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 6a85d357ff..a05abbb4c0 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -30,7 +30,7 @@
#include "theme.h"
#include "core/os/file_access.h"
-#include "core/print_string.h"
+#include "core/string/print_string.h"
void Theme::_emit_theme_changed() {
emit_changed();
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index 3c72ddd8a2..5f46ce6303 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -31,8 +31,8 @@
#ifndef THEME_H
#define THEME_H
+#include "core/io/resource.h"
#include "core/io/resource_loader.h"
-#include "core/resource.h"
#include "scene/resources/font.h"
#include "scene/resources/shader.h"
#include "scene/resources/style_box.h"
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index 84b067d1e2..4581763e9c 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -30,9 +30,9 @@
#include "tile_set.h"
-#include "core/array.h"
-#include "core/engine.h"
+#include "core/config/engine.h"
#include "core/math/geometry_2d.h"
+#include "core/variant/array.h"
bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
String n = p_name;
@@ -51,8 +51,6 @@ bool TileSet::_set(const StringName &p_name, const Variant &p_value) {
tile_set_name(id, p_value);
} else if (what == "texture") {
tile_set_texture(id, p_value);
- } else if (what == "normal_map") {
- tile_set_normal_map(id, p_value);
} else if (what == "tex_offset") {
tile_set_texture_offset(id, p_value);
} else if (what == "material") {
@@ -226,8 +224,6 @@ bool TileSet::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = tile_get_name(id);
} else if (what == "texture") {
r_ret = tile_get_texture(id);
- } else if (what == "normal_map") {
- r_ret = tile_get_normal_map(id);
} else if (what == "tex_offset") {
r_ret = tile_get_texture_offset(id);
} else if (what == "material") {
@@ -331,7 +327,6 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
String pre = itos(id) + "/";
p_list->push_back(PropertyInfo(Variant::STRING, pre + "name", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_NOEDITOR));
- p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_NOEDITOR));
p_list->push_back(PropertyInfo(Variant::VECTOR2, pre + "tex_offset", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "material", PROPERTY_HINT_RESOURCE_TYPE, "ShaderMaterial", PROPERTY_USAGE_NOEDITOR));
p_list->push_back(PropertyInfo(Variant::COLOR, pre + "modulate", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR));
@@ -402,17 +397,6 @@ Ref<Texture2D> TileSet::tile_get_texture(int p_id) const {
return tile_map[p_id].texture;
}
-void TileSet::tile_set_normal_map(int p_id, const Ref<Texture2D> &p_normal_map) {
- ERR_FAIL_COND(!tile_map.has(p_id));
- tile_map[p_id].normal_map = p_normal_map;
- emit_changed();
-}
-
-Ref<Texture2D> TileSet::tile_get_normal_map(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture2D>());
- return tile_map[p_id].normal_map;
-}
-
void TileSet::tile_set_material(int p_id, const Ref<ShaderMaterial> &p_material) {
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].material = p_material;
@@ -1128,8 +1112,6 @@ void TileSet::_bind_methods() {
ClassDB::bind_method(D_METHOD("tile_get_name", "id"), &TileSet::tile_get_name);
ClassDB::bind_method(D_METHOD("tile_set_texture", "id", "texture"), &TileSet::tile_set_texture);
ClassDB::bind_method(D_METHOD("tile_get_texture", "id"), &TileSet::tile_get_texture);
- ClassDB::bind_method(D_METHOD("tile_set_normal_map", "id", "normal_map"), &TileSet::tile_set_normal_map);
- ClassDB::bind_method(D_METHOD("tile_get_normal_map", "id"), &TileSet::tile_get_normal_map);
ClassDB::bind_method(D_METHOD("tile_set_material", "id", "material"), &TileSet::tile_set_material);
ClassDB::bind_method(D_METHOD("tile_get_material", "id"), &TileSet::tile_get_material);
ClassDB::bind_method(D_METHOD("tile_set_modulate", "id", "color"), &TileSet::tile_set_modulate);
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index 78f34e46ce..79f1b4aa95 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -31,8 +31,8 @@
#ifndef TILE_SET_H
#define TILE_SET_H
-#include "core/array.h"
-#include "core/resource.h"
+#include "core/io/resource.h"
+#include "core/variant/array.h"
#include "scene/2d/light_occluder_2d.h"
#include "scene/2d/navigation_region_2d.h"
#include "scene/resources/convex_polygon_shape_2d.h"
@@ -106,7 +106,6 @@ private:
struct TileData {
String name;
Ref<Texture2D> texture;
- Ref<Texture2D> normal_map;
Vector2 offset;
Rect2i region;
Vector<ShapeData> shapes_data;
@@ -149,9 +148,6 @@ public:
void tile_set_texture(int p_id, const Ref<Texture2D> &p_texture);
Ref<Texture2D> tile_get_texture(int p_id) const;
- void tile_set_normal_map(int p_id, const Ref<Texture2D> &p_normal_map);
- Ref<Texture2D> tile_get_normal_map(int p_id) const;
-
void tile_set_texture_offset(int p_id, const Vector2 &p_offset);
Vector2 tile_get_texture_offset(int p_id) const;
diff --git a/scene/resources/visual_shader.cpp b/scene/resources/visual_shader.cpp
index 1afc4e114e..141d4b09f5 100644
--- a/scene/resources/visual_shader.cpp
+++ b/scene/resources/visual_shader.cpp
@@ -30,7 +30,7 @@
#include "visual_shader.h"
-#include "core/vmap.h"
+#include "core/templates/vmap.h"
#include "servers/rendering/shader_types.h"
#include "visual_shader_nodes.h"
@@ -992,7 +992,7 @@ bool VisualShader::_set(const StringName &p_name, const Variant &p_value) {
set_node_position(type, id, p_value);
return true;
} else if (what == "size") {
- ((VisualShaderNodeGroupBase *)get_node(type, id).ptr())->set_size(p_value);
+ ((VisualShaderNodeResizableBase *)get_node(type, id).ptr())->set_size(p_value);
return true;
} else if (what == "input_ports") {
((VisualShaderNodeGroupBase *)get_node(type, id).ptr())->set_inputs(p_value);
@@ -1059,7 +1059,7 @@ bool VisualShader::_get(const StringName &p_name, Variant &r_ret) const {
r_ret = get_node_position(type, id);
return true;
} else if (what == "size") {
- r_ret = ((VisualShaderNodeGroupBase *)get_node(type, id).ptr())->get_size();
+ r_ret = ((VisualShaderNodeResizableBase *)get_node(type, id).ptr())->get_size();
return true;
} else if (what == "input_ports") {
r_ret = ((VisualShaderNodeGroupBase *)get_node(type, id).ptr())->get_inputs();
@@ -1243,9 +1243,9 @@ Error VisualShader::_write_node(Type type, StringBuilder &global_code, StringBui
} else if (in_type == VisualShaderNode::PORT_TYPE_BOOLEAN && out_type == VisualShaderNode::PORT_TYPE_SCALAR_INT) {
inputs[i] = src_var + " > 0 ? true : false";
} else if (in_type == VisualShaderNode::PORT_TYPE_SCALAR && out_type == VisualShaderNode::PORT_TYPE_BOOLEAN) {
- inputs[i] = src_var + " ? 1.0 : 0.0";
+ inputs[i] = "(" + src_var + " ? 1.0 : 0.0)";
} else if (in_type == VisualShaderNode::PORT_TYPE_SCALAR_INT && out_type == VisualShaderNode::PORT_TYPE_BOOLEAN) {
- inputs[i] = src_var + " ? 1 : 0";
+ inputs[i] = "(" + src_var + " ? 1 : 0)";
} else if (in_type == VisualShaderNode::PORT_TYPE_VECTOR && out_type == VisualShaderNode::PORT_TYPE_BOOLEAN) {
inputs[i] = "vec3(" + src_var + " ? 1.0 : 0.0)";
} else if (in_type == VisualShaderNode::PORT_TYPE_SCALAR && out_type == VisualShaderNode::PORT_TYPE_SCALAR_INT) {
@@ -2597,20 +2597,37 @@ Vector<StringName> VisualShaderNodeUniform::get_editable_properties() const {
VisualShaderNodeUniform::VisualShaderNodeUniform() {
}
-////////////// GroupBase
-
-String VisualShaderNodeGroupBase::get_caption() const {
- return "Group";
-}
+////////////// ResizeableBase
-void VisualShaderNodeGroupBase::set_size(const Vector2 &p_size) {
+void VisualShaderNodeResizableBase::set_size(const Vector2 &p_size) {
size = p_size;
}
-Vector2 VisualShaderNodeGroupBase::get_size() const {
+Vector2 VisualShaderNodeResizableBase::get_size() const {
return size;
}
+void VisualShaderNodeResizableBase::set_allow_v_resize(bool p_enabled) {
+ allow_v_resize = p_enabled;
+}
+
+bool VisualShaderNodeResizableBase::is_allow_v_resize() const {
+ return allow_v_resize;
+}
+
+void VisualShaderNodeResizableBase::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_size", "size"), &VisualShaderNodeResizableBase::set_size);
+ ClassDB::bind_method(D_METHOD("get_size"), &VisualShaderNodeResizableBase::get_size);
+
+ ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
+}
+
+VisualShaderNodeResizableBase::VisualShaderNodeResizableBase() {
+ set_allow_v_resize(true);
+}
+
+////////////// GroupBase
+
void VisualShaderNodeGroupBase::set_inputs(const String &p_inputs) {
if (inputs == p_inputs) {
return;
@@ -3037,9 +3054,6 @@ bool VisualShaderNodeGroupBase::is_editable() const {
}
void VisualShaderNodeGroupBase::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_size", "size"), &VisualShaderNodeGroupBase::set_size);
- ClassDB::bind_method(D_METHOD("get_size"), &VisualShaderNodeGroupBase::get_size);
-
ClassDB::bind_method(D_METHOD("set_inputs", "inputs"), &VisualShaderNodeGroupBase::set_inputs);
ClassDB::bind_method(D_METHOD("get_inputs"), &VisualShaderNodeGroupBase::get_inputs);
@@ -3067,8 +3081,6 @@ void VisualShaderNodeGroupBase::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_free_input_port_id"), &VisualShaderNodeGroupBase::get_free_input_port_id);
ClassDB::bind_method(D_METHOD("get_free_output_port_id"), &VisualShaderNodeGroupBase::get_free_output_port_id);
-
- ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "size"), "set_size", "get_size");
}
String VisualShaderNodeGroupBase::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index e3d5200e6b..41c4642ee3 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -31,7 +31,7 @@
#ifndef VISUAL_SHADER_H
#define VISUAL_SHADER_H
-#include "core/string_builder.h"
+#include "core/string/string_builder.h"
#include "scene/gui/control.h"
#include "scene/resources/shader.h"
@@ -486,14 +486,33 @@ public:
VisualShaderNodeUniformRef();
};
-class VisualShaderNodeGroupBase : public VisualShaderNode {
- GDCLASS(VisualShaderNodeGroupBase, VisualShaderNode);
+class VisualShaderNodeResizableBase : public VisualShaderNode {
+ GDCLASS(VisualShaderNodeResizableBase, VisualShaderNode);
+
+protected:
+ Vector2 size = Size2(0, 0);
+ bool allow_v_resize = true;
+
+protected:
+ static void _bind_methods();
+
+public:
+ void set_size(const Vector2 &p_size);
+ Vector2 get_size() const;
+
+ bool is_allow_v_resize() const;
+ void set_allow_v_resize(bool p_enabled);
+
+ VisualShaderNodeResizableBase();
+};
+
+class VisualShaderNodeGroupBase : public VisualShaderNodeResizableBase {
+ GDCLASS(VisualShaderNodeGroupBase, VisualShaderNodeResizableBase);
private:
void _apply_port_changes();
protected:
- Vector2 size = Size2(0, 0);
String inputs = "";
String outputs = "";
bool editable = false;
@@ -511,11 +530,6 @@ protected:
static void _bind_methods();
public:
- virtual String get_caption() const override;
-
- void set_size(const Vector2 &p_size);
- Vector2 get_size() const;
-
void set_inputs(const String &p_inputs);
String get_inputs() const;
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index 085c0d0112..704d1b2ea8 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -782,6 +782,90 @@ void VisualShaderNodeTexture::_bind_methods() {
VisualShaderNodeTexture::VisualShaderNodeTexture() {
}
+////////////// Curve
+
+String VisualShaderNodeCurveTexture::get_caption() const {
+ return "CurveTexture";
+}
+
+int VisualShaderNodeCurveTexture::get_input_port_count() const {
+ return 1;
+}
+
+VisualShaderNodeCurveTexture::PortType VisualShaderNodeCurveTexture::get_input_port_type(int p_port) const {
+ return PORT_TYPE_SCALAR;
+}
+
+String VisualShaderNodeCurveTexture::get_input_port_name(int p_port) const {
+ return String();
+}
+
+int VisualShaderNodeCurveTexture::get_output_port_count() const {
+ return 1;
+}
+
+VisualShaderNodeCurveTexture::PortType VisualShaderNodeCurveTexture::get_output_port_type(int p_port) const {
+ return PORT_TYPE_SCALAR;
+}
+
+String VisualShaderNodeCurveTexture::get_output_port_name(int p_port) const {
+ return String();
+}
+
+void VisualShaderNodeCurveTexture::set_texture(Ref<CurveTexture> p_texture) {
+ texture = p_texture;
+ emit_changed();
+}
+
+Ref<CurveTexture> VisualShaderNodeCurveTexture::get_texture() const {
+ return texture;
+}
+
+Vector<StringName> VisualShaderNodeCurveTexture::get_editable_properties() const {
+ Vector<StringName> props;
+ props.push_back("texture");
+ return props;
+}
+
+String VisualShaderNodeCurveTexture::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
+ return "uniform sampler2D " + make_unique_id(p_type, p_id, "curve") + ";\n";
+}
+
+String VisualShaderNodeCurveTexture::generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview) const {
+ if (p_input_vars[0] == String()) {
+ return "\t" + p_output_vars[0] + " = 0.0;\n";
+ }
+ String id = make_unique_id(p_type, p_id, "curve");
+ String code;
+ code += "\t" + p_output_vars[0] + " = texture(" + id + ", vec2(" + p_input_vars[0] + ", 0.0)).r;\n";
+ return code;
+}
+
+Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCurveTexture::get_default_texture_parameters(VisualShader::Type p_type, int p_id) const {
+ VisualShader::DefaultTextureParam dtp;
+ dtp.name = make_unique_id(p_type, p_id, "curve");
+ dtp.param = texture;
+ Vector<VisualShader::DefaultTextureParam> ret;
+ ret.push_back(dtp);
+ return ret;
+}
+
+void VisualShaderNodeCurveTexture::_bind_methods() {
+ ClassDB::bind_method(D_METHOD("set_texture", "texture"), &VisualShaderNodeCurveTexture::set_texture);
+ ClassDB::bind_method(D_METHOD("get_texture"), &VisualShaderNodeCurveTexture::get_texture);
+
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "CurveTexture"), "set_texture", "get_texture");
+}
+
+bool VisualShaderNodeCurveTexture::is_use_prop_slots() const {
+ return true;
+}
+
+VisualShaderNodeCurveTexture::VisualShaderNodeCurveTexture() {
+ simple_decl = true;
+ allow_v_resize = false;
+}
+
////////////// Sample3D
int VisualShaderNodeSample3D::get_input_port_count() const {
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index 95042f8e56..d4d6540baf 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -284,6 +284,39 @@ VARIANT_ENUM_CAST(VisualShaderNodeTexture::Source)
///////////////////////////////////////
+class VisualShaderNodeCurveTexture : public VisualShaderNodeResizableBase {
+ GDCLASS(VisualShaderNodeCurveTexture, VisualShaderNodeResizableBase);
+ Ref<CurveTexture> texture;
+
+protected:
+ static void _bind_methods();
+
+public:
+ virtual String get_caption() const override;
+
+ virtual int get_input_port_count() const override;
+ virtual PortType get_input_port_type(int p_port) const override;
+ virtual String get_input_port_name(int p_port) const override;
+
+ virtual int get_output_port_count() const override;
+ virtual PortType get_output_port_type(int p_port) const override;
+ virtual String get_output_port_name(int p_port) const override;
+
+ virtual Vector<VisualShader::DefaultTextureParam> get_default_texture_parameters(VisualShader::Type p_type, int p_id) const override;
+ virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const override;
+ virtual String generate_code(Shader::Mode p_mode, VisualShader::Type p_type, int p_id, const String *p_input_vars, const String *p_output_vars, bool p_for_preview = false) const override; //if no output is connected, the output var passed will be empty. if no input is connected and input is NIL, the input var passed will be empty
+
+ void set_texture(Ref<CurveTexture> p_value);
+ Ref<CurveTexture> get_texture() const;
+
+ virtual Vector<StringName> get_editable_properties() const override;
+ virtual bool is_use_prop_slots() const override;
+
+ VisualShaderNodeCurveTexture();
+};
+
+///////////////////////////////////////
+
class VisualShaderNodeSample3D : public VisualShaderNode {
GDCLASS(VisualShaderNodeSample3D, VisualShaderNode);
diff --git a/scene/resources/world_2d.cpp b/scene/resources/world_2d.cpp
index d2bc2bea31..7bff850a15 100644
--- a/scene/resources/world_2d.cpp
+++ b/scene/resources/world_2d.cpp
@@ -30,7 +30,7 @@
#include "world_2d.h"
-#include "core/project_settings.h"
+#include "core/config/project_settings.h"
#include "scene/2d/camera_2d.h"
#include "scene/2d/visibility_notifier_2d.h"
#include "scene/main/window.h"
diff --git a/scene/resources/world_2d.h b/scene/resources/world_2d.h
index c330719104..11614f9aa4 100644
--- a/scene/resources/world_2d.h
+++ b/scene/resources/world_2d.h
@@ -31,8 +31,8 @@
#ifndef WORLD_2D_H
#define WORLD_2D_H
-#include "core/project_settings.h"
-#include "core/resource.h"
+#include "core/config/project_settings.h"
+#include "core/io/resource.h"
#include "servers/physics_server_2d.h"
class VisibilityNotifier2D;
diff --git a/scene/resources/world_3d.h b/scene/resources/world_3d.h
index 02a821637f..93e9c72e59 100644
--- a/scene/resources/world_3d.h
+++ b/scene/resources/world_3d.h
@@ -31,7 +31,7 @@
#ifndef WORLD_3D_H
#define WORLD_3D_H
-#include "core/resource.h"
+#include "core/io/resource.h"
#include "scene/resources/camera_effects.h"
#include "scene/resources/environment.h"
#include "servers/physics_server_3d.h"