summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/texture.cpp20
-rw-r--r--scene/resources/texture.h3
2 files changed, 22 insertions, 1 deletions
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 0b8ad5536c..b819dc13b3 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 3a0f466b4f..662614e0e5 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;