summaryrefslogtreecommitdiff
path: root/scene/3d
diff options
context:
space:
mode:
Diffstat (limited to 'scene/3d')
-rw-r--r--scene/3d/baked_lightmap.cpp14
-rw-r--r--scene/3d/baked_lightmap.h6
-rw-r--r--scene/3d/immediate_geometry.cpp4
-rw-r--r--scene/3d/immediate_geometry.h4
-rw-r--r--scene/3d/sprite_3d.cpp11
-rw-r--r--scene/3d/sprite_3d.h6
-rw-r--r--scene/3d/voxel_light_baker.cpp4
7 files changed, 23 insertions, 26 deletions
diff --git a/scene/3d/baked_lightmap.cpp b/scene/3d/baked_lightmap.cpp
index 071afd1a69..d199e53db5 100644
--- a/scene/3d/baked_lightmap.cpp
+++ b/scene/3d/baked_lightmap.cpp
@@ -86,7 +86,7 @@ float BakedLightmapData::get_energy() const {
return energy;
}
-void BakedLightmapData::add_user(const NodePath &p_path, const Ref<Texture> &p_lightmap, int p_instance) {
+void BakedLightmapData::add_user(const NodePath &p_path, const Ref<Texture2D> &p_lightmap, int p_instance) {
ERR_FAIL_COND_MSG(p_lightmap.is_null(), "It's not a reference to a valid Texture object.");
User user;
@@ -105,9 +105,9 @@ NodePath BakedLightmapData::get_user_path(int p_user) const {
ERR_FAIL_INDEX_V(p_user, users.size(), NodePath());
return users[p_user].path;
}
-Ref<Texture> BakedLightmapData::get_user_lightmap(int p_user) const {
+Ref<Texture2D> BakedLightmapData::get_user_lightmap(int p_user) const {
- ERR_FAIL_INDEX_V(p_user, users.size(), Ref<Texture>());
+ ERR_FAIL_INDEX_V(p_user, users.size(), Ref<Texture2D>());
return users[p_user].lightmap;
}
@@ -491,7 +491,6 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi
Ref<Image> image;
image.instance();
- uint32_t tex_flags = Texture::FLAGS_DEFAULT;
if (hdr) {
//just save a regular image
@@ -534,11 +533,10 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi
//This texture is saved to SRGB for two reasons:
// 1) first is so it looks better when doing the LINEAR->SRGB conversion (more accurate)
// 2) So it can be used in the GLES2 backend, which does not support linkear workflow
- tex_flags |= Texture::FLAG_CONVERT_TO_LINEAR;
}
String image_path = save_path.plus_file(mesh_name);
- Ref<Texture> texture;
+ Ref<Texture2D> texture;
if (ResourceLoader::import) {
@@ -583,7 +581,7 @@ BakedLightmap::BakeError BakedLightmap::bake(Node *p_from_node, bool p_create_vi
tex.instance();
}
- tex->create_from_image(image, tex_flags);
+ tex->create_from_image(image);
err = ResourceSaver::save(image_path, tex, ResourceSaver::FLAG_CHANGE_PATH);
if (set_path) {
@@ -668,7 +666,7 @@ void BakedLightmap::_assign_lightmaps() {
ERR_FAIL_COND(!light_data.is_valid());
for (int i = 0; i < light_data->get_user_count(); i++) {
- Ref<Texture> lightmap = light_data->get_user_lightmap(i);
+ Ref<Texture2D> lightmap = light_data->get_user_lightmap(i);
ERR_CONTINUE(!lightmap.is_valid());
Node *node = get_node(light_data->get_user_path(i));
diff --git a/scene/3d/baked_lightmap.h b/scene/3d/baked_lightmap.h
index 82354cc9f0..895a52aad8 100644
--- a/scene/3d/baked_lightmap.h
+++ b/scene/3d/baked_lightmap.h
@@ -47,7 +47,7 @@ class BakedLightmapData : public Resource {
struct User {
NodePath path;
- Ref<Texture> lightmap;
+ Ref<Texture2D> lightmap;
int instance_index;
};
@@ -75,10 +75,10 @@ public:
void set_energy(float p_energy);
float get_energy() const;
- void add_user(const NodePath &p_path, const Ref<Texture> &p_lightmap, int p_instance = -1);
+ void add_user(const NodePath &p_path, const Ref<Texture2D> &p_lightmap, int p_instance = -1);
int get_user_count() const;
NodePath get_user_path(int p_user) const;
- Ref<Texture> get_user_lightmap(int p_user) const;
+ Ref<Texture2D> get_user_lightmap(int p_user) const;
int get_user_instance(int p_user) const;
void clear_users();
diff --git a/scene/3d/immediate_geometry.cpp b/scene/3d/immediate_geometry.cpp
index 0a1beaf3f4..afe60226b6 100644
--- a/scene/3d/immediate_geometry.cpp
+++ b/scene/3d/immediate_geometry.cpp
@@ -30,7 +30,7 @@
#include "immediate_geometry.h"
-void ImmediateGeometry::begin(Mesh::PrimitiveType p_primitive, const Ref<Texture> &p_texture) {
+void ImmediateGeometry::begin(Mesh::PrimitiveType p_primitive, const Ref<Texture2D> &p_texture) {
VS::get_singleton()->immediate_begin(im, (VS::PrimitiveType)p_primitive, p_texture.is_valid() ? p_texture->get_rid() : RID());
if (p_texture.is_valid())
@@ -144,7 +144,7 @@ void ImmediateGeometry::add_sphere(int p_lats, int p_lons, float p_radius, bool
void ImmediateGeometry::_bind_methods() {
- ClassDB::bind_method(D_METHOD("begin", "primitive", "texture"), &ImmediateGeometry::begin, DEFVAL(Ref<Texture>()));
+ ClassDB::bind_method(D_METHOD("begin", "primitive", "texture"), &ImmediateGeometry::begin, DEFVAL(Ref<Texture2D>()));
ClassDB::bind_method(D_METHOD("set_normal", "normal"), &ImmediateGeometry::set_normal);
ClassDB::bind_method(D_METHOD("set_tangent", "tangent"), &ImmediateGeometry::set_tangent);
ClassDB::bind_method(D_METHOD("set_color", "color"), &ImmediateGeometry::set_color);
diff --git a/scene/3d/immediate_geometry.h b/scene/3d/immediate_geometry.h
index f45ebd6724..7f506ce9ef 100644
--- a/scene/3d/immediate_geometry.h
+++ b/scene/3d/immediate_geometry.h
@@ -41,7 +41,7 @@ class ImmediateGeometry : public GeometryInstance {
RID im;
//a list of textures drawn need to be kept, to avoid references
// in VisualServer from becoming invalid if the texture is no longer used
- List<Ref<Texture> > cached_textures;
+ List<Ref<Texture2D> > cached_textures;
bool empty;
AABB aabb;
@@ -49,7 +49,7 @@ protected:
static void _bind_methods();
public:
- void begin(Mesh::PrimitiveType p_primitive, const Ref<Texture> &p_texture = Ref<Texture>());
+ void begin(Mesh::PrimitiveType p_primitive, const Ref<Texture2D> &p_texture = Ref<Texture2D>());
void set_normal(const Vector3 &p_normal);
void set_tangent(const Plane &p_tangent);
void set_color(const Color &p_color);
diff --git a/scene/3d/sprite_3d.cpp b/scene/3d/sprite_3d.cpp
index a4c81b864d..6656f8d751 100644
--- a/scene/3d/sprite_3d.cpp
+++ b/scene/3d/sprite_3d.cpp
@@ -525,7 +525,7 @@ void Sprite3D::_draw() {
VS::get_singleton()->immediate_end(immediate);
}
-void Sprite3D::set_texture(const Ref<Texture> &p_texture) {
+void Sprite3D::set_texture(const Ref<Texture2D> &p_texture) {
if (p_texture == texture)
return;
@@ -534,13 +534,12 @@ void Sprite3D::set_texture(const Ref<Texture> &p_texture) {
}
texture = p_texture;
if (texture.is_valid()) {
- texture->set_flags(texture->get_flags()); //remove repeat from texture, it looks bad in sprites
texture->connect(CoreStringNames::get_singleton()->changed, this, SceneStringNames::get_singleton()->_queue_update);
}
_queue_update();
}
-Ref<Texture> Sprite3D::get_texture() const {
+Ref<Texture2D> Sprite3D::get_texture() const {
return texture;
}
@@ -691,7 +690,7 @@ void Sprite3D::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_hframes", "hframes"), &Sprite3D::set_hframes);
ClassDB::bind_method(D_METHOD("get_hframes"), &Sprite3D::get_hframes);
- 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_GROUP("Animation", "");
ADD_PROPERTY(PropertyInfo(Variant::INT, "vframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_vframes", "get_vframes");
ADD_PROPERTY(PropertyInfo(Variant::INT, "hframes", PROPERTY_HINT_RANGE, "1,16384,1"), "set_hframes", "get_hframes");
@@ -731,7 +730,7 @@ void AnimatedSprite3D::_draw() {
return;
}
- Ref<Texture> texture = frames->get_frame(animation, frame);
+ Ref<Texture2D> texture = frames->get_frame(animation, frame);
if (!texture.is_valid())
return; //no texuture no life
Vector2 tsize = texture->get_size();
@@ -1003,7 +1002,7 @@ Rect2 AnimatedSprite3D::get_item_rect() const {
return Rect2(0, 0, 1, 1);
}
- Ref<Texture> t;
+ Ref<Texture2D> t;
if (animation)
t = frames->get_frame(animation, frame);
if (t.is_null())
diff --git a/scene/3d/sprite_3d.h b/scene/3d/sprite_3d.h
index ddbade147c..8ec07b46ca 100644
--- a/scene/3d/sprite_3d.h
+++ b/scene/3d/sprite_3d.h
@@ -147,7 +147,7 @@ public:
class Sprite3D : public SpriteBase3D {
GDCLASS(Sprite3D, SpriteBase3D);
- Ref<Texture> texture;
+ Ref<Texture2D> texture;
bool region;
Rect2 region_rect;
@@ -164,8 +164,8 @@ protected:
virtual void _validate_property(PropertyInfo &property) const;
public:
- void set_texture(const Ref<Texture> &p_texture);
- Ref<Texture> get_texture() const;
+ void set_texture(const Ref<Texture2D> &p_texture);
+ Ref<Texture2D> get_texture() const;
void set_region(bool p_region);
bool is_region() const;
diff --git a/scene/3d/voxel_light_baker.cpp b/scene/3d/voxel_light_baker.cpp
index c1ec59d49f..1b6e328342 100644
--- a/scene/3d/voxel_light_baker.cpp
+++ b/scene/3d/voxel_light_baker.cpp
@@ -527,7 +527,7 @@ VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Ref<Material
if (mat.is_valid()) {
- Ref<Texture> albedo_tex = mat->get_texture(SpatialMaterial::TEXTURE_ALBEDO);
+ Ref<Texture2D> albedo_tex = mat->get_texture(SpatialMaterial::TEXTURE_ALBEDO);
Ref<Image> img_albedo;
if (albedo_tex.is_valid()) {
@@ -538,7 +538,7 @@ VoxelLightBaker::MaterialCache VoxelLightBaker::_get_material_cache(Ref<Material
mc.albedo = _get_bake_texture(img_albedo, Color(1, 1, 1), mat->get_albedo()); // no albedo texture, color is additive
}
- Ref<Texture> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION);
+ Ref<Texture2D> emission_tex = mat->get_texture(SpatialMaterial::TEXTURE_EMISSION);
Color emission_col = mat->get_emission();
float emission_energy = mat->get_emission_energy();