aboutsummaryrefslogtreecommitdiff
path: root/scene
diff options
context:
space:
mode:
authorJuan Linietsky2017-06-16 21:47:28 -0300
committerJuan Linietsky2017-06-16 21:49:37 -0300
commitb19225bfce3dab39f8ce6b1ecf610ea0ba650f99 (patch)
tree7946e6eabae1c679a404a9146343fe2b6f2672b7 /scene
parent8a03a29233d5ef4cf5be3aeebd76cb77c82bc983 (diff)
downloadgodot-b19225bfce3dab39f8ce6b1ecf610ea0ba650f99.tar.gz
godot-b19225bfce3dab39f8ce6b1ecf610ea0ba650f99.tar.zst
godot-b19225bfce3dab39f8ce6b1ecf610ea0ba650f99.zip
-Fix freezes caused by etccomp2, closes #9183
-Normalmaps are now detected and imported as RGTC, both in S3TC and ETC2, this improves their quality.
Diffstat (limited to 'scene')
-rw-r--r--scene/gui/color_picker.cpp6
-rw-r--r--scene/main/viewport.cpp12
-rw-r--r--scene/main/viewport.h3
-rw-r--r--scene/resources/texture.cpp20
-rw-r--r--scene/resources/texture.h3
5 files changed, 25 insertions, 19 deletions
diff --git a/scene/gui/color_picker.cpp b/scene/gui/color_picker.cpp
index d3bdc401a..bc1b16bea 100644
--- a/scene/gui/color_picker.cpp
+++ b/scene/gui/color_picker.cpp
@@ -427,10 +427,10 @@ void ColorPicker::_screen_input(const Ref<InputEvent> &ev) {
Viewport *r = get_tree()->get_root();
if (!r->get_visible_rect().has_point(Point2(mev->get_global_position().x, mev->get_global_position().y)))
return;
- Ref<Image> img = r->get_screen_capture();
+ Ref<Image> img; //= r->get_screen_capture();
if (!img.is_null()) {
last_capture = img;
- r->queue_screen_capture();
+ //r->queue_screen_capture();
}
if (last_capture.is_valid() && !last_capture->empty()) {
int pw = last_capture->get_format() == Image::FORMAT_RGBA8 ? 4 : 3;
@@ -460,7 +460,7 @@ void ColorPicker::_screen_pick_pressed() {
}
screen->raise();
screen->show_modal();
- r->queue_screen_capture();
+ // r->queue_screen_capture();
}
void ColorPicker::_bind_methods() {
diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp
index d8ec8b999..714327c5b 100644
--- a/scene/main/viewport.cpp
+++ b/scene/main/viewport.cpp
@@ -1233,16 +1233,6 @@ Viewport::UpdateMode Viewport::get_update_mode() const {
}
//RID get_texture() const;
-void Viewport::queue_screen_capture() {
-
- //VS::get_singleton()->viewport_queue_screen_capture(viewport);
-}
-Ref<Image> Viewport::get_screen_capture() const {
-
- //return VS::get_singleton()->viewport_get_screen_capture(viewport);
- return Ref<Image>();
-}
-
Ref<ViewportTexture> Viewport::get_texture() const {
return default_texture;
@@ -2581,8 +2571,6 @@ void Viewport::_bind_methods() {
ClassDB::bind_method(D_METHOD("is_size_override_enabled"), &Viewport::is_size_override_enabled);
ClassDB::bind_method(D_METHOD("set_size_override_stretch", "enabled"), &Viewport::set_size_override_stretch);
ClassDB::bind_method(D_METHOD("is_size_override_stretch_enabled"), &Viewport::is_size_override_stretch_enabled);
- ClassDB::bind_method(D_METHOD("queue_screen_capture"), &Viewport::queue_screen_capture);
- ClassDB::bind_method(D_METHOD("get_screen_capture"), &Viewport::get_screen_capture);
ClassDB::bind_method(D_METHOD("set_vflip", "enable"), &Viewport::set_vflip);
ClassDB::bind_method(D_METHOD("get_vflip"), &Viewport::get_vflip);
diff --git a/scene/main/viewport.h b/scene/main/viewport.h
index 378055bef..bd9747d87 100644
--- a/scene/main/viewport.h
+++ b/scene/main/viewport.h
@@ -413,9 +413,6 @@ public:
Vector2 get_camera_coords(const Vector2 &p_viewport_coords) const;
Vector2 get_camera_rect_size() const;
- void queue_screen_capture();
- Ref<Image> get_screen_capture() const;
-
void set_use_own_world(bool p_world);
bool is_using_own_world() const;
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 0b8ad5536..b819dc13b 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -390,8 +390,17 @@ void StreamTexture::_requested_srgb(void *p_ud) {
request_srgb_callback(stex);
}
+void StreamTexture::_requested_normal(void *p_ud) {
+
+ StreamTexture *st = (StreamTexture *)p_ud;
+ Ref<StreamTexture> stex(st);
+ ERR_FAIL_COND(!request_normal_callback);
+ request_normal_callback(stex);
+}
+
StreamTexture::TextureFormatRequestCallback StreamTexture::request_3d_callback = NULL;
StreamTexture::TextureFormatRequestCallback StreamTexture::request_srgb_callback = NULL;
+StreamTexture::TextureFormatRequestCallback StreamTexture::request_normal_callback = NULL;
uint32_t StreamTexture::get_flags() const {
@@ -421,12 +430,13 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &fla
flags = f->get_32(); //texture flags!
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) {
//print_line("request detect 3D at " + p_path);
@@ -444,6 +454,14 @@ Error StreamTexture::_load_data(const String &p_path, int &tw, int &th, int &fla
VS::get_singleton()->texture_set_detect_srgb_callback(texture, NULL, NULL);
}
+ if (request_srgb_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 {
+ //print_line("not requesting detect normal at " + p_path);
+ VS::get_singleton()->texture_set_detect_normal_callback(texture, NULL, NULL);
+ }
+#endif
if (!(df & FORMAT_BIT_STREAM)) {
p_size_limit = 0;
}
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 3a0f466b4..662614e0e 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -167,6 +167,7 @@ public:
FORMAT_BIT_HAS_MIPMAPS = 1 << 23,
FORMAT_BIT_DETECT_3D = 1 << 24,
FORMAT_BIT_DETECT_SRGB = 1 << 25,
+ FORMAT_BIT_DETECT_NORMAL = 1 << 26,
};
private:
@@ -181,6 +182,7 @@ private:
static void _requested_3d(void *p_ud);
static void _requested_srgb(void *p_ud);
+ static void _requested_normal(void *p_ud);
protected:
static void _bind_methods();
@@ -190,6 +192,7 @@ public:
static TextureFormatRequestCallback request_3d_callback;
static TextureFormatRequestCallback request_srgb_callback;
+ static TextureFormatRequestCallback request_normal_callback;
uint32_t get_flags() const;
Image::Format get_format() const;