diff options
-rw-r--r-- | editor/import/resource_importer_texture.cpp | 9 | ||||
-rw-r--r-- | scene/resources/material.cpp | 11 | ||||
-rw-r--r-- | scene/resources/material.h | 6 |
3 files changed, 25 insertions, 1 deletions
diff --git a/editor/import/resource_importer_texture.cpp b/editor/import/resource_importer_texture.cpp index ade3550daa..f29bdde634 100644 --- a/editor/import/resource_importer_texture.cpp +++ b/editor/import/resource_importer_texture.cpp @@ -33,7 +33,7 @@ #include "io/config_file.h" #include "io/image_loader.h" #include "scene/resources/texture.h" - +#include "editor/editor_node.h" void ResourceImporterTexture::_texture_reimport_srgb(const Ref<StreamTexture> &p_tex) { singleton->mutex->lock(); @@ -411,10 +411,14 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String if (compress_mode == COMPRESS_VIDEO_RAM) { //must import in all formats, in order of priority (so platform choses the best supported one. IE, etc2 over etc). //Android, GLES 2.x + + bool ok_on_pc=false; + if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_s3tc")) { _save_stex(image, p_save_path + ".s3tc.stex", compress_mode, lossy, Image::COMPRESS_S3TC, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); r_platform_variants->push_back("s3tc"); + ok_on_pc=true; } if (ProjectSettings::get_singleton()->get("rendering/vram_compression/import_etc2")) { @@ -434,6 +438,9 @@ Error ResourceImporterTexture::import(const String &p_source_file, const String r_platform_variants->push_back("pvrtc"); } + if (!ok_on_pc) { + EditorNode::add_io_error("Warning, no suitable PC VRAM compression enabled in Project Settings. This texture will not display correcly on PC."); + } } else { //import normally _save_stex(image, p_save_path + ".stex", compress_mode, lossy, Image::COMPRESS_S3TC /*this is ignored */, mipmaps, tex_flags, stream, detect_3d, detect_srgb, force_rgbe, detect_normal, force_normal); diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp index 3d6a10ffc7..a187692bcb 100644 --- a/scene/resources/material.cpp +++ b/scene/resources/material.cpp @@ -65,6 +65,12 @@ RID Material::get_rid() const { return material; } +void Material::_validate_property(PropertyInfo &property) const { + + if (!_can_do_next_pass() && property.name=="next_pass") { + property.usage=0; + } +} void Material::_bind_methods() { @@ -204,6 +210,11 @@ void ShaderMaterial::get_argument_options(const StringName &p_function, int p_id Resource::get_argument_options(p_function, p_idx, r_options); } +bool ShaderMaterial::_can_do_next_pass() const { + + return shader.is_valid() && shader->get_mode()==Shader::MODE_SPATIAL; +} + ShaderMaterial::ShaderMaterial() { } diff --git a/scene/resources/material.h b/scene/resources/material.h index 4e77ab1ed6..fdb11982a8 100644 --- a/scene/resources/material.h +++ b/scene/resources/material.h @@ -53,6 +53,9 @@ class Material : public Resource { protected: _FORCE_INLINE_ RID _get_material() const { return material; } static void _bind_methods(); + virtual bool _can_do_next_pass() const { return false; } + + void _validate_property(PropertyInfo &property) const; public: enum { @@ -84,6 +87,8 @@ protected: void get_argument_options(const StringName &p_function, int p_idx, List<String> *r_options) const; + virtual bool _can_do_next_pass() const; + public: void set_shader(const Ref<Shader> &p_shader); Ref<Shader> get_shader() const; @@ -394,6 +399,7 @@ private: protected: static void _bind_methods(); void _validate_property(PropertyInfo &property) const; + virtual bool _can_do_next_pass() const { return true; } public: void set_albedo(const Color &p_albedo); |