summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/default_theme/default_theme.cpp12
-rw-r--r--scene/resources/default_theme/default_theme.h2
-rw-r--r--scene/resources/dynamic_font.cpp54
-rw-r--r--scene/resources/dynamic_font.h6
-rw-r--r--scene/resources/environment.cpp9
-rw-r--r--scene/resources/environment.h6
-rw-r--r--scene/resources/font.cpp10
-rw-r--r--scene/resources/font.h6
-rw-r--r--scene/resources/material.cpp42
-rw-r--r--scene/resources/material.h8
-rw-r--r--scene/resources/mesh_library.cpp10
-rw-r--r--scene/resources/mesh_library.h6
-rw-r--r--scene/resources/particles_material.cpp30
-rw-r--r--scene/resources/particles_material.h30
-rw-r--r--scene/resources/shader.cpp8
-rw-r--r--scene/resources/shader.h6
-rw-r--r--scene/resources/sky.cpp30
-rw-r--r--scene/resources/sky.h6
-rw-r--r--scene/resources/style_box.cpp12
-rw-r--r--scene/resources/style_box.h12
-rw-r--r--scene/resources/texture.cpp898
-rw-r--r--scene/resources/texture.h345
-rw-r--r--scene/resources/theme.cpp14
-rw-r--r--scene/resources/theme.h10
-rw-r--r--scene/resources/tile_set.cpp16
-rw-r--r--scene/resources/tile_set.h12
-rw-r--r--scene/resources/video_stream.h3
-rw-r--r--scene/resources/visual_shader.h2
-rw-r--r--scene/resources/visual_shader_nodes.cpp92
-rw-r--r--scene/resources/visual_shader_nodes.h28
30 files changed, 587 insertions, 1138 deletions
diff --git a/scene/resources/default_theme/default_theme.cpp b/scene/resources/default_theme/default_theme.cpp
index 00c56e5eb2..5a6a8dc286 100644
--- a/scene/resources/default_theme/default_theme.cpp
+++ b/scene/resources/default_theme/default_theme.cpp
@@ -69,7 +69,7 @@ static Ref<StyleBoxTexture> make_stylebox(T p_src, float p_left, float p_top, fl
img->resize(orig_size.x * scale, orig_size.y * scale);
}
- texture->create_from_image(img, ImageTexture::FLAG_FILTER);
+ texture->create_from_image(img);
(*tex_cache)[p_src] = texture;
}
@@ -98,7 +98,7 @@ static Ref<StyleBoxTexture> sb_expand(Ref<StyleBoxTexture> p_sbox, float p_left,
}
template <class T>
-static Ref<Texture> make_icon(T p_src) {
+static Ref<Texture2D> make_icon(T p_src) {
Ref<ImageTexture> texture(memnew(ImageTexture));
Ref<Image> img = memnew(Image(p_src));
@@ -115,7 +115,7 @@ static Ref<Texture> make_icon(T p_src) {
img->convert(Image::FORMAT_RGBA8);
img->resize(orig_size.x * scale, orig_size.y * scale);
}
- texture->create_from_image(img, ImageTexture::FLAG_FILTER);
+ texture->create_from_image(img);
return texture;
}
@@ -169,7 +169,7 @@ static Ref<StyleBox> make_empty_stylebox(float p_margin_left = -1, float p_margi
return style;
}
-void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture> &default_icon, Ref<StyleBox> &default_style, float p_scale) {
+void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture2D> &default_icon, Ref<StyleBox> &default_style, float p_scale) {
scale = p_scale;
@@ -464,7 +464,7 @@ void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const
theme->set_constant("completion_scroll_width", "TextEdit", 3);
theme->set_constant("line_spacing", "TextEdit", 4 * scale);
- Ref<Texture> empty_icon = memnew(ImageTexture);
+ Ref<Texture2D> empty_icon = memnew(ImageTexture);
// HScrollBar
@@ -873,7 +873,7 @@ void make_default_theme(bool p_hidpi, Ref<Font> p_font) {
t.instance();
Ref<StyleBox> default_style;
- Ref<Texture> default_icon;
+ Ref<Texture2D> default_icon;
Ref<Font> default_font;
if (p_font.is_valid()) {
default_font = p_font;
diff --git a/scene/resources/default_theme/default_theme.h b/scene/resources/default_theme/default_theme.h
index 1807770ff4..46f89a9b50 100644
--- a/scene/resources/default_theme/default_theme.h
+++ b/scene/resources/default_theme/default_theme.h
@@ -33,7 +33,7 @@
#include "scene/resources/theme.h"
-void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture> &default_icon, Ref<StyleBox> &default_style, float p_scale);
+void fill_default_theme(Ref<Theme> &theme, const Ref<Font> &default_font, const Ref<Font> &large_font, Ref<Texture2D> &default_icon, Ref<StyleBox> &default_style, float p_scale);
void make_default_theme(bool p_hidpi, Ref<Font> p_font);
void clear_default_theme();
diff --git a/scene/resources/dynamic_font.cpp b/scene/resources/dynamic_font.cpp
index 451029e93b..235f200c4e 100644
--- a/scene/resources/dynamic_font.cpp
+++ b/scene/resources/dynamic_font.cpp
@@ -222,11 +222,6 @@ Error DynamicFontAtSize::_load() {
ascent = (face->size->metrics.ascender / 64.0) / oversampling * scale_color_font;
descent = (-face->size->metrics.descender / 64.0) / oversampling * scale_color_font;
linegap = 0;
- texture_flags = 0;
- if (id.mipmaps)
- texture_flags |= Texture::FLAG_MIPMAPS;
- if (id.filter)
- texture_flags |= Texture::FLAG_FILTER;
valid = true;
return OK;
@@ -299,16 +294,6 @@ Size2 DynamicFontAtSize::get_char_size(CharType p_char, CharType p_next, const V
return ret;
}
-void DynamicFontAtSize::set_texture_flags(uint32_t p_flags) {
-
- texture_flags = p_flags;
- for (int i = 0; i < textures.size(); i++) {
- Ref<ImageTexture> &tex = textures.write[i].texture;
- if (!tex.is_null())
- tex->set_flags(p_flags);
- }
-}
-
float DynamicFontAtSize::draw_char(RID p_canvas_item, const Point2 &p_pos, CharType p_char, CharType p_next, const Color &p_modulate, const Vector<Ref<DynamicFontAtSize> > &p_fallbacks, bool p_advance_only, bool p_outline) const {
if (!valid)
@@ -536,9 +521,9 @@ DynamicFontAtSize::Character DynamicFontAtSize::_bitmap_to_character(FT_Bitmap b
if (tex.texture.is_null()) {
tex.texture.instance();
- tex.texture->create_from_image(img, Texture::FLAG_VIDEO_SURFACE | texture_flags);
+ tex.texture->create_from_image(img);
} else {
- tex.texture->set_data(img); //update
+ tex.texture->update(img); //update
}
}
@@ -659,7 +644,6 @@ DynamicFontAtSize::DynamicFontAtSize() {
ascent = 1;
descent = 1;
linegap = 1;
- texture_flags = 0;
oversampling = font_oversampling;
scale_color_font = 1;
}
@@ -758,34 +742,6 @@ Color DynamicFont::get_outline_color() const {
return outline_color;
}
-bool DynamicFont::get_use_mipmaps() const {
-
- return cache_id.mipmaps;
-}
-
-void DynamicFont::set_use_mipmaps(bool p_enable) {
-
- if (cache_id.mipmaps == p_enable)
- return;
- cache_id.mipmaps = p_enable;
- outline_cache_id.mipmaps = p_enable;
- _reload_cache();
-}
-
-bool DynamicFont::get_use_filter() const {
-
- return cache_id.filter;
-}
-
-void DynamicFont::set_use_filter(bool p_enable) {
-
- if (cache_id.filter == p_enable)
- return;
- cache_id.filter = p_enable;
- outline_cache_id.filter = p_enable;
- _reload_cache();
-}
-
bool DynamicFontData::is_antialiased() const {
return antialiased;
@@ -1007,10 +963,6 @@ void DynamicFont::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_outline_color", "color"), &DynamicFont::set_outline_color);
ClassDB::bind_method(D_METHOD("get_outline_color"), &DynamicFont::get_outline_color);
- ClassDB::bind_method(D_METHOD("set_use_mipmaps", "enable"), &DynamicFont::set_use_mipmaps);
- ClassDB::bind_method(D_METHOD("get_use_mipmaps"), &DynamicFont::get_use_mipmaps);
- ClassDB::bind_method(D_METHOD("set_use_filter", "enable"), &DynamicFont::set_use_filter);
- ClassDB::bind_method(D_METHOD("get_use_filter"), &DynamicFont::get_use_filter);
ClassDB::bind_method(D_METHOD("set_spacing", "type", "value"), &DynamicFont::set_spacing);
ClassDB::bind_method(D_METHOD("get_spacing", "type"), &DynamicFont::get_spacing);
@@ -1024,8 +976,6 @@ void DynamicFont::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "size", PROPERTY_HINT_RANGE, "1,1024,1"), "set_size", "get_size");
ADD_PROPERTY(PropertyInfo(Variant::INT, "outline_size", PROPERTY_HINT_RANGE, "0,1024,1"), "set_outline_size", "get_outline_size");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "outline_color"), "set_outline_color", "get_outline_color");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_mipmaps"), "set_use_mipmaps", "get_use_mipmaps");
- ADD_PROPERTY(PropertyInfo(Variant::BOOL, "use_filter"), "set_use_filter", "get_use_filter");
ADD_GROUP("Extra Spacing", "extra_spacing");
ADD_PROPERTYI(PropertyInfo(Variant::INT, "extra_spacing_top"), "set_spacing", "get_spacing", SPACING_TOP);
ADD_PROPERTYI(PropertyInfo(Variant::INT, "extra_spacing_bottom"), "set_spacing", "get_spacing", SPACING_BOTTOM);
diff --git a/scene/resources/dynamic_font.h b/scene/resources/dynamic_font.h
index 9170767512..94f03665d3 100644
--- a/scene/resources/dynamic_font.h
+++ b/scene/resources/dynamic_font.h
@@ -56,9 +56,7 @@ public:
struct {
uint32_t size : 16;
uint32_t outline_size : 8;
- uint32_t mipmaps : 1;
- uint32_t filter : 1;
- uint32_t unused : 6;
+ uint32_t unused : 8;
};
uint32_t key;
};
@@ -127,8 +125,6 @@ class DynamicFontAtSize : public Reference {
float oversampling;
float scale_color_font;
- uint32_t texture_flags;
-
bool valid;
struct CharTexture {
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 7597cd636e..37a185ecac 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -113,7 +113,10 @@ void Environment::set_ambient_light_sky_contribution(float p_energy) {
void Environment::set_camera_feed_id(int p_camera_feed_id) {
camera_feed_id = p_camera_feed_id;
+// FIXME: Disabled during Vulkan refactoring, should be ported.
+#if 0
VS::get_singleton()->environment_set_camera_feed_id(environment, camera_feed_id);
+#endif
};
Environment::BGMode Environment::get_background() const {
@@ -300,12 +303,12 @@ float Environment::get_adjustment_saturation() const {
return adjustment_saturation;
}
-void Environment::set_adjustment_color_correction(const Ref<Texture> &p_ramp) {
+void Environment::set_adjustment_color_correction(const Ref<Texture2D> &p_ramp) {
adjustment_color_correction = p_ramp;
VS::get_singleton()->environment_set_adjustment(environment, adjustment_enabled, adjustment_brightness, adjustment_contrast, adjustment_saturation, adjustment_color_correction.is_valid() ? adjustment_color_correction->get_rid() : RID());
}
-Ref<Texture> Environment::get_adjustment_color_correction() const {
+Ref<Texture2D> Environment::get_adjustment_color_correction() const {
return adjustment_color_correction;
}
@@ -1273,7 +1276,7 @@ void Environment::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_brightness", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_brightness", "get_adjustment_brightness");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_contrast", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_contrast", "get_adjustment_contrast");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "adjustment_saturation", PROPERTY_HINT_RANGE, "0.01,8,0.01"), "set_adjustment_saturation", "get_adjustment_saturation");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "adjustment_color_correction", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_adjustment_color_correction", "get_adjustment_color_correction");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "adjustment_color_correction", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_adjustment_color_correction", "get_adjustment_color_correction");
BIND_ENUM_CONSTANT(BG_KEEP);
BIND_ENUM_CONSTANT(BG_CLEAR_COLOR);
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index 62c6c5b4cd..e9088d4fbd 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -114,7 +114,7 @@ private:
float adjustment_contrast;
float adjustment_saturation;
float adjustment_brightness;
- Ref<Texture> adjustment_color_correction;
+ Ref<Texture2D> adjustment_color_correction;
bool ssr_enabled;
int ssr_max_steps;
@@ -246,8 +246,8 @@ public:
void set_adjustment_saturation(float p_saturation);
float get_adjustment_saturation() const;
- void set_adjustment_color_correction(const Ref<Texture> &p_ramp);
- Ref<Texture> get_adjustment_color_correction() const;
+ void set_adjustment_color_correction(const Ref<Texture2D> &p_ramp);
+ Ref<Texture2D> get_adjustment_color_correction() const;
void set_ssr_enabled(bool p_enable);
bool is_ssr_enabled() const;
diff --git a/scene/resources/font.cpp b/scene/resources/font.cpp
index 19c59b3817..076a0ced48 100644
--- a/scene/resources/font.cpp
+++ b/scene/resources/font.cpp
@@ -182,7 +182,7 @@ void BitmapFont::_set_textures(const Vector<Variant> &p_textures) {
textures.clear();
for (int i = 0; i < p_textures.size(); i++) {
- Ref<Texture> tex = p_textures[i];
+ Ref<Texture2D> tex = p_textures[i];
ERR_CONTINUE(!tex.is_valid());
add_texture(tex);
}
@@ -270,7 +270,7 @@ Error BitmapFont::create_from_fnt(const String &p_file) {
String base_dir = p_file.get_base_dir();
String file = base_dir.plus_file(keys["file"]);
- Ref<Texture> tex = ResourceLoader::load(file);
+ Ref<Texture2D> tex = ResourceLoader::load(file);
if (tex.is_null()) {
ERR_PRINT("Can't load font texture!");
} else {
@@ -356,7 +356,7 @@ float BitmapFont::get_descent() const {
return height - ascent;
}
-void BitmapFont::add_texture(const Ref<Texture> &p_texture) {
+void BitmapFont::add_texture(const Ref<Texture2D> &p_texture) {
ERR_FAIL_COND_MSG(p_texture.is_null(), "It's not a reference to a valid Texture object.");
textures.push_back(p_texture);
@@ -367,9 +367,9 @@ int BitmapFont::get_texture_count() const {
return textures.size();
};
-Ref<Texture> BitmapFont::get_texture(int p_idx) const {
+Ref<Texture2D> BitmapFont::get_texture(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx, textures.size(), Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_idx, textures.size(), Ref<Texture2D>());
return textures[p_idx];
};
diff --git a/scene/resources/font.h b/scene/resources/font.h
index 411145c153..fc1d92e2f9 100644
--- a/scene/resources/font.h
+++ b/scene/resources/font.h
@@ -108,7 +108,7 @@ class BitmapFont : public Font {
GDCLASS(BitmapFont, Font);
RES_BASE_EXTENSION("font");
- Vector<Ref<Texture> > textures;
+ Vector<Ref<Texture2D> > textures;
public:
struct Character {
@@ -168,7 +168,7 @@ public:
float get_ascent() const;
float get_descent() const;
- void add_texture(const Ref<Texture> &p_texture);
+ void add_texture(const Ref<Texture2D> &p_texture);
void add_char(CharType p_char, int p_texture_idx, const Rect2 &p_rect, const Size2 &p_align, float p_advance = -1);
int get_character_count() const;
@@ -176,7 +176,7 @@ public:
Character get_character(CharType p_char) const;
int get_texture_count() const;
- Ref<Texture> get_texture(int p_idx) const;
+ Ref<Texture2D> get_texture(int p_idx) const;
void add_kerning_pair(CharType p_A, CharType p_B, int p_kerning);
int get_kerning_pair(CharType p_A, CharType p_B) const;
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index ab4dbb758a..e90a917b27 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -1407,7 +1407,7 @@ bool SpatialMaterial::get_feature(Feature p_feature) const {
return features[p_feature];
}
-void SpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture> &p_texture) {
+void SpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture2D> &p_texture) {
ERR_FAIL_INDEX(p_param, TEXTURE_MAX);
textures[p_param] = p_texture;
@@ -1417,19 +1417,19 @@ void SpatialMaterial::set_texture(TextureParam p_param, const Ref<Texture> &p_te
_queue_shader_change();
}
-Ref<Texture> SpatialMaterial::get_texture(TextureParam p_param) const {
+Ref<Texture2D> SpatialMaterial::get_texture(TextureParam p_param) const {
- ERR_FAIL_INDEX_V(p_param, TEXTURE_MAX, Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_param, TEXTURE_MAX, Ref<Texture2D>());
return textures[p_param];
}
-Ref<Texture> SpatialMaterial::get_texture_by_name(StringName p_name) const {
+Ref<Texture2D> SpatialMaterial::get_texture_by_name(StringName p_name) const {
for (int i = 0; i < (int)SpatialMaterial::TEXTURE_MAX; i++) {
TextureParam param = TextureParam(i);
if (p_name == shader_names->texture_names[param])
return textures[param];
}
- return Ref<Texture>();
+ return Ref<Texture2D>();
}
void SpatialMaterial::_validate_feature(const String &text, Feature feature, PropertyInfo &property) const {
@@ -2137,17 +2137,17 @@ void SpatialMaterial::_bind_methods() {
ADD_GROUP("Albedo", "albedo_");
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "albedo_color"), "set_albedo", "get_albedo");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "albedo_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_ALBEDO);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "albedo_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_ALBEDO);
ADD_GROUP("Metallic", "metallic_");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_metallic", "get_metallic");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "metallic_specular", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_specular", "get_specular");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "metallic_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_METALLIC);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "metallic_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_METALLIC);
ADD_PROPERTY(PropertyInfo(Variant::INT, "metallic_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_metallic_texture_channel", "get_metallic_texture_channel");
ADD_GROUP("Roughness", "roughness_");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "roughness", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_roughness", "get_roughness");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "roughness_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_ROUGHNESS);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "roughness_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_ROUGHNESS);
ADD_PROPERTY(PropertyInfo(Variant::INT, "roughness_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_roughness_texture_channel", "get_roughness_texture_channel");
ADD_GROUP("Emission", "emission_");
@@ -2156,34 +2156,34 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "emission_energy", PROPERTY_HINT_RANGE, "0,16,0.01,or_greater"), "set_emission_energy", "get_emission_energy");
ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_operator", PROPERTY_HINT_ENUM, "Add,Multiply"), "set_emission_operator", "get_emission_operator");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "emission_on_uv2"), "set_flag", "get_flag", FLAG_EMISSION_ON_UV2);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "emission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_EMISSION);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "emission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_EMISSION);
ADD_GROUP("NormalMap", "normal_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "normal_enabled"), "set_feature", "get_feature", FEATURE_NORMAL_MAPPING);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "normal_scale", PROPERTY_HINT_RANGE, "-16,16,0.01"), "set_normal_scale", "get_normal_scale");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_NORMAL);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_NORMAL);
ADD_GROUP("Rim", "rim_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "rim_enabled"), "set_feature", "get_feature", FEATURE_RIM);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rim", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_rim", "get_rim");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "rim_tint", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_rim_tint", "get_rim_tint");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "rim_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_RIM);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "rim_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_RIM);
ADD_GROUP("Clearcoat", "clearcoat_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "clearcoat_enabled"), "set_feature", "get_feature", FEATURE_CLEARCOAT);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "clearcoat", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_clearcoat", "get_clearcoat");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "clearcoat_gloss", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_clearcoat_gloss", "get_clearcoat_gloss");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "clearcoat_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_CLEARCOAT);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "clearcoat_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_CLEARCOAT);
ADD_GROUP("Anisotropy", "anisotropy_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "anisotropy_enabled"), "set_feature", "get_feature", FEATURE_ANISOTROPY);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "anisotropy", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_anisotropy", "get_anisotropy");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anisotropy_flowmap", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_FLOWMAP);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "anisotropy_flowmap", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_FLOWMAP);
ADD_GROUP("Ambient Occlusion", "ao_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_enabled"), "set_feature", "get_feature", FEATURE_AMBIENT_OCCLUSION);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "ao_light_affect", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_ao_light_affect", "get_ao_light_affect");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "ao_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_AMBIENT_OCCLUSION);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "ao_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_AMBIENT_OCCLUSION);
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "ao_on_uv2"), "set_flag", "get_flag", FLAG_AO_ON_UV2);
ADD_PROPERTY(PropertyInfo(Variant::INT, "ao_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_ao_texture_channel", "get_ao_texture_channel");
@@ -2195,31 +2195,31 @@ void SpatialMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "depth_max_layers", PROPERTY_HINT_RANGE, "1,32,1"), "set_depth_deep_parallax_max_layers", "get_depth_deep_parallax_max_layers");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "depth_flip_tangent"), "set_depth_deep_parallax_flip_tangent", "get_depth_deep_parallax_flip_tangent");
ADD_PROPERTY(PropertyInfo(Variant::BOOL, "depth_flip_binormal"), "set_depth_deep_parallax_flip_binormal", "get_depth_deep_parallax_flip_binormal");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "depth_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_DEPTH);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "depth_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_DEPTH);
ADD_GROUP("Subsurf Scatter", "subsurf_scatter_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "subsurf_scatter_enabled"), "set_feature", "get_feature", FEATURE_SUBSURACE_SCATTERING);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "subsurf_scatter_strength", PROPERTY_HINT_RANGE, "0,1,0.01"), "set_subsurface_scattering_strength", "get_subsurface_scattering_strength");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "subsurf_scatter_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_SUBSURFACE_SCATTERING);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "subsurf_scatter_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_SUBSURFACE_SCATTERING);
ADD_GROUP("Transmission", "transmission_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "transmission_enabled"), "set_feature", "get_feature", FEATURE_TRANSMISSION);
ADD_PROPERTY(PropertyInfo(Variant::COLOR, "transmission", PROPERTY_HINT_COLOR_NO_ALPHA), "set_transmission", "get_transmission");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "transmission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_TRANSMISSION);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "transmission_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_TRANSMISSION);
ADD_GROUP("Refraction", "refraction_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "refraction_enabled"), "set_feature", "get_feature", FEATURE_REFRACTION);
ADD_PROPERTY(PropertyInfo(Variant::REAL, "refraction_scale", PROPERTY_HINT_RANGE, "-1,1,0.01"), "set_refraction", "get_refraction");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "refraction_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_REFRACTION);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "refraction_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_REFRACTION);
ADD_PROPERTY(PropertyInfo(Variant::INT, "refraction_texture_channel", PROPERTY_HINT_ENUM, "Red,Green,Blue,Alpha,Gray"), "set_refraction_texture_channel", "get_refraction_texture_channel");
ADD_GROUP("Detail", "detail_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "detail_enabled"), "set_feature", "get_feature", FEATURE_DETAIL);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_mask", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_DETAIL_MASK);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_mask", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_DETAIL_MASK);
ADD_PROPERTY(PropertyInfo(Variant::INT, "detail_blend_mode", PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul"), "set_detail_blend_mode", "get_detail_blend_mode");
ADD_PROPERTY(PropertyInfo(Variant::INT, "detail_uv_layer", PROPERTY_HINT_ENUM, "UV1,UV2"), "set_detail_uv", "get_detail_uv");
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_albedo", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_DETAIL_ALBEDO);
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture", TEXTURE_DETAIL_NORMAL);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_albedo", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_DETAIL_ALBEDO);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "detail_normal", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture", TEXTURE_DETAIL_NORMAL);
ADD_GROUP("UV1", "uv1_");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "uv1_scale"), "set_uv1_scale", "get_uv1_scale");
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 8e66011bec..38fb8b2172 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -437,7 +437,7 @@ private:
bool features[FEATURE_MAX];
- Ref<Texture> textures[TEXTURE_MAX];
+ Ref<Texture2D> textures[TEXTURE_MAX];
_FORCE_INLINE_ void _validate_feature(const String &text, Feature feature, PropertyInfo &property) const;
@@ -549,10 +549,10 @@ public:
void set_flag(Flags p_flag, bool p_enabled);
bool get_flag(Flags p_flag) const;
- void set_texture(TextureParam p_param, const Ref<Texture> &p_texture);
- Ref<Texture> get_texture(TextureParam p_param) const;
+ void set_texture(TextureParam p_param, const Ref<Texture2D> &p_texture);
+ Ref<Texture2D> get_texture(TextureParam p_param) const;
// Used only for shader material conversion
- Ref<Texture> get_texture_by_name(StringName p_name) const;
+ Ref<Texture2D> get_texture_by_name(StringName p_name) const;
void set_feature(Feature p_feature, bool p_enabled);
bool get_feature(Feature p_feature) const;
diff --git a/scene/resources/mesh_library.cpp b/scene/resources/mesh_library.cpp
index 754cad4def..ac016bec5d 100644
--- a/scene/resources/mesh_library.cpp
+++ b/scene/resources/mesh_library.cpp
@@ -104,7 +104,7 @@ void MeshLibrary::_get_property_list(List<PropertyInfo> *p_list) const {
p_list->push_back(PropertyInfo(Variant::ARRAY, name + "shapes"));
p_list->push_back(PropertyInfo(Variant::OBJECT, name + "navmesh", PROPERTY_HINT_RESOURCE_TYPE, "NavigationMesh"));
p_list->push_back(PropertyInfo(Variant::TRANSFORM, name + "navmesh_transform"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, name + "preview", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_HELPER));
+ p_list->push_back(PropertyInfo(Variant::OBJECT, name + "preview", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_EDITOR_HELPER));
}
}
@@ -162,7 +162,7 @@ void MeshLibrary::set_item_navmesh_transform(int p_item, const Transform &p_tran
_change_notify();
}
-void MeshLibrary::set_item_preview(int p_item, const Ref<Texture> &p_preview) {
+void MeshLibrary::set_item_preview(int p_item, const Ref<Texture2D> &p_preview) {
ERR_FAIL_COND_MSG(!item_map.has(p_item), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
item_map[p_item].preview = p_preview;
@@ -200,14 +200,14 @@ Transform MeshLibrary::get_item_navmesh_transform(int p_item) const {
return item_map[p_item].navmesh_transform;
}
-Ref<Texture> MeshLibrary::get_item_preview(int p_item) const {
+Ref<Texture2D> MeshLibrary::get_item_preview(int p_item) const {
if (!Engine::get_singleton()->is_editor_hint()) {
ERR_PRINT("MeshLibrary item previews are only generated in an editor context, which means they aren't available in a running project.");
- return Ref<Texture>();
+ return Ref<Texture2D>();
}
- ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Texture>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
+ ERR_FAIL_COND_V_MSG(!item_map.has(p_item), Ref<Texture2D>(), "Requested for nonexistent MeshLibrary item '" + itos(p_item) + "'.");
return item_map[p_item].preview;
}
diff --git a/scene/resources/mesh_library.h b/scene/resources/mesh_library.h
index 5f1fddae22..9155975f47 100644
--- a/scene/resources/mesh_library.h
+++ b/scene/resources/mesh_library.h
@@ -51,7 +51,7 @@ public:
String name;
Ref<Mesh> mesh;
Vector<ShapeData> shapes;
- Ref<Texture> preview;
+ Ref<Texture2D> preview;
Transform navmesh_transform;
Ref<NavigationMesh> navmesh;
};
@@ -75,13 +75,13 @@ public:
void set_item_navmesh(int p_item, const Ref<NavigationMesh> &p_navmesh);
void set_item_navmesh_transform(int p_item, const Transform &p_transform);
void set_item_shapes(int p_item, const Vector<ShapeData> &p_shapes);
- void set_item_preview(int p_item, const Ref<Texture> &p_preview);
+ void set_item_preview(int p_item, const Ref<Texture2D> &p_preview);
String get_item_name(int p_item) const;
Ref<Mesh> get_item_mesh(int p_item) const;
Ref<NavigationMesh> get_item_navmesh(int p_item) const;
Transform get_item_navmesh_transform(int p_item) const;
Vector<ShapeData> get_item_shapes(int p_item) const;
- Ref<Texture> get_item_preview(int p_item) const;
+ Ref<Texture2D> get_item_preview(int p_item) const;
void remove_item(int p_item);
bool has_item(int p_item) const;
diff --git a/scene/resources/particles_material.cpp b/scene/resources/particles_material.cpp
index baeb88400e..d852dca7fa 100644
--- a/scene/resources/particles_material.cpp
+++ b/scene/resources/particles_material.cpp
@@ -790,7 +790,7 @@ float ParticlesMaterial::get_param_randomness(Parameter p_param) const {
return randomness[p_param];
}
-static void _adjust_curve_range(const Ref<Texture> &p_texture, float p_min, float p_max) {
+static void _adjust_curve_range(const Ref<Texture2D> &p_texture, float p_min, float p_max) {
Ref<CurveTexture> curve_tex = p_texture;
if (!curve_tex.is_valid())
@@ -799,7 +799,7 @@ static void _adjust_curve_range(const Ref<Texture> &p_texture, float p_min, floa
curve_tex->ensure_default_setup(p_min, p_max);
}
-void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture> &p_texture) {
+void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture2D> &p_texture) {
ERR_FAIL_INDEX(p_param, PARAM_MAX);
@@ -857,9 +857,9 @@ void ParticlesMaterial::set_param_texture(Parameter p_param, const Ref<Texture>
_queue_shader_change();
}
-Ref<Texture> ParticlesMaterial::get_param_texture(Parameter p_param) const {
+Ref<Texture2D> ParticlesMaterial::get_param_texture(Parameter p_param) const {
- ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_param, PARAM_MAX, Ref<Texture2D>());
return tex_parameters[p_param];
}
@@ -875,7 +875,7 @@ Color ParticlesMaterial::get_color() const {
return color;
}
-void ParticlesMaterial::set_color_ramp(const Ref<Texture> &p_texture) {
+void ParticlesMaterial::set_color_ramp(const Ref<Texture2D> &p_texture) {
color_ramp = p_texture;
VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->color_ramp, p_texture);
@@ -883,7 +883,7 @@ void ParticlesMaterial::set_color_ramp(const Ref<Texture> &p_texture) {
_change_notify();
}
-Ref<Texture> ParticlesMaterial::get_color_ramp() const {
+Ref<Texture2D> ParticlesMaterial::get_color_ramp() const {
return color_ramp;
}
@@ -921,19 +921,19 @@ void ParticlesMaterial::set_emission_box_extents(Vector3 p_extents) {
VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_box_extents, p_extents);
}
-void ParticlesMaterial::set_emission_point_texture(const Ref<Texture> &p_points) {
+void ParticlesMaterial::set_emission_point_texture(const Ref<Texture2D> &p_points) {
emission_point_texture = p_points;
VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_points, p_points);
}
-void ParticlesMaterial::set_emission_normal_texture(const Ref<Texture> &p_normals) {
+void ParticlesMaterial::set_emission_normal_texture(const Ref<Texture2D> &p_normals) {
emission_normal_texture = p_normals;
VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_normal, p_normals);
}
-void ParticlesMaterial::set_emission_color_texture(const Ref<Texture> &p_colors) {
+void ParticlesMaterial::set_emission_color_texture(const Ref<Texture2D> &p_colors) {
emission_color_texture = p_colors;
VisualServer::get_singleton()->material_set_param(_get_material(), shader_names->emission_texture_color, p_colors);
@@ -959,16 +959,16 @@ Vector3 ParticlesMaterial::get_emission_box_extents() const {
return emission_box_extents;
}
-Ref<Texture> ParticlesMaterial::get_emission_point_texture() const {
+Ref<Texture2D> ParticlesMaterial::get_emission_point_texture() const {
return emission_point_texture;
}
-Ref<Texture> ParticlesMaterial::get_emission_normal_texture() const {
+Ref<Texture2D> ParticlesMaterial::get_emission_normal_texture() const {
return emission_normal_texture;
}
-Ref<Texture> ParticlesMaterial::get_emission_color_texture() const {
+Ref<Texture2D> ParticlesMaterial::get_emission_color_texture() const {
return emission_color_texture;
}
@@ -1162,9 +1162,9 @@ void ParticlesMaterial::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_shape", PROPERTY_HINT_ENUM, "Point,Sphere,Box,Points,Directed Points"), "set_emission_shape", "get_emission_shape");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "emission_sphere_radius", PROPERTY_HINT_RANGE, "0.01,128,0.01,or_greater"), "set_emission_sphere_radius", "get_emission_sphere_radius");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR3, "emission_box_extents"), "set_emission_box_extents", "get_emission_box_extents");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_point_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_point_texture", "get_emission_point_texture");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_normal_texture", "get_emission_normal_texture");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_color_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_emission_color_texture", "get_emission_color_texture");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_point_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_emission_point_texture", "get_emission_point_texture");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_normal_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_emission_normal_texture", "get_emission_normal_texture");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "emission_color_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_emission_color_texture", "get_emission_color_texture");
ADD_PROPERTY(PropertyInfo(Variant::INT, "emission_point_count", PROPERTY_HINT_RANGE, "0,1000000,1"), "set_emission_point_count", "get_emission_point_count");
ADD_GROUP("Flags", "flag_");
ADD_PROPERTYI(PropertyInfo(Variant::BOOL, "flag_align_y"), "set_flag", "get_flag", FLAG_ALIGN_Y_TO_VELOCITY);
diff --git a/scene/resources/particles_material.h b/scene/resources/particles_material.h
index cc860b3812..246ce58a21 100644
--- a/scene/resources/particles_material.h
+++ b/scene/resources/particles_material.h
@@ -205,18 +205,18 @@ private:
float parameters[PARAM_MAX];
float randomness[PARAM_MAX];
- Ref<Texture> tex_parameters[PARAM_MAX];
+ Ref<Texture2D> tex_parameters[PARAM_MAX];
Color color;
- Ref<Texture> color_ramp;
+ Ref<Texture2D> color_ramp;
bool flags[FLAG_MAX];
EmissionShape emission_shape;
float emission_sphere_radius;
Vector3 emission_box_extents;
- Ref<Texture> emission_point_texture;
- Ref<Texture> emission_normal_texture;
- Ref<Texture> emission_color_texture;
+ Ref<Texture2D> emission_point_texture;
+ Ref<Texture2D> emission_normal_texture;
+ Ref<Texture2D> emission_color_texture;
int emission_point_count;
bool anim_loop;
@@ -252,14 +252,14 @@ public:
void set_param_randomness(Parameter p_param, float p_value);
float get_param_randomness(Parameter p_param) const;
- void set_param_texture(Parameter p_param, const Ref<Texture> &p_texture);
- Ref<Texture> get_param_texture(Parameter p_param) const;
+ void set_param_texture(Parameter p_param, const Ref<Texture2D> &p_texture);
+ Ref<Texture2D> get_param_texture(Parameter p_param) const;
void set_color(const Color &p_color);
Color get_color() const;
- void set_color_ramp(const Ref<Texture> &p_texture);
- Ref<Texture> get_color_ramp() const;
+ void set_color_ramp(const Ref<Texture2D> &p_texture);
+ Ref<Texture2D> get_color_ramp() const;
void set_flag(Flags p_flag, bool p_enable);
bool get_flag(Flags p_flag) const;
@@ -267,17 +267,17 @@ public:
void set_emission_shape(EmissionShape p_shape);
void set_emission_sphere_radius(float p_radius);
void set_emission_box_extents(Vector3 p_extents);
- void set_emission_point_texture(const Ref<Texture> &p_points);
- void set_emission_normal_texture(const Ref<Texture> &p_normals);
- void set_emission_color_texture(const Ref<Texture> &p_colors);
+ void set_emission_point_texture(const Ref<Texture2D> &p_points);
+ void set_emission_normal_texture(const Ref<Texture2D> &p_normals);
+ void set_emission_color_texture(const Ref<Texture2D> &p_colors);
void set_emission_point_count(int p_count);
EmissionShape get_emission_shape() const;
float get_emission_sphere_radius() const;
Vector3 get_emission_box_extents() const;
- Ref<Texture> get_emission_point_texture() const;
- Ref<Texture> get_emission_normal_texture() const;
- Ref<Texture> get_emission_color_texture() const;
+ Ref<Texture2D> get_emission_point_texture() const;
+ Ref<Texture2D> get_emission_normal_texture() const;
+ Ref<Texture2D> get_emission_color_texture() const;
int get_emission_point_count() const;
void set_trail_divisor(int p_divisor);
diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp
index 44c2a46065..79cb9754df 100644
--- a/scene/resources/shader.cpp
+++ b/scene/resources/shader.cpp
@@ -98,7 +98,7 @@ RID Shader::get_rid() const {
return shader;
}
-void Shader::set_default_texture_param(const StringName &p_param, const Ref<Texture> &p_texture) {
+void Shader::set_default_texture_param(const StringName &p_param, const Ref<Texture2D> &p_texture) {
if (p_texture.is_valid()) {
default_textures[p_param] = p_texture;
@@ -111,17 +111,17 @@ void Shader::set_default_texture_param(const StringName &p_param, const Ref<Text
emit_changed();
}
-Ref<Texture> Shader::get_default_texture_param(const StringName &p_param) const {
+Ref<Texture2D> Shader::get_default_texture_param(const StringName &p_param) const {
if (default_textures.has(p_param))
return default_textures[p_param];
else
- return Ref<Texture>();
+ return Ref<Texture2D>();
}
void Shader::get_default_texture_param_list(List<StringName> *r_textures) const {
- for (const Map<StringName, Ref<Texture> >::Element *E = default_textures.front(); E; E = E->next()) {
+ for (const Map<StringName, Ref<Texture2D> >::Element *E = default_textures.front(); E; E = E->next()) {
r_textures->push_back(E->key());
}
diff --git a/scene/resources/shader.h b/scene/resources/shader.h
index 67ae436a4c..702e58aedc 100644
--- a/scene/resources/shader.h
+++ b/scene/resources/shader.h
@@ -59,7 +59,7 @@ private:
// conversion fast and save memory.
mutable bool params_cache_dirty;
mutable Map<StringName, StringName> params_cache; //map a shader param to a material param..
- Map<StringName, Ref<Texture> > default_textures;
+ Map<StringName, Ref<Texture2D> > default_textures;
virtual void _update_shader() const; //used for visual shader
protected:
@@ -75,8 +75,8 @@ public:
void get_param_list(List<PropertyInfo> *p_params) const;
bool has_param(const StringName &p_param) const;
- void set_default_texture_param(const StringName &p_param, const Ref<Texture> &p_texture);
- Ref<Texture> get_default_texture_param(const StringName &p_param) const;
+ void set_default_texture_param(const StringName &p_param, const Ref<Texture2D> &p_texture);
+ Ref<Texture2D> get_default_texture_param(const StringName &p_param) const;
void get_default_texture_param_list(List<StringName> *r_textures) const;
virtual bool is_text_shader() const;
diff --git a/scene/resources/sky.cpp b/scene/resources/sky.cpp
index c20fbb4129..59af1f58e8 100644
--- a/scene/resources/sky.cpp
+++ b/scene/resources/sky.cpp
@@ -77,7 +77,7 @@ void PanoramaSky::_radiance_changed() {
}
}
-void PanoramaSky::set_panorama(const Ref<Texture> &p_panorama) {
+void PanoramaSky::set_panorama(const Ref<Texture2D> &p_panorama) {
panorama = p_panorama;
@@ -90,7 +90,7 @@ void PanoramaSky::set_panorama(const Ref<Texture> &p_panorama) {
}
}
-Ref<Texture> PanoramaSky::get_panorama() const {
+Ref<Texture2D> PanoramaSky::get_panorama() const {
return panorama;
}
@@ -105,7 +105,7 @@ void PanoramaSky::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_panorama", "texture"), &PanoramaSky::set_panorama);
ClassDB::bind_method(D_METHOD("get_panorama"), &PanoramaSky::get_panorama);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "panorama", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_panorama", "get_panorama");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "panorama", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_panorama", "get_panorama");
}
PanoramaSky::PanoramaSky() {
@@ -415,8 +415,12 @@ void ProceduralSky::_update_sky() {
} else {
Ref<Image> image = _generate_sky();
- VS::get_singleton()->texture_allocate(texture, image->get_width(), image->get_height(), 0, Image::FORMAT_RGBE9995, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT);
- VS::get_singleton()->texture_set_data(texture, image);
+ if (texture.is_valid()) {
+ RID new_texture = VS::get_singleton()->texture_2d_create(image);
+ VS::get_singleton()->texture_replace(texture, new_texture);
+ } else {
+ texture = VS::get_singleton()->texture_2d_create(image);
+ }
_radiance_changed();
}
}
@@ -432,8 +436,13 @@ void ProceduralSky::_queue_update() {
void ProceduralSky::_thread_done(const Ref<Image> &p_image) {
- VS::get_singleton()->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, Image::FORMAT_RGBE9995, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_FILTER | VS::TEXTURE_FLAG_REPEAT);
- VS::get_singleton()->texture_set_data(texture, p_image);
+ if (texture.is_valid()) {
+ RID new_texture = VS::get_singleton()->texture_2d_create(p_image);
+ VS::get_singleton()->texture_replace(texture, new_texture);
+ } else {
+ texture = VS::get_singleton()->texture_2d_create(p_image);
+ }
+
_radiance_changed();
Thread::wait_to_finish(sky_thread);
memdelete(sky_thread);
@@ -525,7 +534,7 @@ void ProceduralSky::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_curve", PROPERTY_HINT_EXP_EASING), "set_sun_curve", "get_sun_curve");
ADD_PROPERTY(PropertyInfo(Variant::REAL, "sun_energy", PROPERTY_HINT_RANGE, "0,64,0.01"), "set_sun_energy", "get_sun_energy");
- ADD_GROUP("Texture", "texture_");
+ ADD_GROUP("Texture2D", "texture_");
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_size", PROPERTY_HINT_ENUM, "256,512,1024,2048,4096"), "set_texture_size", "get_texture_size");
BIND_ENUM_CONSTANT(TEXTURE_SIZE_256);
@@ -539,7 +548,6 @@ void ProceduralSky::_bind_methods() {
ProceduralSky::ProceduralSky(bool p_desaturate) {
sky = VS::get_singleton()->sky_create();
- texture = VS::get_singleton()->texture_create();
update_queued = false;
sky_top_color = Color::hex(0xa5d6f1ff);
@@ -582,5 +590,7 @@ ProceduralSky::~ProceduralSky() {
sky_thread = NULL;
}
VS::get_singleton()->free(sky);
- VS::get_singleton()->free(texture);
+ if (texture.is_valid()) {
+ VS::get_singleton()->free(texture);
+ }
}
diff --git a/scene/resources/sky.h b/scene/resources/sky.h
index 70ea9c4c18..cc5ec79a1f 100644
--- a/scene/resources/sky.h
+++ b/scene/resources/sky.h
@@ -69,15 +69,15 @@ class PanoramaSky : public Sky {
private:
RID sky;
- Ref<Texture> panorama;
+ Ref<Texture2D> panorama;
protected:
static void _bind_methods();
virtual void _radiance_changed();
public:
- void set_panorama(const Ref<Texture> &p_panorama);
- Ref<Texture> get_panorama() const;
+ void set_panorama(const Ref<Texture2D> &p_panorama);
+ Ref<Texture2D> get_panorama() const;
virtual RID get_rid() const;
diff --git a/scene/resources/style_box.cpp b/scene/resources/style_box.cpp
index 9408d1aa71..1766b531d5 100644
--- a/scene/resources/style_box.cpp
+++ b/scene/resources/style_box.cpp
@@ -118,7 +118,7 @@ StyleBox::StyleBox() {
}
}
-void StyleBoxTexture::set_texture(Ref<Texture> p_texture) {
+void StyleBoxTexture::set_texture(Ref<Texture2D> p_texture) {
if (texture == p_texture)
return;
@@ -133,12 +133,12 @@ void StyleBoxTexture::set_texture(Ref<Texture> p_texture) {
_change_notify("texture");
}
-Ref<Texture> StyleBoxTexture::get_texture() const {
+Ref<Texture2D> StyleBoxTexture::get_texture() const {
return texture;
}
-void StyleBoxTexture::set_normal_map(Ref<Texture> p_normal_map) {
+void StyleBoxTexture::set_normal_map(Ref<Texture2D> p_normal_map) {
if (normal_map == p_normal_map)
return;
@@ -146,7 +146,7 @@ void StyleBoxTexture::set_normal_map(Ref<Texture> p_normal_map) {
emit_changed();
}
-Ref<Texture> StyleBoxTexture::get_normal_map() const {
+Ref<Texture2D> StyleBoxTexture::get_normal_map() const {
return normal_map;
}
@@ -335,8 +335,8 @@ void StyleBoxTexture::_bind_methods() {
ADD_SIGNAL(MethodInfo("texture_changed"));
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_normal_map", "get_normal_map");
+ 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::REAL, "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 3e0fffdcd9..1aa1a00c55 100644
--- a/scene/resources/style_box.h
+++ b/scene/resources/style_box.h
@@ -92,8 +92,8 @@ private:
float expand_margin[4];
float margin[4];
Rect2 region_rect;
- Ref<Texture> texture;
- Ref<Texture> normal_map;
+ Ref<Texture2D> texture;
+ Ref<Texture2D> normal_map;
bool draw_center;
Color modulate;
AxisStretchMode axis_h;
@@ -115,11 +115,11 @@ public:
void set_region_rect(const Rect2 &p_region_rect);
Rect2 get_region_rect() const;
- void set_texture(Ref<Texture> p_texture);
- Ref<Texture> get_texture() const;
+ void set_texture(Ref<Texture2D> p_texture);
+ Ref<Texture2D> get_texture() const;
- void set_normal_map(Ref<Texture> p_normal_map);
- Ref<Texture> get_normal_map() 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;
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index b7805b7e38..e28eaeb5f7 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -38,31 +38,31 @@
#include "scene/resources/bit_map.h"
#include "servers/camera/camera_feed.h"
-Size2 Texture::get_size() const {
+Size2 Texture2D::get_size() const {
return Size2(get_width(), get_height());
}
-bool Texture::is_pixel_opaque(int p_x, int p_y) const {
+bool Texture2D::is_pixel_opaque(int p_x, int p_y) const {
return true;
}
-void Texture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
+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 {
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, get_size()), get_rid(), false, p_modulate, p_transpose, normal_rid);
}
-void Texture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
+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 {
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, get_rid(), p_tile, p_modulate, p_transpose, normal_rid);
}
-void Texture::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<Texture> &p_normal_map, bool p_clip_uv) const {
+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, bool p_clip_uv) const {
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, p_rect, get_rid(), p_src_rect, p_modulate, p_transpose, normal_rid, p_clip_uv);
}
-bool Texture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect2 &r_rect, Rect2 &r_src_rect) const {
+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;
@@ -70,34 +70,21 @@ bool Texture::get_rect_region(const Rect2 &p_rect, const Rect2 &p_src_rect, Rect
return true;
}
-void Texture::_bind_methods() {
+void Texture2D::_bind_methods() {
- ClassDB::bind_method(D_METHOD("get_width"), &Texture::get_width);
- ClassDB::bind_method(D_METHOD("get_height"), &Texture::get_height);
- ClassDB::bind_method(D_METHOD("get_size"), &Texture::get_size);
- ClassDB::bind_method(D_METHOD("has_alpha"), &Texture::has_alpha);
- ClassDB::bind_method(D_METHOD("set_flags", "flags"), &Texture::set_flags);
- ClassDB::bind_method(D_METHOD("get_flags"), &Texture::get_flags);
- ClassDB::bind_method(D_METHOD("draw", "canvas_item", "position", "modulate", "transpose", "normal_map"), &Texture::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map"), &Texture::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
- ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &Texture::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true));
- ClassDB::bind_method(D_METHOD("get_data"), &Texture::get_data);
+ ClassDB::bind_method(D_METHOD("get_width"), &Texture2D::get_width);
+ 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"), &Texture2D::draw, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("draw_rect", "canvas_item", "rect", "tile", "modulate", "transpose", "normal_map"), &Texture2D::draw_rect, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()));
+ ClassDB::bind_method(D_METHOD("draw_rect_region", "canvas_item", "rect", "src_rect", "modulate", "transpose", "normal_map", "clip_uv"), &Texture2D::draw_rect_region, DEFVAL(Color(1, 1, 1)), DEFVAL(false), DEFVAL(Variant()), DEFVAL(true));
+ ClassDB::bind_method(D_METHOD("get_data"), &Texture2D::get_data);
- ADD_GROUP("Flags", "");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic Linear,Convert to Linear,Mirrored Repeat,Video Surface"), "set_flags", "get_flags");
ADD_GROUP("", "");
-
- BIND_ENUM_CONSTANT(FLAGS_DEFAULT);
- BIND_ENUM_CONSTANT(FLAG_MIPMAPS);
- BIND_ENUM_CONSTANT(FLAG_REPEAT);
- BIND_ENUM_CONSTANT(FLAG_FILTER);
- BIND_ENUM_CONSTANT(FLAG_ANISOTROPIC_FILTER);
- BIND_ENUM_CONSTANT(FLAG_CONVERT_TO_LINEAR);
- BIND_ENUM_CONSTANT(FLAG_MIRRORED_REPEAT);
- BIND_ENUM_CONSTANT(FLAG_VIDEO_SURFACE);
}
-Texture::Texture() {
+Texture2D::Texture2D() {
}
/////////////////////
@@ -108,12 +95,11 @@ void ImageTexture::reload_from_file() {
if (!path.is_resource_file())
return;
- uint32_t flags = get_flags();
Ref<Image> img;
img.instance();
if (ImageLoader::load_image(path, img) == OK) {
- create_from_image(img, flags);
+ create_from_image(img);
} else {
Resource::reload_from_file();
_change_notify();
@@ -124,19 +110,12 @@ void ImageTexture::reload_from_file() {
bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) {
if (p_name == "image")
- create_from_image(p_value, flags);
- else if (p_name == "flags")
- if (w * h == 0)
- flags = p_value;
- else
- set_flags(p_value);
+ create_from_image(p_value);
else if (p_name == "size") {
Size2 s = p_value;
w = s.width;
h = s.height;
- VisualServer::get_singleton()->texture_set_size_override(texture, w, h, 0);
- } else if (p_name == "_data") {
- _set_data(p_value);
+ VisualServer::get_singleton()->texture_set_size_override(texture, w, h);
} else
return false;
@@ -145,12 +124,8 @@ bool ImageTexture::_set(const StringName &p_name, const Variant &p_value) {
bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const {
- if (p_name == "image_data") {
-
- } else if (p_name == "image")
+ if (p_name == "image")
r_ret = get_data();
- else if (p_name == "flags")
- r_ret = flags;
else if (p_name == "size")
r_ret = Size2(w, h);
else
@@ -161,7 +136,6 @@ bool ImageTexture::_get(const StringName &p_name, Variant &r_ret) const {
void ImageTexture::_get_property_list(List<PropertyInfo> *p_list) const {
- p_list->push_back(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter,Anisotropic,sRGB,Mirrored Repeat"));
p_list->push_back(PropertyInfo(Variant::OBJECT, "image", PROPERTY_HINT_RESOURCE_TYPE, "Image", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_RESOURCE_NOT_PERSISTENT));
p_list->push_back(PropertyInfo(Variant::VECTOR2, "size", PROPERTY_HINT_NONE, ""));
}
@@ -178,79 +152,51 @@ void ImageTexture::_reload_hook(const RID &p_hook) {
ERR_FAIL_COND_MSG(err != OK, "Cannot load image from path '" + path + "'.");
- VisualServer::get_singleton()->texture_set_data(texture, img);
+ RID new_texture = VisualServer::get_singleton()->texture_2d_create(img);
+ VisualServer::get_singleton()->texture_replace(texture, new_texture);
_change_notify();
emit_changed();
}
-void ImageTexture::create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags) {
-
- flags = p_flags;
- VisualServer::get_singleton()->texture_allocate(texture, p_width, p_height, 0, p_format, VS::TEXTURE_TYPE_2D, p_flags);
- format = p_format;
- w = p_width;
- h = p_height;
- _change_notify();
- emit_changed();
-}
-void ImageTexture::create_from_image(const Ref<Image> &p_image, uint32_t p_flags) {
+void ImageTexture::create_from_image(const Ref<Image> &p_image) {
ERR_FAIL_COND(p_image.is_null());
- flags = p_flags;
w = p_image->get_width();
h = p_image->get_height();
format = p_image->get_format();
+ mipmaps = p_image->has_mipmaps();
- VisualServer::get_singleton()->texture_allocate(texture, p_image->get_width(), p_image->get_height(), 0, p_image->get_format(), VS::TEXTURE_TYPE_2D, p_flags);
- VisualServer::get_singleton()->texture_set_data(texture, p_image);
+ if (texture.is_null()) {
+ texture = VisualServer::get_singleton()->texture_2d_create(p_image);
+ } else {
+ RID new_texture = VisualServer::get_singleton()->texture_2d_create(p_image);
+ VisualServer::get_singleton()->texture_replace(texture, new_texture);
+ }
_change_notify();
emit_changed();
image_stored = true;
}
-void ImageTexture::set_flags(uint32_t p_flags) {
-
- if (flags == p_flags)
- return;
-
- flags = p_flags;
- if (w == 0 || h == 0) {
- return; //uninitialized, do not set to texture
- }
- VisualServer::get_singleton()->texture_set_flags(texture, p_flags);
- _change_notify("flags");
- emit_changed();
-}
-
-uint32_t ImageTexture::get_flags() const {
-
- return ImageTexture::flags;
-}
-
Image::Format ImageTexture::get_format() const {
return format;
}
-#ifndef DISABLE_DEPRECATED
-Error ImageTexture::load(const String &p_path) {
- WARN_DEPRECATED;
- Ref<Image> img;
- img.instance();
- Error err = img->load(p_path);
- if (err == OK) {
- create_from_image(img);
- }
- return err;
-}
-#endif
-void ImageTexture::set_data(const Ref<Image> &p_image) {
+void ImageTexture::update(const Ref<Image> &p_image, bool p_immediate) {
ERR_FAIL_COND(p_image.is_null());
+ ERR_FAIL_COND(texture.is_null());
+ ERR_FAIL_COND(p_image->get_width() != w || p_image->get_height() != h);
+ ERR_FAIL_COND(p_image->get_format() != format);
+ ERR_FAIL_COND(mipmaps != p_image->get_format());
- VisualServer::get_singleton()->texture_set_data(texture, p_image);
+ if (p_immediate) {
+ VisualServer::get_singleton()->texture_2d_update_immediate(texture, p_image);
+ } else {
+ VisualServer::get_singleton()->texture_2d_update(texture, p_image);
+ }
_change_notify();
emit_changed();
@@ -267,7 +213,7 @@ void ImageTexture::_resource_path_changed() {
Ref<Image> ImageTexture::get_data() const {
if (image_stored) {
- return VisualServer::get_singleton()->texture_get_data(texture);
+ return VisualServer::get_singleton()->texture_2d_get(texture);
} else {
return Ref<Image>();
}
@@ -285,6 +231,10 @@ int ImageTexture::get_height() const {
RID ImageTexture::get_rid() const {
+ if (texture.is_null()) {
+ //we are in trouble, create something temporary
+ texture = VisualServer::get_singleton()->texture_2d_placeholder_create();
+ }
return texture;
}
@@ -293,21 +243,21 @@ 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<Texture> &p_normal_map) const {
+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 {
if ((w | h) == 0)
return;
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid);
}
-void ImageTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
+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 {
if ((w | h) == 0)
return;
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid);
}
-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<Texture> &p_normal_map, 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, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const {
if ((w | h) == 0)
return;
@@ -357,7 +307,7 @@ void ImageTexture::set_size_override(const Size2 &p_size) {
w = s.x;
if (s.y != 0)
h = s.y;
- VisualServer::get_singleton()->texture_set_size_override(texture, w, h, 0);
+ VisualServer::get_singleton()->texture_set_size_override(texture, w, h);
}
void ImageTexture::set_path(const String &p_path, bool p_take_over) {
@@ -369,79 +319,29 @@ void ImageTexture::set_path(const String &p_path, bool p_take_over) {
Resource::set_path(p_path, p_take_over);
}
-void ImageTexture::set_storage(Storage p_storage) {
-
- storage = p_storage;
-}
-
-ImageTexture::Storage ImageTexture::get_storage() const {
-
- return storage;
-}
-
-void ImageTexture::set_lossy_storage_quality(float p_lossy_storage_quality) {
-
- lossy_storage_quality = p_lossy_storage_quality;
-}
-
-float ImageTexture::get_lossy_storage_quality() const {
-
- return lossy_storage_quality;
-}
-
-void ImageTexture::_set_data(Dictionary p_data) {
-
- Ref<Image> img = p_data["image"];
- ERR_FAIL_COND(!img.is_valid());
- uint32_t flags = p_data["flags"];
-
- create_from_image(img, flags);
-
- set_storage(Storage(p_data["storage"].operator int()));
- set_lossy_storage_quality(p_data["lossy_quality"]);
-
- set_size_override(p_data["size"]);
-};
-
void ImageTexture::_bind_methods() {
- ClassDB::bind_method(D_METHOD("create", "width", "height", "format", "flags"), &ImageTexture::create, DEFVAL(FLAGS_DEFAULT));
- ClassDB::bind_method(D_METHOD("create_from_image", "image", "flags"), &ImageTexture::create_from_image, DEFVAL(FLAGS_DEFAULT));
+ ClassDB::bind_method(D_METHOD("create_from_image", "image"), &ImageTexture::create_from_image);
ClassDB::bind_method(D_METHOD("get_format"), &ImageTexture::get_format);
-#ifndef DISABLE_DEPRECATED
- ClassDB::bind_method(D_METHOD("load", "path"), &ImageTexture::load);
-#endif
- ClassDB::bind_method(D_METHOD("set_data", "image"), &ImageTexture::set_data);
- ClassDB::bind_method(D_METHOD("set_storage", "mode"), &ImageTexture::set_storage);
- ClassDB::bind_method(D_METHOD("get_storage"), &ImageTexture::get_storage);
- ClassDB::bind_method(D_METHOD("set_lossy_storage_quality", "quality"), &ImageTexture::set_lossy_storage_quality);
- ClassDB::bind_method(D_METHOD("get_lossy_storage_quality"), &ImageTexture::get_lossy_storage_quality);
+ ClassDB::bind_method(D_METHOD("update", "image", "immediate"), &ImageTexture::update, DEFVAL(false));
ClassDB::bind_method(D_METHOD("set_size_override", "size"), &ImageTexture::set_size_override);
ClassDB::bind_method(D_METHOD("_reload_hook", "rid"), &ImageTexture::_reload_hook);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "storage", PROPERTY_HINT_ENUM, "Uncompressed,Compress Lossy,Compress Lossless"), "set_storage", "get_storage");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "lossy_quality", PROPERTY_HINT_RANGE, "0.0,1.0,0.01"), "set_lossy_storage_quality", "get_lossy_storage_quality");
-
- BIND_ENUM_CONSTANT(STORAGE_RAW);
- BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSY);
- BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSLESS);
}
ImageTexture::ImageTexture() {
w = h = 0;
- flags = FLAGS_DEFAULT;
- texture = VisualServer::get_singleton()->texture_create();
- storage = STORAGE_RAW;
- lossy_storage_quality = 0.7;
image_stored = false;
+ mipmaps = false;
format = Image::FORMAT_L8;
}
ImageTexture::~ImageTexture() {
- VisualServer::get_singleton()->free(texture);
+ if (texture.is_valid()) {
+ VisualServer::get_singleton()->free(texture);
+ }
}
//////////////////////////////////////////
@@ -463,12 +363,12 @@ void StreamTexture::_requested_3d(void *p_ud) {
request_3d_callback(stex);
}
-void StreamTexture::_requested_srgb(void *p_ud) {
+void StreamTexture::_requested_roughness(void *p_ud, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel) {
StreamTexture *st = (StreamTexture *)p_ud;
Ref<StreamTexture> stex(st);
- ERR_FAIL_COND(!request_srgb_callback);
- request_srgb_callback(stex);
+ ERR_FAIL_COND(!request_roughness_callback);
+ request_roughness_callback(stex, p_normal_path, p_roughness_channel);
}
void StreamTexture::_requested_normal(void *p_ud) {
@@ -480,19 +380,15 @@ void StreamTexture::_requested_normal(void *p_ud) {
}
StreamTexture::TextureFormatRequestCallback StreamTexture::request_3d_callback = NULL;
-StreamTexture::TextureFormatRequestCallback StreamTexture::request_srgb_callback = NULL;
+StreamTexture::TextureFormatRoughnessRequestCallback StreamTexture::request_roughness_callback = NULL;
StreamTexture::TextureFormatRequestCallback StreamTexture::request_normal_callback = NULL;
-uint32_t StreamTexture::get_flags() const {
-
- return flags;
-}
Image::Format StreamTexture::get_format() const {
return format;
}
-Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, int &flags, Ref<Image> &image, int p_size_limit) {
+Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, Ref<Image> &image, int p_size_limit) {
alpha_cache.unref();
@@ -513,15 +409,9 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_
th = f->get_16();
th_custom = f->get_16();
- flags = f->get_32(); //texture flags!
+ f->get_32(); //texture flags (ignore, no longer supported)
uint32_t df = f->get_32(); //data format
- /*
- print_line("width: " + itos(tw));
- print_line("height: " + itos(th));
- print_line("flags: " + itos(flags));
- print_line("df: " + itos(df));
- */
#ifdef TOOLS_ENABLED
if (request_3d_callback && df & FORMAT_BIT_DETECT_3D) {
@@ -532,15 +422,15 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_
VS::get_singleton()->texture_set_detect_3d_callback(texture, NULL, NULL);
}
- if (request_srgb_callback && df & FORMAT_BIT_DETECT_SRGB) {
+ if (request_roughness_callback && df & FORMAT_BIT_DETECT_ROUGNESS) {
//print_line("request detect srgb at " + p_path);
- VS::get_singleton()->texture_set_detect_srgb_callback(texture, _requested_srgb, this);
+ VS::get_singleton()->texture_set_detect_roughness_callback(texture, _requested_roughness, this);
} else {
//print_line("not requesting detect srgb at " + p_path);
- VS::get_singleton()->texture_set_detect_srgb_callback(texture, NULL, NULL);
+ VS::get_singleton()->texture_set_detect_roughness_callback(texture, NULL, NULL);
}
- if (request_srgb_callback && df & FORMAT_BIT_DETECT_NORMAL) {
+ if (request_normal_callback && df & FORMAT_BIT_DETECT_NORMAL) {
//print_line("request detect srgb at " + p_path);
VS::get_singleton()->texture_set_detect_normal_callback(texture, _requested_normal, this);
} else {
@@ -716,10 +606,10 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &tw_
Error StreamTexture::load(const String &p_path) {
- int lw, lh, lwc, lhc, lflags;
+ int lw, lh, lwc, lhc;
Ref<Image> image;
image.instance();
- Error err = _load_data(p_path, lw, lh, lwc, lhc, lflags, image);
+ Error err = _load_data(p_path, lw, lh, lwc, lhc, image);
if (err)
return err;
@@ -727,16 +617,18 @@ Error StreamTexture::load(const String &p_path) {
//temporarily set path if no path set for resource, helps find errors
VisualServer::get_singleton()->texture_set_path(texture, p_path);
}
- VS::get_singleton()->texture_allocate(texture, image->get_width(), image->get_height(), 0, image->get_format(), VS::TEXTURE_TYPE_2D, lflags);
- VS::get_singleton()->texture_set_data(texture, image);
- if (lwc || lhc) {
- VS::get_singleton()->texture_set_size_override(texture, lwc, lhc, 0);
+ if (texture.is_valid()) {
+ RID new_texture = VS::get_singleton()->texture_2d_create(image);
+ VS::get_singleton()->texture_replace(texture, new_texture);
} else {
+ texture = VS::get_singleton()->texture_2d_create(image);
+ }
+ if (lwc || lhc) {
+ VS::get_singleton()->texture_set_size_override(texture, lwc, lhc);
}
w = lwc ? lwc : lw;
h = lhc ? lhc : lh;
- flags = lflags;
path_to_file = p_path;
format = image->get_format();
@@ -759,24 +651,27 @@ int StreamTexture::get_height() const {
}
RID StreamTexture::get_rid() const {
+ if (!texture.is_valid()) {
+ texture = VS::get_singleton()->texture_2d_placeholder_create();
+ }
return texture;
}
-void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
+void StreamTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_modulate, bool p_transpose, const Ref<Texture2D> &p_normal_map) const {
if ((w | h) == 0)
return;
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, Rect2(p_pos, Size2(w, h)), texture, false, p_modulate, p_transpose, normal_rid);
}
-void StreamTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
+void StreamTexture::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 {
if ((w | h) == 0)
return;
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
VisualServer::get_singleton()->canvas_item_add_texture_rect(p_canvas_item, p_rect, texture, p_tile, p_modulate, p_transpose, normal_rid);
}
-void StreamTexture::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<Texture> &p_normal_map, bool p_clip_uv) const {
+void StreamTexture::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, bool p_clip_uv) const {
if ((w | h) == 0)
return;
@@ -791,7 +686,11 @@ bool StreamTexture::has_alpha() const {
Ref<Image> StreamTexture::get_data() const {
- return VS::get_singleton()->texture_get_data(texture);
+ if (texture.is_valid()) {
+ return VS::get_singleton()->texture_2d_get(texture);
+ } else {
+ return Ref<Image>();
+ }
}
bool StreamTexture::is_pixel_opaque(int p_x, int p_y) const {
@@ -829,12 +728,6 @@ bool StreamTexture::is_pixel_opaque(int p_x, int p_y) const {
return true;
}
-void StreamTexture::set_flags(uint32_t p_flags) {
- flags = p_flags;
- VS::get_singleton()->texture_set_flags(texture, flags);
- _change_notify("flags");
- emit_changed();
-}
void StreamTexture::reload_from_file() {
@@ -851,9 +744,6 @@ void StreamTexture::reload_from_file() {
}
void StreamTexture::_validate_property(PropertyInfo &property) const {
- if (property.name == "flags") {
- property.usage = PROPERTY_USAGE_NOEDITOR;
- }
}
void StreamTexture::_bind_methods() {
@@ -867,16 +757,15 @@ void StreamTexture::_bind_methods() {
StreamTexture::StreamTexture() {
format = Image::FORMAT_MAX;
- flags = 0;
w = 0;
h = 0;
-
- texture = VS::get_singleton()->texture_create();
}
StreamTexture::~StreamTexture() {
- VS::get_singleton()->free(texture);
+ if (texture.is_valid()) {
+ VS::get_singleton()->free(texture);
+ }
}
RES ResourceFormatLoaderStreamTexture::load(const String &p_path, const String &p_original_path, Error *r_error) {
@@ -944,21 +833,7 @@ bool AtlasTexture::has_alpha() const {
return false;
}
-void AtlasTexture::set_flags(uint32_t p_flags) {
-
- if (atlas.is_valid())
- atlas->set_flags(p_flags);
-}
-
-uint32_t AtlasTexture::get_flags() const {
-
- if (atlas.is_valid())
- return atlas->get_flags();
-
- return 0;
-}
-
-void AtlasTexture::set_atlas(const Ref<Texture> &p_atlas) {
+void AtlasTexture::set_atlas(const Ref<Texture2D> &p_atlas) {
ERR_FAIL_COND(p_atlas == this);
if (atlas == p_atlas)
@@ -967,7 +842,7 @@ void AtlasTexture::set_atlas(const Ref<Texture> &p_atlas) {
emit_changed();
_change_notify("atlas");
}
-Ref<Texture> AtlasTexture::get_atlas() const {
+Ref<Texture2D> AtlasTexture::get_atlas() const {
return atlas;
}
@@ -1026,13 +901,13 @@ void AtlasTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_filter_clip", "enable"), &AtlasTexture::set_filter_clip);
ClassDB::bind_method(D_METHOD("has_filter_clip"), &AtlasTexture::has_filter_clip);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_atlas", "get_atlas");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "atlas", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_atlas", "get_atlas");
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "region"), "set_region", "get_region");
ADD_PROPERTY(PropertyInfo(Variant::RECT2, "margin"), "set_margin", "get_margin");
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<Texture> &p_normal_map) const {
+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 {
if (!atlas.is_valid())
return;
@@ -1051,7 +926,7 @@ void AtlasTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
VS::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, 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<Texture> &p_normal_map) const {
+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 {
if (!atlas.is_valid())
return;
@@ -1072,7 +947,7 @@ void AtlasTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item, dr, atlas->get_rid(), rc, p_modulate, p_transpose, normal_rid, 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<Texture> &p_normal_map, 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, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const {
//this might not necessarily work well if using a rect, needs to be fixed properly
if (!atlas.is_valid())
@@ -1157,13 +1032,6 @@ bool MeshTexture::has_alpha() const {
return false;
}
-void MeshTexture::set_flags(uint32_t p_flags) {
-}
-
-uint32_t MeshTexture::get_flags() const {
- return 0;
-}
-
void MeshTexture::set_mesh(const Ref<Mesh> &p_mesh) {
mesh = p_mesh;
}
@@ -1180,15 +1048,15 @@ Size2 MeshTexture::get_image_size() const {
return size;
}
-void MeshTexture::set_base_texture(const Ref<Texture> &p_texture) {
+void MeshTexture::set_base_texture(const Ref<Texture2D> &p_texture) {
base_texture = p_texture;
}
-Ref<Texture> MeshTexture::get_base_texture() const {
+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<Texture> &p_normal_map) const {
+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 {
if (mesh.is_null() || base_texture.is_null()) {
return;
@@ -1202,7 +1070,7 @@ void MeshTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_mo
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_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<Texture> &p_normal_map) const {
+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 {
if (mesh.is_null() || base_texture.is_null()) {
return;
}
@@ -1224,7 +1092,7 @@ void MeshTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile,
RID normal_rid = p_normal_map.is_valid() ? p_normal_map->get_rid() : RID();
VisualServer::get_singleton()->canvas_item_add_mesh(p_canvas_item, mesh->get_rid(), xform, p_modulate, base_texture->get_rid(), normal_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<Texture> &p_normal_map, 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, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const {
if (mesh.is_null() || base_texture.is_null()) {
return;
@@ -1266,7 +1134,7 @@ void MeshTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_base_texture"), &MeshTexture::get_base_texture);
ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "mesh", PROPERTY_HINT_RESOURCE_TYPE, "Mesh"), "set_mesh", "get_mesh");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "base_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_base_texture", "get_base_texture");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "base_texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_base_texture", "get_base_texture");
ADD_PROPERTY(PropertyInfo(Variant::VECTOR2, "image_size", PROPERTY_HINT_RANGE, "0,16384,1"), "set_image_size", "get_image_size");
}
@@ -1298,22 +1166,7 @@ bool LargeTexture::has_alpha() const {
return false;
}
-void LargeTexture::set_flags(uint32_t p_flags) {
-
- for (int i = 0; i < pieces.size(); i++) {
- pieces.write[i].texture->set_flags(p_flags);
- }
-}
-
-uint32_t LargeTexture::get_flags() const {
-
- if (pieces.size())
- return pieces[0].texture->get_flags();
-
- return 0;
-}
-
-int LargeTexture::add_piece(const Point2 &p_offset, const Ref<Texture> &p_texture) {
+int LargeTexture::add_piece(const Point2 &p_offset, const Ref<Texture2D> &p_texture) {
ERR_FAIL_COND_V(p_texture.is_null(), -1);
Piece p;
@@ -1330,7 +1183,7 @@ void LargeTexture::set_piece_offset(int p_idx, const Point2 &p_offset) {
pieces.write[p_idx].offset = p_offset;
};
-void LargeTexture::set_piece_texture(int p_idx, const Ref<Texture> &p_texture) {
+void LargeTexture::set_piece_texture(int p_idx, const Ref<Texture2D> &p_texture) {
ERR_FAIL_COND(p_texture == this);
ERR_FAIL_COND(p_texture.is_null());
@@ -1378,9 +1231,9 @@ Vector2 LargeTexture::get_piece_offset(int p_idx) const {
ERR_FAIL_INDEX_V(p_idx, pieces.size(), Vector2());
return pieces[p_idx].offset;
}
-Ref<Texture> LargeTexture::get_piece_texture(int p_idx) const {
+Ref<Texture2D> LargeTexture::get_piece_texture(int p_idx) const {
- ERR_FAIL_INDEX_V(p_idx, pieces.size(), Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_idx, pieces.size(), Ref<Texture2D>());
return pieces[p_idx].texture;
}
Ref<Image> LargeTexture::to_image() const {
@@ -1413,7 +1266,7 @@ 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<Texture> &p_normal_map) const {
+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 {
for (int i = 0; i < pieces.size(); i++) {
@@ -1422,7 +1275,7 @@ void LargeTexture::draw(RID p_canvas_item, const Point2 &p_pos, const Color &p_m
}
}
-void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile, const Color &p_modulate, bool p_transpose, const Ref<Texture> &p_normal_map) const {
+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 {
//tiling not supported for this
if (size.x == 0 || size.y == 0)
@@ -1436,7 +1289,7 @@ void LargeTexture::draw_rect(RID p_canvas_item, const Rect2 &p_rect, bool p_tile
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);
}
}
-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<Texture> &p_normal_map, 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, const Ref<Texture2D> &p_normal_map, bool p_clip_uv) const {
//tiling not supported for this
if (p_src_rect.size.x == 0 || p_src_rect.size.y == 0)
@@ -1479,211 +1332,7 @@ bool LargeTexture::is_pixel_opaque(int p_x, int p_y) const {
LargeTexture::LargeTexture() {
}
-///////////////////////////////////////////////
-
-void CubeMap::set_flags(uint32_t p_flags) {
-
- flags = p_flags;
- if (_is_valid())
- VS::get_singleton()->texture_set_flags(cubemap, flags);
-}
-
-uint32_t CubeMap::get_flags() const {
-
- return flags;
-}
-
-void CubeMap::set_side(Side p_side, const Ref<Image> &p_image) {
-
- ERR_FAIL_COND(p_image.is_null());
- ERR_FAIL_COND(p_image->empty());
- ERR_FAIL_INDEX(p_side, 6);
-
- if (!_is_valid()) {
- format = p_image->get_format();
- w = p_image->get_width();
- h = p_image->get_height();
- VS::get_singleton()->texture_allocate(cubemap, w, h, 0, p_image->get_format(), VS::TEXTURE_TYPE_CUBEMAP, flags);
- }
-
- VS::get_singleton()->texture_set_data(cubemap, p_image, VS::CubeMapSide(p_side));
- valid[p_side] = true;
-}
-
-Ref<Image> CubeMap::get_side(Side p_side) const {
-
- ERR_FAIL_INDEX_V(p_side, 6, Ref<Image>());
- if (!valid[p_side])
- return Ref<Image>();
- return VS::get_singleton()->texture_get_data(cubemap, VS::CubeMapSide(p_side));
-}
-
-Image::Format CubeMap::get_format() const {
-
- return format;
-}
-int CubeMap::get_width() const {
-
- return w;
-}
-int CubeMap::get_height() const {
-
- return h;
-}
-
-RID CubeMap::get_rid() const {
-
- return cubemap;
-}
-
-void CubeMap::set_storage(Storage p_storage) {
-
- storage = p_storage;
-}
-
-CubeMap::Storage CubeMap::get_storage() const {
-
- return storage;
-}
-
-void CubeMap::set_lossy_storage_quality(float p_lossy_storage_quality) {
-
- lossy_storage_quality = p_lossy_storage_quality;
-}
-
-float CubeMap::get_lossy_storage_quality() const {
-
- return lossy_storage_quality;
-}
-
-void CubeMap::set_path(const String &p_path, bool p_take_over) {
-
- if (cubemap.is_valid()) {
- VisualServer::get_singleton()->texture_set_path(cubemap, p_path);
- }
-
- Resource::set_path(p_path, p_take_over);
-}
-
-bool CubeMap::_set(const StringName &p_name, const Variant &p_value) {
-
- if (p_name == "side/left") {
- set_side(SIDE_LEFT, p_value);
- } else if (p_name == "side/right") {
- set_side(SIDE_RIGHT, p_value);
- } else if (p_name == "side/bottom") {
- set_side(SIDE_BOTTOM, p_value);
- } else if (p_name == "side/top") {
- set_side(SIDE_TOP, p_value);
- } else if (p_name == "side/front") {
- set_side(SIDE_FRONT, p_value);
- } else if (p_name == "side/back") {
- set_side(SIDE_BACK, p_value);
- } else if (p_name == "storage") {
- storage = Storage(p_value.operator int());
- } else if (p_name == "lossy_quality") {
- lossy_storage_quality = p_value;
- } else
- return false;
-
- return true;
-}
-
-bool CubeMap::_get(const StringName &p_name, Variant &r_ret) const {
-
- if (p_name == "side/left") {
- r_ret = get_side(SIDE_LEFT);
- } else if (p_name == "side/right") {
- r_ret = get_side(SIDE_RIGHT);
- } else if (p_name == "side/bottom") {
- r_ret = get_side(SIDE_BOTTOM);
- } else if (p_name == "side/top") {
- r_ret = get_side(SIDE_TOP);
- } else if (p_name == "side/front") {
- r_ret = get_side(SIDE_FRONT);
- } else if (p_name == "side/back") {
- r_ret = get_side(SIDE_BACK);
- } else if (p_name == "storage") {
- r_ret = storage;
- } else if (p_name == "lossy_quality") {
- r_ret = lossy_storage_quality;
- } else
- return false;
-
- return true;
-}
-
-void CubeMap::_get_property_list(List<PropertyInfo> *p_list) const {
-
- p_list->push_back(PropertyInfo(Variant::OBJECT, "side/left", PROPERTY_HINT_RESOURCE_TYPE, "Image"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "side/right", PROPERTY_HINT_RESOURCE_TYPE, "Image"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "side/bottom", PROPERTY_HINT_RESOURCE_TYPE, "Image"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "side/top", PROPERTY_HINT_RESOURCE_TYPE, "Image"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "side/front", PROPERTY_HINT_RESOURCE_TYPE, "Image"));
- p_list->push_back(PropertyInfo(Variant::OBJECT, "side/back", PROPERTY_HINT_RESOURCE_TYPE, "Image"));
-}
-
-void CubeMap::_bind_methods() {
-
- ClassDB::bind_method(D_METHOD("get_width"), &CubeMap::get_width);
- ClassDB::bind_method(D_METHOD("get_height"), &CubeMap::get_height);
- ClassDB::bind_method(D_METHOD("set_flags", "flags"), &CubeMap::set_flags);
- ClassDB::bind_method(D_METHOD("get_flags"), &CubeMap::get_flags);
- ClassDB::bind_method(D_METHOD("set_side", "side", "image"), &CubeMap::set_side);
- ClassDB::bind_method(D_METHOD("get_side", "side"), &CubeMap::get_side);
- ClassDB::bind_method(D_METHOD("set_storage", "mode"), &CubeMap::set_storage);
- ClassDB::bind_method(D_METHOD("get_storage"), &CubeMap::get_storage);
- ClassDB::bind_method(D_METHOD("set_lossy_storage_quality", "quality"), &CubeMap::set_lossy_storage_quality);
- ClassDB::bind_method(D_METHOD("get_lossy_storage_quality"), &CubeMap::get_lossy_storage_quality);
-
- ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter"), "set_flags", "get_flags");
- ADD_PROPERTY(PropertyInfo(Variant::INT, "storage_mode", PROPERTY_HINT_ENUM, "Raw,Lossy Compressed,Lossless Compressed"), "set_storage", "get_storage");
- ADD_PROPERTY(PropertyInfo(Variant::REAL, "lossy_storage_quality"), "set_lossy_storage_quality", "get_lossy_storage_quality");
-
- BIND_ENUM_CONSTANT(STORAGE_RAW);
- BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSY);
- BIND_ENUM_CONSTANT(STORAGE_COMPRESS_LOSSLESS);
-
- BIND_ENUM_CONSTANT(SIDE_LEFT);
- BIND_ENUM_CONSTANT(SIDE_RIGHT);
- BIND_ENUM_CONSTANT(SIDE_BOTTOM);
- BIND_ENUM_CONSTANT(SIDE_TOP);
- BIND_ENUM_CONSTANT(SIDE_FRONT);
- BIND_ENUM_CONSTANT(SIDE_BACK);
-
- BIND_ENUM_CONSTANT(FLAG_MIPMAPS);
- BIND_ENUM_CONSTANT(FLAG_REPEAT);
- BIND_ENUM_CONSTANT(FLAG_FILTER);
- BIND_ENUM_CONSTANT(FLAGS_DEFAULT);
-}
-
-CubeMap::CubeMap() {
-
- w = h = 0;
- flags = FLAGS_DEFAULT;
- for (int i = 0; i < 6; i++)
- valid[i] = false;
- cubemap = VisualServer::get_singleton()->texture_create();
- storage = STORAGE_RAW;
- lossy_storage_quality = 0.7;
- format = Image::FORMAT_BPTC_RGBA;
-}
-
-CubeMap::~CubeMap() {
-
- VisualServer::get_singleton()->free(cubemap);
-}
-
-/* BIND_ENUM(CubeMapSize);
- BIND_ENUM_CONSTANT( FLAG_CUBEMAP );
- BIND_ENUM_CONSTANT( CUBEMAP_LEFT );
- BIND_ENUM_CONSTANT( CUBEMAP_RIGHT );
- BIND_ENUM_CONSTANT( CUBEMAP_BOTTOM );
- BIND_ENUM_CONSTANT( CUBEMAP_TOP );
- BIND_ENUM_CONSTANT( CUBEMAP_FRONT );
- BIND_ENUM_CONSTANT( CUBEMAP_BACK );
-*/
-///////////////////////////
+///////////////////
void CurveTexture::_bind_methods() {
@@ -1761,8 +1410,12 @@ void CurveTexture::_update() {
Ref<Image> image = memnew(Image(_width, 1, false, Image::FORMAT_RF, data));
- VS::get_singleton()->texture_allocate(_texture, _width, 1, 0, Image::FORMAT_RF, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_FILTER);
- VS::get_singleton()->texture_set_data(_texture, image);
+ if (_texture.is_valid()) {
+ RID new_texture = VS::get_singleton()->texture_2d_create(image);
+ VS::get_singleton()->texture_replace(_texture, new_texture);
+ } else {
+ _texture = VS::get_singleton()->texture_2d_create(image);
+ }
emit_changed();
}
@@ -1774,15 +1427,19 @@ Ref<Curve> CurveTexture::get_curve() const {
RID CurveTexture::get_rid() const {
+ if (!_texture.is_valid()) {
+ _texture = VS::get_singleton()->texture_2d_placeholder_create();
+ }
return _texture;
}
CurveTexture::CurveTexture() {
_width = 2048;
- _texture = VS::get_singleton()->texture_create();
}
CurveTexture::~CurveTexture() {
- VS::get_singleton()->free(_texture);
+ if (_texture.is_valid()) {
+ VS::get_singleton()->free(_texture);
+ }
}
//////////////////
@@ -1796,12 +1453,13 @@ GradientTexture::GradientTexture() {
update_pending = false;
width = 2048;
- texture = VS::get_singleton()->texture_create();
_queue_update();
}
GradientTexture::~GradientTexture() {
- VS::get_singleton()->free(texture);
+ if (texture.is_valid()) {
+ VS::get_singleton()->free(texture);
+ }
}
void GradientTexture::_bind_methods() {
@@ -1871,8 +1529,12 @@ void GradientTexture::_update() {
Ref<Image> image = memnew(Image(width, 1, false, Image::FORMAT_RGBA8, data));
- VS::get_singleton()->texture_allocate(texture, width, 1, 0, Image::FORMAT_RGBA8, VS::TEXTURE_TYPE_2D, VS::TEXTURE_FLAG_FILTER);
- VS::get_singleton()->texture_set_data(texture, image);
+ if (texture.is_valid()) {
+ RID new_texture = VS::get_singleton()->texture_2d_create(image);
+ VS::get_singleton()->texture_replace(texture, new_texture);
+ } else {
+ texture = VS::get_singleton()->texture_2d_create(image);
+ }
emit_changed();
}
@@ -1888,7 +1550,10 @@ int GradientTexture::get_width() const {
}
Ref<Image> GradientTexture::get_data() const {
- return VisualServer::get_singleton()->texture_get_data(texture);
+ if (!texture.is_valid()) {
+ return Ref<Image>();
+ }
+ return VisualServer::get_singleton()->texture_2d_get(texture);
}
//////////////////////////////////////
@@ -1898,10 +1563,10 @@ void ProxyTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_base", "base"), &ProxyTexture::set_base);
ClassDB::bind_method(D_METHOD("get_base"), &ProxyTexture::get_base);
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "base", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_base", "get_base");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "base", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_base", "get_base");
}
-void ProxyTexture::set_base(const Ref<Texture> &p_texture) {
+void ProxyTexture::set_base(const Ref<Texture2D> &p_texture) {
ERR_FAIL_COND(p_texture == this);
base = p_texture;
@@ -1912,7 +1577,7 @@ void ProxyTexture::set_base(const Ref<Texture> &p_texture) {
}
}
-Ref<Texture> ProxyTexture::get_base() const {
+Ref<Texture2D> ProxyTexture::get_base() const {
return base;
}
@@ -1941,24 +1606,14 @@ bool ProxyTexture::has_alpha() const {
return false;
}
-void ProxyTexture::set_flags(uint32_t p_flags) {
-}
-
-uint32_t ProxyTexture::get_flags() const {
-
- if (base.is_valid())
- return base->get_flags();
- return 0;
-}
-
ProxyTexture::ProxyTexture() {
- proxy = VS::get_singleton()->texture_create();
+ //proxy = VS::get_singleton()->texture_create();
}
ProxyTexture::~ProxyTexture() {
- VS::get_singleton()->free(proxy);
+ //VS::get_singleton()->free(proxy);
}
//////////////////////////////////////////////
@@ -2018,7 +1673,7 @@ int AnimatedTexture::get_frames() const {
return frame_count;
}
-void AnimatedTexture::set_frame_texture(int p_frame, const Ref<Texture> &p_texture) {
+void AnimatedTexture::set_frame_texture(int p_frame, const Ref<Texture2D> &p_texture) {
ERR_FAIL_COND(p_texture == this);
ERR_FAIL_INDEX(p_frame, MAX_FRAMES);
@@ -2027,8 +1682,8 @@ void AnimatedTexture::set_frame_texture(int p_frame, const Ref<Texture> &p_textu
frames[p_frame].texture = p_texture;
}
-Ref<Texture> AnimatedTexture::get_frame_texture(int p_frame) const {
- ERR_FAIL_INDEX_V(p_frame, MAX_FRAMES, Ref<Texture>());
+Ref<Texture2D> AnimatedTexture::get_frame_texture(int p_frame) const {
+ ERR_FAIL_INDEX_V(p_frame, MAX_FRAMES, Ref<Texture2D>());
RWLockRead r(rw_lock);
@@ -2113,19 +1768,6 @@ bool AnimatedTexture::is_pixel_opaque(int p_x, int p_y) const {
return true;
}
-void AnimatedTexture::set_flags(uint32_t p_flags) {
-}
-uint32_t AnimatedTexture::get_flags() const {
-
- RWLockRead r(rw_lock);
-
- if (!frames[current_frame].texture.is_valid()) {
- return 0;
- }
-
- return frames[current_frame].texture->get_flags();
-}
-
void AnimatedTexture::_validate_property(PropertyInfo &property) const {
String prop = property.name;
@@ -2156,7 +1798,7 @@ void AnimatedTexture::_bind_methods() {
ADD_PROPERTY(PropertyInfo(Variant::REAL, "fps", PROPERTY_HINT_RANGE, "0,1024,0.1"), "set_fps", "get_fps");
for (int i = 0; i < MAX_FRAMES; i++) {
- ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "frame_" + itos(i) + "/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_frame_texture", "get_frame_texture", i);
+ ADD_PROPERTYI(PropertyInfo(Variant::OBJECT, "frame_" + itos(i) + "/texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_frame_texture", "get_frame_texture", i);
ADD_PROPERTYI(PropertyInfo(Variant::REAL, "frame_" + itos(i) + "/delay_sec", PROPERTY_HINT_RANGE, "0.0,16.0,0.01", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_INTERNAL), "set_frame_delay", "get_frame_delay", i);
}
@@ -2164,7 +1806,7 @@ void AnimatedTexture::_bind_methods() {
}
AnimatedTexture::AnimatedTexture() {
- proxy = VS::get_singleton()->texture_create();
+ //proxy = VS::get_singleton()->texture_create();
VisualServer::get_singleton()->texture_set_force_redraw_if_visible(proxy, true);
time = 0;
frame_count = 1;
@@ -2188,18 +1830,6 @@ AnimatedTexture::~AnimatedTexture() {
}
///////////////////////////////
-void TextureLayered::set_flags(uint32_t p_flags) {
- flags = p_flags;
-
- if (texture.is_valid()) {
- VS::get_singleton()->texture_set_flags(texture, flags);
- }
-}
-
-uint32_t TextureLayered::get_flags() const {
- return flags;
-}
-
Image::Format TextureLayered::get_format() const {
return format;
}
@@ -2212,82 +1842,93 @@ uint32_t TextureLayered::get_height() const {
return height;
}
-uint32_t TextureLayered::get_depth() const {
- return depth;
+uint32_t TextureLayered::get_layers() const {
+ return layers;
}
-void TextureLayered::_set_data(const Dictionary &p_data) {
- ERR_FAIL_COND(!p_data.has("width"));
- ERR_FAIL_COND(!p_data.has("height"));
- ERR_FAIL_COND(!p_data.has("depth"));
- ERR_FAIL_COND(!p_data.has("format"));
- ERR_FAIL_COND(!p_data.has("flags"));
- ERR_FAIL_COND(!p_data.has("layers"));
- int w = p_data["width"];
- int h = p_data["height"];
- int d = p_data["depth"];
- Image::Format format = Image::Format(int(p_data["format"]));
- int flags = p_data["flags"];
- Array layers = p_data["layers"];
- ERR_FAIL_COND(layers.size() != d);
+Error TextureLayered::_create_from_images(const Array &p_images) {
+ Vector<Ref<Image> > images;
+ for (int i = 0; i < p_images.size(); i++) {
+ Ref<Image> img = p_images[i];
+ ERR_FAIL_COND_V(img.is_null(), ERR_INVALID_PARAMETER);
+ images.push_back(img);
+ }
- create(w, h, d, format, flags);
+ return create_from_images(images);
+}
- for (int i = 0; i < layers.size(); i++) {
- Ref<Image> img = layers[i];
- ERR_CONTINUE(!img.is_valid());
- ERR_CONTINUE(img->get_format() != format);
- ERR_CONTINUE(img->get_width() != w);
- ERR_CONTINUE(img->get_height() != h);
- set_layer_data(img, i);
+Array TextureLayered::_get_images() const {
+ Array images;
+ for (int i = 0; i < layers; i++) {
+ images.push_back(get_layer_data(i));
}
+ return images;
}
-Dictionary TextureLayered::_get_data() const {
- Dictionary d;
- d["width"] = width;
- d["height"] = height;
- d["depth"] = depth;
- d["flags"] = flags;
- d["format"] = format;
+Error TextureLayered::create_from_images(Vector<Ref<Image> > p_images) {
- Array layers;
- for (int i = 0; i < depth; i++) {
- layers.push_back(get_layer_data(i));
+ int new_layers = p_images.size();
+ ERR_FAIL_COND_V(new_layers == 0, ERR_INVALID_PARAMETER);
+ if (layered_type == VS::TEXTURE_LAYERED_CUBEMAP) {
+ ERR_FAIL_COND_V_MSG(new_layers != 6, ERR_INVALID_PARAMETER,
+ "Cubemaps require exactly 6 layers");
+ } else if (layered_type == VS::TEXTURE_LAYERED_CUBEMAP_ARRAY) {
+ ERR_FAIL_COND_V_MSG((new_layers % 6) != 0, ERR_INVALID_PARAMETER,
+ "Cubemap array layers must be a multiple of 6");
}
- d["layers"] = layers;
- return d;
-}
-void TextureLayered::create(uint32_t p_width, uint32_t p_height, uint32_t p_depth, Image::Format p_format, uint32_t p_flags) {
- VS::get_singleton()->texture_allocate(texture, p_width, p_height, p_depth, p_format, is_3d ? VS::TEXTURE_TYPE_3D : VS::TEXTURE_TYPE_2D_ARRAY, p_flags);
+ ERR_FAIL_COND_V(p_images[0].is_null() || p_images[0]->empty(), ERR_INVALID_PARAMETER);
- width = p_width;
- height = p_height;
- depth = p_depth;
- format = p_format;
- flags = p_flags;
-}
+ Image::Format new_format = p_images[0]->get_format();
+ int new_width = p_images[0]->get_width();
+ int new_height = p_images[0]->get_height();
+ bool new_mipmaps = p_images[0]->has_mipmaps();
-void TextureLayered::set_layer_data(const Ref<Image> &p_image, int p_layer) {
- ERR_FAIL_COND(!texture.is_valid());
- ERR_FAIL_COND(!p_image.is_valid());
- VS::get_singleton()->texture_set_data(texture, p_image, p_layer);
-}
+ for (int i = 1; i < p_images.size(); i++) {
+ ERR_FAIL_COND_V_MSG(p_images[i]->get_format() != new_format, ERR_INVALID_PARAMETER,
+ "All images must share the same format");
+ ERR_FAIL_COND_V_MSG(p_images[i]->get_width() != new_width || p_images[i]->get_height() != new_height, ERR_INVALID_PARAMETER,
+ "All images must share the same dimensions");
+ ERR_FAIL_COND_V_MSG(p_images[i]->has_mipmaps() != new_mipmaps, ERR_INVALID_PARAMETER,
+ "All images must share the usage of mipmaps");
+ }
-Ref<Image> TextureLayered::get_layer_data(int p_layer) const {
+ if (texture.is_valid()) {
+ RID new_texture = VS::get_singleton()->texture_2d_layered_create(p_images, layered_type);
+ ERR_FAIL_COND_V(!new_texture.is_valid(), ERR_CANT_CREATE);
+ VS::get_singleton()->texture_replace(texture, new_texture);
+ } else {
+ texture = VS::get_singleton()->texture_2d_layered_create(p_images, layered_type);
+ ERR_FAIL_COND_V(!texture.is_valid(), ERR_CANT_CREATE);
+ }
- ERR_FAIL_COND_V(!texture.is_valid(), Ref<Image>());
- return VS::get_singleton()->texture_get_data(texture, p_layer);
+ format = new_format;
+ width = new_width;
+ height = new_height;
+ layers = new_layers;
+ mipmaps = new_mipmaps;
+ return OK;
}
-void TextureLayered::set_data_partial(const Ref<Image> &p_image, int p_x_ofs, int p_y_ofs, int p_z, int p_mipmap) {
- ERR_FAIL_COND(!texture.is_valid());
- ERR_FAIL_COND(!p_image.is_valid());
- VS::get_singleton()->texture_set_data_partial(texture, p_image, 0, 0, p_image->get_width(), p_image->get_height(), p_x_ofs, p_y_ofs, p_mipmap, p_z);
+void TextureLayered::update_layer(const Ref<Image> &p_image, int p_layer) {
+ ERR_FAIL_COND(texture.is_valid());
+ ERR_FAIL_COND(p_image.is_null());
+ ERR_FAIL_COND(p_image->get_format() != format);
+ ERR_FAIL_COND(p_image->get_width() != width || p_image->get_height() != height);
+ ERR_FAIL_INDEX(p_layer, layers);
+ ERR_FAIL_COND(p_image->has_mipmaps() != mipmaps);
+ VS::get_singleton()->texture_2d_update(texture, p_image, p_layer);
+}
+
+Ref<Image> TextureLayered::get_layer_data(int p_layer) const {
+ ERR_FAIL_INDEX_V(p_layer, layers, Ref<Image>());
+ return VS::get_singleton()->texture_2d_layer_get(texture, p_layer);
}
RID TextureLayered::get_rid() const {
+ if (texture.is_null()) {
+ texture = VS::get_singleton()->texture_2d_layered_placeholder_create();
+ }
return texture;
}
@@ -2300,42 +1941,29 @@ void TextureLayered::set_path(const String &p_path, bool p_take_over) {
}
void TextureLayered::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_flags", "flags"), &TextureLayered::set_flags);
- ClassDB::bind_method(D_METHOD("get_flags"), &TextureLayered::get_flags);
ClassDB::bind_method(D_METHOD("get_format"), &TextureLayered::get_format);
ClassDB::bind_method(D_METHOD("get_width"), &TextureLayered::get_width);
ClassDB::bind_method(D_METHOD("get_height"), &TextureLayered::get_height);
- ClassDB::bind_method(D_METHOD("get_depth"), &TextureLayered::get_depth);
+ ClassDB::bind_method(D_METHOD("get_layers"), &TextureLayered::get_layers);
- ClassDB::bind_method(D_METHOD("create", "width", "height", "depth", "format", "flags"), &TextureLayered::create, DEFVAL(FLAGS_DEFAULT));
- ClassDB::bind_method(D_METHOD("set_layer_data", "image", "layer"), &TextureLayered::set_layer_data);
+ ClassDB::bind_method(D_METHOD("create_from_images", "images"), &TextureLayered::_create_from_images);
+ ClassDB::bind_method(D_METHOD("update_layer", "image", "layer"), &TextureLayered::update_layer);
ClassDB::bind_method(D_METHOD("get_layer_data", "layer"), &TextureLayered::get_layer_data);
- ClassDB::bind_method(D_METHOD("set_data_partial", "image", "x_offset", "y_offset", "layer", "mipmap"), &TextureLayered::set_data_partial, DEFVAL(0));
-
- ClassDB::bind_method(D_METHOD("_set_data", "data"), &TextureLayered::_set_data);
- ClassDB::bind_method(D_METHOD("_get_data"), &TextureLayered::_get_data);
- ADD_PROPERTY(PropertyInfo(Variant::INT, "flags", PROPERTY_HINT_FLAGS, "Mipmaps,Repeat,Filter"), "set_flags", "get_flags");
- ADD_PROPERTY(PropertyInfo(Variant::DICTIONARY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NOEDITOR), "_set_data", "_get_data");
+ ClassDB::bind_method(D_METHOD("_get_images"), &TextureLayered::_get_images);
- BIND_ENUM_CONSTANT(FLAG_MIPMAPS);
- BIND_ENUM_CONSTANT(FLAG_REPEAT);
- BIND_ENUM_CONSTANT(FLAG_FILTER);
- BIND_ENUM_CONSTANT(FLAGS_DEFAULT);
+ ADD_PROPERTY(PropertyInfo(Variant::ARRAY, "_images", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_INTERNAL), "create_from_images", "_get_images");
}
-TextureLayered::TextureLayered(bool p_3d) {
- is_3d = p_3d;
+TextureLayered::TextureLayered(VisualServer::TextureLayeredType p_layered_type) {
+ layered_type = p_layered_type;
format = Image::FORMAT_MAX;
- flags = FLAGS_DEFAULT;
width = 0;
height = 0;
- depth = 0;
-
- texture = VS::get_singleton()->texture_create();
+ layers = 0;
}
TextureLayered::~TextureLayered() {
@@ -2351,15 +1979,19 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String
}
Ref<TextureLayered> lt;
- Ref<Texture3D> tex3d;
- Ref<TextureArray> texarr;
-
- if (p_path.ends_with("tex3d")) {
- tex3d.instance();
- lt = tex3d;
- } else if (p_path.ends_with("texarr")) {
- texarr.instance();
- lt = texarr;
+
+ if (p_path.ends_with("cube")) {
+ Ref<Cubemap> cube;
+ cube.instance();
+ lt = cube;
+ } else if (p_path.ends_with("cubearr")) {
+ Ref<CubemapArray> cubearr;
+ cubearr.instance();
+ lt = cubearr;
+ } else if (p_path.ends_with("tex2darr")) {
+ Ref<Texture2DArray> t2darr;
+ t2darr.instance();
+ lt = t2darr;
} else {
ERR_FAIL_V_MSG(RES(), "Unrecognized layered texture extension.");
}
@@ -2367,21 +1999,18 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String
FileAccess *f = FileAccess::open(p_path, FileAccess::READ);
ERR_FAIL_COND_V_MSG(!f, RES(), "Cannot open file '" + p_path + "'.");
- uint8_t header[5] = { 0, 0, 0, 0, 0 };
- f->get_buffer(header, 4);
+ char header[5] = { 0, 0, 0, 0, 0 };
+ f->get_buffer((uint8_t *)header, 4);
- if (header[0] == 'G' && header[1] == 'D' && header[2] == '3' && header[3] == 'T') {
- if (tex3d.is_null()) {
- f->close();
- memdelete(f);
- ERR_FAIL_COND_V(tex3d.is_null(), RES());
- }
- } else if (header[0] == 'G' && header[1] == 'D' && header[2] == 'A' && header[3] == 'T') {
- if (texarr.is_null()) {
- f->close();
- memdelete(f);
- ERR_FAIL_COND_V(texarr.is_null(), RES());
+ if (String(header) != "GDLT") {
+ f->close();
+ memdelete(f);
+ if (r_error) {
+ *r_error = ERR_FILE_CORRUPT;
}
+ // FIXME: It's bogus that we fail in both branches. Seen while rebasing
+ // vulkan branch on master branch.
+ ERR_FAIL_V_MSG(RES(), "Unrecognized layered texture.");
} else {
f->close();
@@ -2392,12 +2021,11 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String
int tw = f->get_32();
int th = f->get_32();
int td = f->get_32();
- int flags = f->get_32(); //texture flags!
+ bool use_mipmaps = f->get_32() != 0; //texture flags (deprecated)
Image::Format format = Image::Format(f->get_32());
uint32_t compression = f->get_32(); // 0 - lossless (PNG), 1 - vram, 2 - uncompressed
- lt->create(tw, th, td, format, flags);
-
+ Vector<Ref<Image> > images;
for (int layer = 0; layer < td; layer++) {
Ref<Image> image;
@@ -2470,8 +2098,8 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String
} else {
//look for regular format
- bool mipmaps = (flags & Texture::FLAG_MIPMAPS);
- int total_size = Image::get_image_data_size(tw, th, format, mipmaps);
+
+ int total_size = Image::get_image_data_size(tw, th, format, use_mipmaps);
PoolVector<uint8_t> img_data;
img_data.resize(total_size);
@@ -2489,35 +2117,47 @@ RES ResourceFormatLoaderTextureLayered::load(const String &p_path, const String
}
}
- image->create(tw, th, mipmaps, format, img_data);
+ image->create(tw, th, use_mipmaps, format, img_data);
}
- lt->set_layer_data(image, layer);
+ images.push_back(image);
}
- if (r_error)
- *r_error = OK;
+ Error err = lt->create_from_images(images);
+ if (err != OK) {
+ *r_error = err;
+ return RES();
+ } else {
+
+ if (r_error)
+ *r_error = OK;
+ }
return lt;
}
void ResourceFormatLoaderTextureLayered::get_recognized_extensions(List<String> *p_extensions) const {
- p_extensions->push_back("tex3d");
- p_extensions->push_back("texarr");
+ p_extensions->push_back("cube");
+ p_extensions->push_back("cubearr");
+ p_extensions->push_back("tex2darr");
}
bool ResourceFormatLoaderTextureLayered::handles_type(const String &p_type) const {
- return p_type == "Texture3D" || p_type == "TextureArray";
+ return p_type == "Texture2DArray" || p_type == "Cubemap" || p_type == "CubemapArray";
}
String ResourceFormatLoaderTextureLayered::get_resource_type(const String &p_path) const {
- if (p_path.get_extension().to_lower() == "tex3d")
- return "Texture3D";
- if (p_path.get_extension().to_lower() == "texarr")
- return "TextureArray";
+ if (p_path.get_extension().to_lower() == "cube")
+ return "Cubemap";
+ if (p_path.get_extension().to_lower() == "cubearr")
+ return "CubemapArray";
+ if (p_path.get_extension().to_lower() == "tex2darr")
+ return "Texture2DArray";
return "";
}
+///////////////////////////////
+
void CameraTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_camera_feed_id", "feed_id"), &CameraTexture::set_camera_feed_id);
ClassDB::bind_method(D_METHOD("get_camera_feed_id"), &CameraTexture::get_camera_feed_id);
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index fa698d387b..d1891566d8 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -42,26 +42,14 @@
#include "servers/camera_server.h"
#include "servers/visual_server.h"
-class Texture : public Resource {
-
- GDCLASS(Texture, Resource);
- OBJ_SAVE_TYPE(Texture); // Saves derived classes with common type so they can be interchanged.
+class Texture2D : public Resource {
+ GDCLASS(Texture2D, Resource);
+ OBJ_SAVE_TYPE(Texture2D); // Saves derived classes with common type so they can be interchanged.
protected:
static void _bind_methods();
public:
- enum Flags {
- FLAG_MIPMAPS = VisualServer::TEXTURE_FLAG_MIPMAPS,
- FLAG_REPEAT = VisualServer::TEXTURE_FLAG_REPEAT,
- FLAG_FILTER = VisualServer::TEXTURE_FLAG_FILTER,
- FLAG_ANISOTROPIC_FILTER = VisualServer::TEXTURE_FLAG_ANISOTROPIC_FILTER,
- FLAG_CONVERT_TO_LINEAR = VisualServer::TEXTURE_FLAG_CONVERT_TO_LINEAR,
- FLAG_VIDEO_SURFACE = VisualServer::TEXTURE_FLAG_USED_FOR_STREAMING,
- FLAGS_DEFAULT = FLAG_MIPMAPS | FLAG_REPEAT | FLAG_FILTER,
- FLAG_MIRRORED_REPEAT = VisualServer::TEXTURE_FLAG_MIRRORED_REPEAT
- };
-
virtual int get_width() const = 0;
virtual int get_height() const = 0;
virtual Size2 get_size() const;
@@ -71,43 +59,28 @@ public:
virtual bool has_alpha() const = 0;
- virtual void set_flags(uint32_t p_flags) = 0;
- virtual uint32_t get_flags() 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>(), 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) 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;
+ 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>(), 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>(); }
- Texture();
+ Texture2D();
};
-VARIANT_ENUM_CAST(Texture::Flags);
-
class BitMap;
-class ImageTexture : public Texture {
+class ImageTexture : public Texture2D {
- GDCLASS(ImageTexture, Texture);
+ GDCLASS(ImageTexture, Texture2D);
RES_BASE_EXTENSION("tex");
-public:
- enum Storage {
- STORAGE_RAW,
- STORAGE_COMPRESS_LOSSY,
- STORAGE_COMPRESS_LOSSLESS
- };
-
-private:
- RID texture;
+ mutable RID texture;
Image::Format format;
- uint32_t flags;
+ bool mipmaps;
int w, h;
- Storage storage;
Size2 size_override;
- float lossy_storage_quality;
mutable Ref<BitMap> alpha_cache;
bool image_stored;
@@ -122,19 +95,12 @@ protected:
virtual void _resource_path_changed();
static void _bind_methods();
- void _set_data(Dictionary p_data);
-
public:
- void create(int p_width, int p_height, Image::Format p_format, uint32_t p_flags = FLAGS_DEFAULT);
- void create_from_image(const Ref<Image> &p_image, uint32_t p_flags = FLAGS_DEFAULT);
+ void create_from_image(const Ref<Image> &p_image);
- void set_flags(uint32_t p_flags);
- uint32_t get_flags() const;
Image::Format get_format() const;
-#ifndef DISABLE_DEPRECATED
- Error load(const String &p_path);
-#endif
- void set_data(const Ref<Image> &p_image);
+
+ void update(const Ref<Image> &p_image, bool p_immediate = false);
Ref<Image> get_data() const;
int get_width() const;
@@ -143,17 +109,12 @@ public:
virtual RID get_rid() const;
bool has_alpha() 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>(), bool p_clip_uv = true) const;
- void set_storage(Storage p_storage);
- Storage get_storage() 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;
+ 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;
+ 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>(), bool p_clip_uv = true) const;
bool is_pixel_opaque(int p_x, int p_y) const;
- void set_lossy_storage_quality(float p_lossy_storage_quality);
- float get_lossy_storage_quality() const;
-
void set_size_override(const Size2 &p_size);
virtual void set_path(const String &p_path, bool p_take_over = false);
@@ -162,9 +123,9 @@ public:
~ImageTexture();
};
-class StreamTexture : public Texture {
+class StreamTexture : public Texture2D {
- GDCLASS(StreamTexture, Texture);
+ GDCLASS(StreamTexture, Texture2D);
public:
enum DataFormat {
@@ -180,23 +141,23 @@ public:
FORMAT_BIT_STREAM = 1 << 22,
FORMAT_BIT_HAS_MIPMAPS = 1 << 23,
FORMAT_BIT_DETECT_3D = 1 << 24,
- FORMAT_BIT_DETECT_SRGB = 1 << 25,
+ //FORMAT_BIT_DETECT_SRGB = 1 << 25,
FORMAT_BIT_DETECT_NORMAL = 1 << 26,
+ FORMAT_BIT_DETECT_ROUGNESS = 1 << 27,
};
private:
- Error _load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, int &flags, Ref<Image> &image, int p_size_limit = 0);
+ Error _load_data(const String &p_path, int &tw, int &th, int &tw_custom, int &th_custom, Ref<Image> &image, int p_size_limit = 0);
String path_to_file;
- RID texture;
+ mutable RID texture;
Image::Format format;
- uint32_t flags;
int w, h;
mutable Ref<BitMap> alpha_cache;
virtual void reload_from_file();
static void _requested_3d(void *p_ud);
- static void _requested_srgb(void *p_ud);
+ static void _requested_roughness(void *p_ud, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel);
static void _requested_normal(void *p_ud);
protected:
@@ -205,12 +166,12 @@ protected:
public:
typedef void (*TextureFormatRequestCallback)(const Ref<StreamTexture> &);
+ typedef void (*TextureFormatRoughnessRequestCallback)(const Ref<StreamTexture> &, const String &p_normal_path, VS::TextureDetectRoughnessChannel p_roughness_channel);
static TextureFormatRequestCallback request_3d_callback;
- static TextureFormatRequestCallback request_srgb_callback;
+ static TextureFormatRoughnessRequestCallback request_roughness_callback;
static TextureFormatRequestCallback request_normal_callback;
- uint32_t get_flags() const;
Image::Format get_format() const;
Error load(const String &p_path);
String get_load_path() const;
@@ -221,12 +182,11 @@ public:
virtual void set_path(const String &p_path, bool p_take_over);
- 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>(), 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) 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;
+ 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>(), bool p_clip_uv = true) const;
virtual bool has_alpha() const;
- virtual void set_flags(uint32_t p_flags);
bool is_pixel_opaque(int p_x, int p_y) const;
virtual Ref<Image> get_data() const;
@@ -243,15 +203,13 @@ public:
virtual String get_resource_type(const String &p_path) const;
};
-VARIANT_ENUM_CAST(ImageTexture::Storage);
-
-class AtlasTexture : public Texture {
+class AtlasTexture : public Texture2D {
- GDCLASS(AtlasTexture, Texture);
+ GDCLASS(AtlasTexture, Texture2D);
RES_BASE_EXTENSION("atlastex");
protected:
- Ref<Texture> atlas;
+ Ref<Texture2D> atlas;
Rect2 region;
Rect2 margin;
bool filter_clip;
@@ -265,11 +223,8 @@ public:
virtual bool has_alpha() const;
- virtual void set_flags(uint32_t p_flags);
- virtual uint32_t get_flags() const;
-
- void set_atlas(const Ref<Texture> &p_atlas);
- Ref<Texture> get_atlas() const;
+ void set_atlas(const Ref<Texture2D> &p_atlas);
+ Ref<Texture2D> get_atlas() const;
void set_region(const Rect2 &p_region);
Rect2 get_region() const;
@@ -280,9 +235,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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>(), 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) 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;
+ 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>(), 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;
bool is_pixel_opaque(int p_x, int p_y) const;
@@ -292,12 +247,12 @@ public:
class Mesh;
-class MeshTexture : public Texture {
+class MeshTexture : public Texture2D {
- GDCLASS(MeshTexture, Texture);
+ GDCLASS(MeshTexture, Texture2D);
RES_BASE_EXTENSION("meshtex");
- Ref<Texture> base_texture;
+ Ref<Texture2D> base_texture;
Ref<Mesh> mesh;
Size2i size;
@@ -311,21 +266,18 @@ public:
virtual bool has_alpha() const;
- virtual void set_flags(uint32_t p_flags);
- virtual uint32_t get_flags() const;
-
void set_mesh(const Ref<Mesh> &p_mesh);
Ref<Mesh> get_mesh() const;
void set_image_size(const Size2 &p_size);
Size2 get_image_size() const;
- void set_base_texture(const Ref<Texture> &p_texture);
- Ref<Texture> get_base_texture() const;
+ 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>(), 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) 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;
+ 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>(), 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;
bool is_pixel_opaque(int p_x, int p_y) const;
@@ -333,16 +285,16 @@ public:
MeshTexture();
};
-class LargeTexture : public Texture {
+class LargeTexture : public Texture2D {
- GDCLASS(LargeTexture, Texture);
+ GDCLASS(LargeTexture, Texture2D);
RES_BASE_EXTENSION("largetex");
protected:
struct Piece {
Point2 offset;
- Ref<Texture> texture;
+ Ref<Texture2D> texture;
};
Vector<Piece> pieces;
@@ -359,179 +311,88 @@ public:
virtual bool has_alpha() const;
- virtual void set_flags(uint32_t p_flags);
- virtual uint32_t get_flags() const;
-
- int add_piece(const Point2 &p_offset, const Ref<Texture> &p_texture);
+ int add_piece(const Point2 &p_offset, const Ref<Texture2D> &p_texture);
void set_piece_offset(int p_idx, const Point2 &p_offset);
- void set_piece_texture(int p_idx, const Ref<Texture> &p_texture);
+ void set_piece_texture(int p_idx, const Ref<Texture2D> &p_texture);
void set_size(const Size2 &p_size);
void clear();
int get_piece_count() const;
Vector2 get_piece_offset(int p_idx) const;
- Ref<Texture> get_piece_texture(int p_idx) const;
+ 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>()) 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<Texture> &p_normal_map = Ref<Texture>(), 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 Ref<Texture2D> &p_normal_map = Ref<Texture2D>()) 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;
+ 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>(), bool p_clip_uv = true) const;
bool is_pixel_opaque(int p_x, int p_y) const;
LargeTexture();
};
-class CubeMap : public Resource {
-
- GDCLASS(CubeMap, Resource);
- RES_BASE_EXTENSION("cubemap");
-
-public:
- enum Storage {
- STORAGE_RAW,
- STORAGE_COMPRESS_LOSSY,
- STORAGE_COMPRESS_LOSSLESS
- };
-
- enum Side {
-
- SIDE_LEFT,
- SIDE_RIGHT,
- SIDE_BOTTOM,
- SIDE_TOP,
- SIDE_FRONT,
- SIDE_BACK
- };
-
- enum Flags {
- FLAG_MIPMAPS = VisualServer::TEXTURE_FLAG_MIPMAPS,
- FLAG_REPEAT = VisualServer::TEXTURE_FLAG_REPEAT,
- FLAG_FILTER = VisualServer::TEXTURE_FLAG_FILTER,
- FLAGS_DEFAULT = FLAG_MIPMAPS | FLAG_REPEAT | FLAG_FILTER,
- };
-
-private:
- bool valid[6];
- RID cubemap;
- Image::Format format;
- uint32_t flags;
- int w, h;
- Storage storage;
- Size2 size_override;
- float lossy_storage_quality;
-
- _FORCE_INLINE_ bool _is_valid() const {
- for (int i = 0; i < 6; i++) {
- if (valid[i]) return true;
- }
- return false;
- }
-
-protected:
- bool _set(const StringName &p_name, const Variant &p_value);
- bool _get(const StringName &p_name, Variant &r_ret) const;
- void _get_property_list(List<PropertyInfo> *p_list) const;
-
- static void _bind_methods();
-
-public:
- void set_flags(uint32_t p_flags);
- uint32_t get_flags() const;
- void set_side(Side p_side, const Ref<Image> &p_image);
- Ref<Image> get_side(Side p_side) const;
-
- Image::Format get_format() const;
- int get_width() const;
- int get_height() const;
-
- virtual RID get_rid() const;
-
- void set_storage(Storage p_storage);
- Storage get_storage() const;
-
- void set_lossy_storage_quality(float p_lossy_storage_quality);
- float get_lossy_storage_quality() const;
-
- virtual void set_path(const String &p_path, bool p_take_over = false);
-
- CubeMap();
- ~CubeMap();
-};
-
-VARIANT_ENUM_CAST(CubeMap::Flags)
-VARIANT_ENUM_CAST(CubeMap::Side)
-VARIANT_ENUM_CAST(CubeMap::Storage)
-
class TextureLayered : public Resource {
GDCLASS(TextureLayered, Resource);
-public:
- enum Flags {
- FLAG_MIPMAPS = VisualServer::TEXTURE_FLAG_MIPMAPS,
- FLAG_REPEAT = VisualServer::TEXTURE_FLAG_REPEAT,
- FLAG_FILTER = VisualServer::TEXTURE_FLAG_FILTER,
- FLAG_CONVERT_TO_LINEAR = VisualServer::TEXTURE_FLAG_CONVERT_TO_LINEAR,
- FLAGS_DEFAULT = FLAG_FILTER,
- };
+ VS::TextureLayeredType layered_type;
-private:
- bool is_3d;
- RID texture;
+ mutable RID texture;
Image::Format format;
- uint32_t flags;
int width;
int height;
- int depth;
+ int layers;
+ bool mipmaps;
+
+ Error _create_from_images(const Array &p_images);
- void _set_data(const Dictionary &p_data);
- Dictionary _get_data() const;
+ Array _get_images() const;
protected:
static void _bind_methods();
public:
- void set_flags(uint32_t p_flags);
- uint32_t get_flags() const;
-
Image::Format get_format() const;
uint32_t get_width() const;
uint32_t get_height() const;
- uint32_t get_depth() const;
+ uint32_t get_layers() const;
+ bool has_mipmaps() const;
- void create(uint32_t p_width, uint32_t p_height, uint32_t p_depth, Image::Format p_format, uint32_t p_flags = FLAGS_DEFAULT);
- void set_layer_data(const Ref<Image> &p_image, int p_layer);
+ Error create_from_images(Vector<Ref<Image> > p_images);
+ void update_layer(const Ref<Image> &p_image, int p_layer);
Ref<Image> get_layer_data(int p_layer) const;
- void set_data_partial(const Ref<Image> &p_image, int p_x_ofs, int p_y_ofs, int p_z, int p_mipmap = 0);
virtual RID get_rid() const;
virtual void set_path(const String &p_path, bool p_take_over = false);
- TextureLayered(bool p_3d = false);
+ TextureLayered(VS::TextureLayeredType p_layered_type);
~TextureLayered();
};
-VARIANT_ENUM_CAST(TextureLayered::Flags)
+class Texture2DArray : public TextureLayered {
-class Texture3D : public TextureLayered {
+ GDCLASS(Texture2DArray, TextureLayered)
+public:
+ Texture2DArray() :
+ TextureLayered(VS::TEXTURE_LAYERED_2D_ARRAY) {}
+};
- GDCLASS(Texture3D, TextureLayered);
+class Cubemap : public TextureLayered {
+ GDCLASS(Cubemap, TextureLayered);
public:
- Texture3D() :
- TextureLayered(true) {}
+ Cubemap() :
+ TextureLayered(VS::TEXTURE_LAYERED_CUBEMAP) {}
};
-class TextureArray : public TextureLayered {
-
- GDCLASS(TextureArray, TextureLayered);
+class CubemapArray : public TextureLayered {
+ GDCLASS(CubemapArray, TextureLayered);
public:
- TextureArray() :
- TextureLayered(false) {}
+ CubemapArray() :
+ TextureLayered(VS::TEXTURE_LAYERED_CUBEMAP_ARRAY) {}
};
class ResourceFormatLoaderTextureLayered : public ResourceFormatLoader {
@@ -548,13 +409,13 @@ public:
virtual String get_resource_type(const String &p_path) const;
};
-class CurveTexture : public Texture {
+class CurveTexture : public Texture2D {
- GDCLASS(CurveTexture, Texture);
+ GDCLASS(CurveTexture, Texture2D);
RES_BASE_EXTENSION("curvetex")
private:
- RID _texture;
+ mutable RID _texture;
Ref<Curve> _curve;
int _width;
@@ -577,9 +438,6 @@ public:
virtual int get_height() const { return 1; }
virtual bool has_alpha() const { return false; }
- virtual void set_flags(uint32_t p_flags) {}
- virtual uint32_t get_flags() const { return FLAG_FILTER; }
-
CurveTexture();
~CurveTexture();
};
@@ -597,8 +455,8 @@ public:
*/
//VARIANT_ENUM_CAST( Texture::CubeMapSide );
-class GradientTexture : public Texture {
- GDCLASS(GradientTexture, Texture);
+class GradientTexture : public Texture2D {
+ GDCLASS(GradientTexture, Texture2D);
public:
struct Point {
@@ -633,28 +491,25 @@ public:
virtual int get_height() const { return 1; }
virtual bool has_alpha() const { return true; }
- virtual void set_flags(uint32_t p_flags) {}
- virtual uint32_t get_flags() const { return FLAG_FILTER; }
-
virtual Ref<Image> get_data() const;
GradientTexture();
virtual ~GradientTexture();
};
-class ProxyTexture : public Texture {
- GDCLASS(ProxyTexture, Texture);
+class ProxyTexture : public Texture2D {
+ GDCLASS(ProxyTexture, Texture2D);
private:
RID proxy;
- Ref<Texture> base;
+ Ref<Texture2D> base;
protected:
static void _bind_methods();
public:
- void set_base(const Ref<Texture> &p_texture);
- Ref<Texture> get_base() const;
+ void set_base(const Ref<Texture2D> &p_texture);
+ Ref<Texture2D> get_base() const;
virtual int get_width() const;
virtual int get_height() const;
@@ -662,15 +517,12 @@ public:
virtual bool has_alpha() const;
- virtual void set_flags(uint32_t p_flags);
- virtual uint32_t get_flags() const;
-
ProxyTexture();
~ProxyTexture();
};
-class AnimatedTexture : public Texture {
- GDCLASS(AnimatedTexture, Texture);
+class AnimatedTexture : public Texture2D {
+ GDCLASS(AnimatedTexture, Texture2D);
//use readers writers lock for this, since its far more times read than written to
RWLock *rw_lock;
@@ -684,7 +536,7 @@ private:
struct Frame {
- Ref<Texture> texture;
+ Ref<Texture2D> texture;
float delay_sec;
Frame() {
@@ -712,8 +564,8 @@ public:
void set_frames(int p_frames);
int get_frames() const;
- void set_frame_texture(int p_frame, const Ref<Texture> &p_texture);
- Ref<Texture> get_frame_texture(int p_frame) const;
+ void set_frame_texture(int p_frame, const Ref<Texture2D> &p_texture);
+ Ref<Texture2D> get_frame_texture(int p_frame) const;
void set_frame_delay(int p_frame, float p_delay_sec);
float get_frame_delay(int p_frame) const;
@@ -727,9 +579,6 @@ public:
virtual bool has_alpha() const;
- virtual void set_flags(uint32_t p_flags);
- virtual uint32_t get_flags() const;
-
virtual Ref<Image> get_data() const;
bool is_pixel_opaque(int p_x, int p_y) const;
@@ -738,8 +587,8 @@ public:
~AnimatedTexture();
};
-class CameraTexture : public Texture {
- GDCLASS(CameraTexture, Texture);
+class CameraTexture : public Texture2D {
+ GDCLASS(CameraTexture, Texture2D);
private:
int camera_feed_id;
diff --git a/scene/resources/theme.cpp b/scene/resources/theme.cpp
index 1f2fa1d60b..75903c1383 100644
--- a/scene/resources/theme.cpp
+++ b/scene/resources/theme.cpp
@@ -196,7 +196,7 @@ bool Theme::_get(const StringName &p_name, Variant &r_ret) const {
if (type == "icons") {
if (!has_icon(name, node_type))
- r_ret = Ref<Texture>();
+ r_ret = Ref<Texture2D>();
else
r_ret = get_icon(name, node_type);
} else if (type == "styles") {
@@ -238,7 +238,7 @@ void Theme::_get_property_list(List<PropertyInfo> *p_list) const {
while ((key2 = icon_map[*key].next(key2))) {
- list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/icons/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
+ list.push_back(PropertyInfo(Variant::OBJECT, String() + *key + "/icons/" + *key2, PROPERTY_HINT_RESOURCE_TYPE, "Texture2D", PROPERTY_USAGE_DEFAULT | PROPERTY_USAGE_STORE_IF_NULL));
}
}
@@ -322,7 +322,7 @@ Ref<Font> Theme::get_default_theme_font() const {
Ref<Theme> Theme::project_default_theme;
Ref<Theme> Theme::default_theme;
-Ref<Texture> Theme::default_icon;
+Ref<Texture2D> Theme::default_icon;
Ref<StyleBox> Theme::default_style;
Ref<Font> Theme::default_font;
@@ -346,7 +346,7 @@ void Theme::set_project_default(const Ref<Theme> &p_project_default) {
project_default_theme = p_project_default;
}
-void Theme::set_default_icon(const Ref<Texture> &p_icon) {
+void Theme::set_default_icon(const Ref<Texture2D> &p_icon) {
default_icon = p_icon;
}
@@ -359,7 +359,7 @@ void Theme::set_default_font(const Ref<Font> &p_font) {
default_font = p_font;
}
-void Theme::set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture> &p_icon) {
+void Theme::set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture2D> &p_icon) {
//ERR_FAIL_COND(p_icon.is_null());
@@ -380,7 +380,7 @@ void Theme::set_icon(const StringName &p_name, const StringName &p_type, const R
emit_changed();
}
}
-Ref<Texture> Theme::get_icon(const StringName &p_name, const StringName &p_type) const {
+Ref<Texture2D> Theme::get_icon(const StringName &p_name, const StringName &p_type) const {
if (icon_map.has(p_type) && icon_map[p_type].has(p_name) && icon_map[p_type][p_name].is_valid()) {
@@ -720,7 +720,7 @@ void Theme::clear() {
while ((K = icon_map.next(K))) {
const StringName *L = NULL;
while ((L = icon_map[*K].next(L))) {
- Ref<Texture> icon = icon_map[*K][*L];
+ Ref<Texture2D> icon = icon_map[*K][*L];
if (icon.is_valid()) {
icon->disconnect("changed", this, "_emit_theme_changed");
}
diff --git a/scene/resources/theme.h b/scene/resources/theme.h
index 4bb614b24e..e60734b144 100644
--- a/scene/resources/theme.h
+++ b/scene/resources/theme.h
@@ -45,7 +45,7 @@ class Theme : public Resource {
void _emit_theme_changed();
- HashMap<StringName, HashMap<StringName, Ref<Texture> > > icon_map;
+ HashMap<StringName, HashMap<StringName, Ref<Texture2D> > > icon_map;
HashMap<StringName, HashMap<StringName, Ref<StyleBox> > > style_map;
HashMap<StringName, HashMap<StringName, Ref<Font> > > font_map;
HashMap<StringName, HashMap<StringName, Ref<Shader> > > shader_map;
@@ -67,7 +67,7 @@ protected:
static Ref<Theme> project_default_theme;
static Ref<Theme> default_theme;
- static Ref<Texture> default_icon;
+ static Ref<Texture2D> default_icon;
static Ref<StyleBox> default_style;
static Ref<Font> default_font;
@@ -82,15 +82,15 @@ public:
static Ref<Theme> get_project_default();
static void set_project_default(const Ref<Theme> &p_project_default);
- static void set_default_icon(const Ref<Texture> &p_icon);
+ static void set_default_icon(const Ref<Texture2D> &p_icon);
static void set_default_style(const Ref<StyleBox> &p_style);
static void set_default_font(const Ref<Font> &p_font);
void set_default_theme_font(const Ref<Font> &p_default_font);
Ref<Font> get_default_theme_font() const;
- void set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture> &p_icon);
- Ref<Texture> get_icon(const StringName &p_name, const StringName &p_type) const;
+ void set_icon(const StringName &p_name, const StringName &p_type, const Ref<Texture2D> &p_icon);
+ Ref<Texture2D> get_icon(const StringName &p_name, const StringName &p_type) const;
bool has_icon(const StringName &p_name, const StringName &p_type) const;
void clear_icon(const StringName &p_name, const StringName &p_type);
void get_icon_list(StringName p_type, List<StringName> *p_list) const;
diff --git a/scene/resources/tile_set.cpp b/scene/resources/tile_set.cpp
index db5037172e..7383e18473 100644
--- a/scene/resources/tile_set.cpp
+++ b/scene/resources/tile_set.cpp
@@ -326,8 +326,8 @@ void TileSet::_get_property_list(List<PropertyInfo> *p_list) const {
int id = E->key();
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, "Texture", PROPERTY_USAGE_NOEDITOR));
- p_list->push_back(PropertyInfo(Variant::OBJECT, pre + "normal_map", PROPERTY_HINT_RESOURCE_TYPE, "Texture", 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));
@@ -387,7 +387,7 @@ TileSet::BitmaskMode TileSet::autotile_get_bitmask_mode(int p_id) const {
return tile_map[p_id].autotile_data.bitmask_mode;
}
-void TileSet::tile_set_texture(int p_id, const Ref<Texture> &p_texture) {
+void TileSet::tile_set_texture(int p_id, const Ref<Texture2D> &p_texture) {
ERR_FAIL_COND(!tile_map.has(p_id));
tile_map[p_id].texture = p_texture;
@@ -395,22 +395,22 @@ void TileSet::tile_set_texture(int p_id, const Ref<Texture> &p_texture) {
_change_notify("texture");
}
-Ref<Texture> TileSet::tile_get_texture(int p_id) const {
+Ref<Texture2D> TileSet::tile_get_texture(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture>());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture2D>());
return tile_map[p_id].texture;
}
-void TileSet::tile_set_normal_map(int p_id, const Ref<Texture> &p_normal_map) {
+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<Texture> TileSet::tile_get_normal_map(int p_id) const {
+Ref<Texture2D> TileSet::tile_get_normal_map(int p_id) const {
- ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture>());
+ ERR_FAIL_COND_V(!tile_map.has(p_id), Ref<Texture2D>());
return tile_map[p_id].normal_map;
}
diff --git a/scene/resources/tile_set.h b/scene/resources/tile_set.h
index eab40ce467..8b540982a4 100644
--- a/scene/resources/tile_set.h
+++ b/scene/resources/tile_set.h
@@ -114,8 +114,8 @@ private:
struct TileData {
String name;
- Ref<Texture> texture;
- Ref<Texture> normal_map;
+ Ref<Texture2D> texture;
+ Ref<Texture2D> normal_map;
Vector2 offset;
Rect2i region;
Vector<ShapeData> shapes_data;
@@ -158,11 +158,11 @@ public:
void tile_set_name(int p_id, const String &p_name);
String tile_get_name(int p_id) const;
- void tile_set_texture(int p_id, const Ref<Texture> &p_texture);
- Ref<Texture> tile_get_texture(int p_id) const;
+ 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<Texture> &p_normal_map);
- Ref<Texture> tile_get_normal_map(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/video_stream.h b/scene/resources/video_stream.h
index 444bb698ae..a9b96214c3 100644
--- a/scene/resources/video_stream.h
+++ b/scene/resources/video_stream.h
@@ -58,7 +58,8 @@ public:
virtual void set_audio_track(int p_idx) = 0;
- virtual Ref<Texture> get_texture() const = 0;
+ virtual Ref<Texture2D> get_texture() const = 0;
+
virtual void update(float p_delta) = 0;
virtual void set_mix_callback(AudioMixCallback p_callback, void *p_userdata) = 0;
diff --git a/scene/resources/visual_shader.h b/scene/resources/visual_shader.h
index f35318e090..1ee75a4cb7 100644
--- a/scene/resources/visual_shader.h
+++ b/scene/resources/visual_shader.h
@@ -58,7 +58,7 @@ public:
struct DefaultTextureParam {
StringName name;
- Ref<Texture> param;
+ Ref<Texture2D> param;
};
private:
diff --git a/scene/resources/visual_shader_nodes.cpp b/scene/resources/visual_shader_nodes.cpp
index 8f0e0058ea..95a8155c31 100644
--- a/scene/resources/visual_shader_nodes.cpp
+++ b/scene/resources/visual_shader_nodes.cpp
@@ -357,7 +357,7 @@ VisualShaderNodeTransformConstant::VisualShaderNodeTransformConstant() {
////////////// Texture
String VisualShaderNodeTexture::get_caption() const {
- return "Texture";
+ return "Texture2D";
}
int VisualShaderNodeTexture::get_input_port_count() const {
@@ -649,13 +649,13 @@ VisualShaderNodeTexture::Source VisualShaderNodeTexture::get_source() const {
return source;
}
-void VisualShaderNodeTexture::set_texture(Ref<Texture> p_value) {
+void VisualShaderNodeTexture::set_texture(Ref<Texture2D> p_value) {
texture = p_value;
emit_changed();
}
-Ref<Texture> VisualShaderNodeTexture::get_texture() const {
+Ref<Texture2D> VisualShaderNodeTexture::get_texture() const {
return texture;
}
@@ -727,7 +727,7 @@ void VisualShaderNodeTexture::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_texture_type"), &VisualShaderNodeTexture::get_texture_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "source", PROPERTY_HINT_ENUM, "Texture,Screen,Texture2D,NormalMap2D,Depth,SamplerPort"), "set_source", "get_source");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture"), "set_texture", "get_texture");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "texture", PROPERTY_HINT_RESOURCE_TYPE, "Texture2D"), "set_texture", "get_texture");
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_type", PROPERTY_HINT_ENUM, "Data,Color,Normalmap"), "set_texture_type", "get_texture_type");
BIND_ENUM_CONSTANT(SOURCE_TEXTURE);
@@ -746,17 +746,17 @@ VisualShaderNodeTexture::VisualShaderNodeTexture() {
source = SOURCE_TEXTURE;
}
-////////////// CubeMap
+////////////// Cubemap
-String VisualShaderNodeCubeMap::get_caption() const {
- return "CubeMap";
+String VisualShaderNodeCubemap::get_caption() const {
+ return "Cubemap";
}
-int VisualShaderNodeCubeMap::get_input_port_count() const {
+int VisualShaderNodeCubemap::get_input_port_count() const {
return 3;
}
-VisualShaderNodeCubeMap::PortType VisualShaderNodeCubeMap::get_input_port_type(int p_port) const {
+VisualShaderNodeCubemap::PortType VisualShaderNodeCubemap::get_input_port_type(int p_port) const {
switch (p_port) {
case 0:
return PORT_TYPE_VECTOR;
@@ -769,7 +769,7 @@ VisualShaderNodeCubeMap::PortType VisualShaderNodeCubeMap::get_input_port_type(i
}
}
-String VisualShaderNodeCubeMap::get_input_port_name(int p_port) const {
+String VisualShaderNodeCubemap::get_input_port_name(int p_port) const {
switch (p_port) {
case 0:
return "uv";
@@ -782,19 +782,19 @@ String VisualShaderNodeCubeMap::get_input_port_name(int p_port) const {
}
}
-int VisualShaderNodeCubeMap::get_output_port_count() const {
+int VisualShaderNodeCubemap::get_output_port_count() const {
return 2;
}
-VisualShaderNodeCubeMap::PortType VisualShaderNodeCubeMap::get_output_port_type(int p_port) const {
+VisualShaderNodeCubemap::PortType VisualShaderNodeCubemap::get_output_port_type(int p_port) const {
return p_port == 0 ? PORT_TYPE_VECTOR : PORT_TYPE_SCALAR;
}
-String VisualShaderNodeCubeMap::get_output_port_name(int p_port) const {
+String VisualShaderNodeCubemap::get_output_port_name(int p_port) const {
return p_port == 0 ? "rgb" : "alpha";
}
-Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCubeMap::get_default_texture_parameters(VisualShader::Type p_type, int p_id) const {
+Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCubemap::get_default_texture_parameters(VisualShader::Type p_type, int p_id) const {
VisualShader::DefaultTextureParam dtp;
dtp.name = make_unique_id(p_type, p_id, "cube");
dtp.param = cube_map;
@@ -803,7 +803,7 @@ Vector<VisualShader::DefaultTextureParam> VisualShaderNodeCubeMap::get_default_t
return ret;
}
-String VisualShaderNodeCubeMap::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
+String VisualShaderNodeCubemap::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
if (source == SOURCE_TEXTURE) {
String u = "uniform samplerCube " + make_unique_id(p_type, p_id, "cube");
@@ -817,7 +817,7 @@ String VisualShaderNodeCubeMap::generate_global(Shader::Mode p_mode, VisualShade
return String();
}
-String VisualShaderNodeCubeMap::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 {
+String VisualShaderNodeCubemap::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 {
String code;
String id;
@@ -860,44 +860,44 @@ String VisualShaderNodeCubeMap::generate_code(Shader::Mode p_mode, VisualShader:
return code;
}
-String VisualShaderNodeCubeMap::get_input_port_default_hint(int p_port) const {
+String VisualShaderNodeCubemap::get_input_port_default_hint(int p_port) const {
if (p_port == 0) {
return "vec3(UV, 0.0)";
}
return "";
}
-void VisualShaderNodeCubeMap::set_source(Source p_source) {
+void VisualShaderNodeCubemap::set_source(Source p_source) {
source = p_source;
emit_changed();
emit_signal("editor_refresh_request");
}
-VisualShaderNodeCubeMap::Source VisualShaderNodeCubeMap::get_source() const {
+VisualShaderNodeCubemap::Source VisualShaderNodeCubemap::get_source() const {
return source;
}
-void VisualShaderNodeCubeMap::set_cube_map(Ref<CubeMap> p_value) {
+void VisualShaderNodeCubemap::set_cube_map(Ref<Cubemap> p_value) {
cube_map = p_value;
emit_changed();
}
-Ref<CubeMap> VisualShaderNodeCubeMap::get_cube_map() const {
+Ref<Cubemap> VisualShaderNodeCubemap::get_cube_map() const {
return cube_map;
}
-void VisualShaderNodeCubeMap::set_texture_type(TextureType p_type) {
+void VisualShaderNodeCubemap::set_texture_type(TextureType p_type) {
texture_type = p_type;
emit_changed();
}
-VisualShaderNodeCubeMap::TextureType VisualShaderNodeCubeMap::get_texture_type() const {
+VisualShaderNodeCubemap::TextureType VisualShaderNodeCubemap::get_texture_type() const {
return texture_type;
}
-Vector<StringName> VisualShaderNodeCubeMap::get_editable_properties() const {
+Vector<StringName> VisualShaderNodeCubemap::get_editable_properties() const {
Vector<StringName> props;
props.push_back("source");
if (source == SOURCE_TEXTURE) {
@@ -907,19 +907,19 @@ Vector<StringName> VisualShaderNodeCubeMap::get_editable_properties() const {
return props;
}
-void VisualShaderNodeCubeMap::_bind_methods() {
+void VisualShaderNodeCubemap::_bind_methods() {
- ClassDB::bind_method(D_METHOD("set_source", "value"), &VisualShaderNodeCubeMap::set_source);
- ClassDB::bind_method(D_METHOD("get_source"), &VisualShaderNodeCubeMap::get_source);
+ ClassDB::bind_method(D_METHOD("set_source", "value"), &VisualShaderNodeCubemap::set_source);
+ ClassDB::bind_method(D_METHOD("get_source"), &VisualShaderNodeCubemap::get_source);
- ClassDB::bind_method(D_METHOD("set_cube_map", "value"), &VisualShaderNodeCubeMap::set_cube_map);
- ClassDB::bind_method(D_METHOD("get_cube_map"), &VisualShaderNodeCubeMap::get_cube_map);
+ ClassDB::bind_method(D_METHOD("set_cube_map", "value"), &VisualShaderNodeCubemap::set_cube_map);
+ ClassDB::bind_method(D_METHOD("get_cube_map"), &VisualShaderNodeCubemap::get_cube_map);
- ClassDB::bind_method(D_METHOD("set_texture_type", "value"), &VisualShaderNodeCubeMap::set_texture_type);
- ClassDB::bind_method(D_METHOD("get_texture_type"), &VisualShaderNodeCubeMap::get_texture_type);
+ ClassDB::bind_method(D_METHOD("set_texture_type", "value"), &VisualShaderNodeCubemap::set_texture_type);
+ ClassDB::bind_method(D_METHOD("get_texture_type"), &VisualShaderNodeCubemap::get_texture_type);
ADD_PROPERTY(PropertyInfo(Variant::INT, "source", PROPERTY_HINT_ENUM, "Texture,SamplerPort"), "set_source", "get_source");
- ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "cube_map", PROPERTY_HINT_RESOURCE_TYPE, "CubeMap"), "set_cube_map", "get_cube_map");
+ ADD_PROPERTY(PropertyInfo(Variant::OBJECT, "cube_map", PROPERTY_HINT_RESOURCE_TYPE, "Cubemap"), "set_cube_map", "get_cube_map");
ADD_PROPERTY(PropertyInfo(Variant::INT, "texture_type", PROPERTY_HINT_ENUM, "Data,Color,Normalmap"), "set_texture_type", "get_texture_type");
BIND_ENUM_CONSTANT(SOURCE_TEXTURE);
@@ -930,7 +930,7 @@ void VisualShaderNodeCubeMap::_bind_methods() {
BIND_ENUM_CONSTANT(TYPE_NORMALMAP);
}
-VisualShaderNodeCubeMap::VisualShaderNodeCubeMap() {
+VisualShaderNodeCubemap::VisualShaderNodeCubemap() {
texture_type = TYPE_DATA;
source = SOURCE_TEXTURE;
simple_decl = false;
@@ -3552,41 +3552,41 @@ String VisualShaderNodeTextureUniformTriplanar::get_input_port_default_hint(int
VisualShaderNodeTextureUniformTriplanar::VisualShaderNodeTextureUniformTriplanar() {
}
-////////////// CubeMap Uniform
+////////////// Cubemap Uniform
-String VisualShaderNodeCubeMapUniform::get_caption() const {
- return "CubeMapUniform";
+String VisualShaderNodeCubemapUniform::get_caption() const {
+ return "CubemapUniform";
}
-int VisualShaderNodeCubeMapUniform::get_output_port_count() const {
+int VisualShaderNodeCubemapUniform::get_output_port_count() const {
return 1;
}
-VisualShaderNodeCubeMapUniform::PortType VisualShaderNodeCubeMapUniform::get_output_port_type(int p_port) const {
+VisualShaderNodeCubemapUniform::PortType VisualShaderNodeCubemapUniform::get_output_port_type(int p_port) const {
return PORT_TYPE_SAMPLER;
}
-String VisualShaderNodeCubeMapUniform::get_output_port_name(int p_port) const {
+String VisualShaderNodeCubemapUniform::get_output_port_name(int p_port) const {
return "samplerCube";
}
-int VisualShaderNodeCubeMapUniform::get_input_port_count() const {
+int VisualShaderNodeCubemapUniform::get_input_port_count() const {
return 0;
}
-VisualShaderNodeCubeMapUniform::PortType VisualShaderNodeCubeMapUniform::get_input_port_type(int p_port) const {
+VisualShaderNodeCubemapUniform::PortType VisualShaderNodeCubemapUniform::get_input_port_type(int p_port) const {
return PORT_TYPE_SCALAR;
}
-String VisualShaderNodeCubeMapUniform::get_input_port_name(int p_port) const {
+String VisualShaderNodeCubemapUniform::get_input_port_name(int p_port) const {
return "";
}
-String VisualShaderNodeCubeMapUniform::get_input_port_default_hint(int p_port) const {
+String VisualShaderNodeCubemapUniform::get_input_port_default_hint(int p_port) const {
return "";
}
-String VisualShaderNodeCubeMapUniform::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
+String VisualShaderNodeCubemapUniform::generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const {
String code = "uniform samplerCube " + get_uniform_name();
switch (texture_type) {
@@ -3609,11 +3609,11 @@ String VisualShaderNodeCubeMapUniform::generate_global(Shader::Mode p_mode, Visu
return code;
}
-String VisualShaderNodeCubeMapUniform::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 {
+String VisualShaderNodeCubemapUniform::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 {
return String();
}
-VisualShaderNodeCubeMapUniform::VisualShaderNodeCubeMapUniform() {
+VisualShaderNodeCubemapUniform::VisualShaderNodeCubemapUniform() {
}
////////////// If
diff --git a/scene/resources/visual_shader_nodes.h b/scene/resources/visual_shader_nodes.h
index 3d57fd0efc..85782bc509 100644
--- a/scene/resources/visual_shader_nodes.h
+++ b/scene/resources/visual_shader_nodes.h
@@ -191,7 +191,7 @@ public:
class VisualShaderNodeTexture : public VisualShaderNode {
GDCLASS(VisualShaderNodeTexture, VisualShaderNode);
- Ref<Texture> texture;
+ Ref<Texture2D> texture;
public:
enum Source {
@@ -236,8 +236,8 @@ public:
void set_source(Source p_source);
Source get_source() const;
- void set_texture(Ref<Texture> p_value);
- Ref<Texture> get_texture() const;
+ void set_texture(Ref<Texture2D> p_value);
+ Ref<Texture2D> get_texture() const;
void set_texture_type(TextureType p_type);
TextureType get_texture_type() const;
@@ -254,9 +254,9 @@ VARIANT_ENUM_CAST(VisualShaderNodeTexture::Source)
///////////////////////////////////////
-class VisualShaderNodeCubeMap : public VisualShaderNode {
- GDCLASS(VisualShaderNodeCubeMap, VisualShaderNode);
- Ref<CubeMap> cube_map;
+class VisualShaderNodeCubemap : public VisualShaderNode {
+ GDCLASS(VisualShaderNodeCubemap, VisualShaderNode);
+ Ref<Cubemap> cube_map;
public:
enum Source {
@@ -296,19 +296,19 @@ public:
void set_source(Source p_source);
Source get_source() const;
- void set_cube_map(Ref<CubeMap> p_value);
- Ref<CubeMap> get_cube_map() const;
+ void set_cube_map(Ref<Cubemap> p_value);
+ Ref<Cubemap> get_cube_map() const;
void set_texture_type(TextureType p_type);
TextureType get_texture_type() const;
virtual Vector<StringName> get_editable_properties() const;
- VisualShaderNodeCubeMap();
+ VisualShaderNodeCubemap();
};
-VARIANT_ENUM_CAST(VisualShaderNodeCubeMap::TextureType)
-VARIANT_ENUM_CAST(VisualShaderNodeCubeMap::Source)
+VARIANT_ENUM_CAST(VisualShaderNodeCubemap::TextureType)
+VARIANT_ENUM_CAST(VisualShaderNodeCubemap::Source)
///////////////////////////////////////
/// OPS
@@ -1514,8 +1514,8 @@ public:
///////////////////////////////////////
-class VisualShaderNodeCubeMapUniform : public VisualShaderNodeTextureUniform {
- GDCLASS(VisualShaderNodeCubeMapUniform, VisualShaderNodeTextureUniform);
+class VisualShaderNodeCubemapUniform : public VisualShaderNodeTextureUniform {
+ GDCLASS(VisualShaderNodeCubemapUniform, VisualShaderNodeTextureUniform);
public:
virtual String get_caption() const;
@@ -1532,7 +1532,7 @@ public:
virtual String generate_global(Shader::Mode p_mode, VisualShader::Type p_type, int p_id) const;
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; //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
- VisualShaderNodeCubeMapUniform();
+ VisualShaderNodeCubemapUniform();
};
///////////////////////////////////////