diff --git a/core/bind/core_bind.cpp b/core/bind/core_bind.cpp index 61209ecb902..73f6f753b95 100644 --- a/core/bind/core_bind.cpp +++ b/core/bind/core_bind.cpp @@ -413,6 +413,56 @@ void _OS::dump_memory_to_file(const String& p_file) { OS::get_singleton()->dump_memory_to_file(p_file.utf8().get_data()); } +struct _OSCoreBindImg { + + String path; + Size2 size; + int fmt; + ObjectID id; + int vram; + bool operator<(const _OSCoreBindImg& p_img) const { return vram==p_img.vram ? id p_img.vram; } +}; + +void _OS::print_all_textures_by_size() { + + + List<_OSCoreBindImg> imgs; + int total=0; + { + List > rsrc; + ResourceCache::get_cached_resources(&rsrc); + + for (List >::Element *E=rsrc.front();E;E=E->next()) { + + if (!E->get()->is_type("ImageTexture")) + continue; + + Size2 size = E->get()->call("get_size"); + int fmt = E->get()->call("get_format"); + + _OSCoreBindImg img; + img.size=size; + img.fmt=fmt; + img.path=E->get()->get_path(); + img.vram=Image::get_image_data_size(img.size.width,img.size.height,Image::Format(img.fmt)); + img.id=E->get()->get_instance_ID(); + total+=img.vram; + imgs.push_back(img); + } + } + + imgs.sort(); + + for(List<_OSCoreBindImg>::Element *E=imgs.front();E;E=E->next()) { + + print_line(E->get().path+" - "+String::humanize_size(E->get().vram)+" ("+E->get().size+") - total:"+String::humanize_size(total) ); + total-=E->get().vram; + } + + + +} + void _OS::print_all_resources(const String& p_to_file ) { OS::get_singleton()->print_all_resources(p_to_file); @@ -516,6 +566,8 @@ void _OS::_bind_methods() { ObjectTypeDB::bind_method(_MD("get_frames_per_second"),&_OS::get_frames_per_second); + ObjectTypeDB::bind_method(_MD("print_all_textures_by_size"),&_OS::print_all_textures_by_size); + BIND_CONSTANT( DAY_SUNDAY ); BIND_CONSTANT( DAY_MONDAY ); BIND_CONSTANT( DAY_TUESDAY ); diff --git a/core/bind/core_bind.h b/core/bind/core_bind.h index e47c9c434a6..9545fc65fb8 100644 --- a/core/bind/core_bind.h +++ b/core/bind/core_bind.h @@ -128,6 +128,7 @@ public: void print_resources_in_use(bool p_short=false); void print_all_resources(const String& p_to_file); + void print_all_textures_by_size(); bool has_touchscreen_ui_hint() const; diff --git a/core/image.cpp b/core/image.cpp index a9485feff2a..ccabd04d6f1 100644 --- a/core/image.cpp +++ b/core/image.cpp @@ -1260,6 +1260,12 @@ int Image::get_format_pixel_size(Format p_format) { return 1; } break; + case FORMAT_ATC: + case FORMAT_ATC_ALPHA_EXPLICIT: + case FORMAT_ATC_ALPHA_INTERPOLATED: { + + return 1; + } break; case FORMAT_ETC: { return 1; @@ -1323,6 +1329,15 @@ void Image::_get_format_min_data_size(Format p_format,int &r_w, int &r_h) { r_w=8; r_h=8; } break; + case FORMAT_ATC: + case FORMAT_ATC_ALPHA_EXPLICIT: + case FORMAT_ATC_ALPHA_INTERPOLATED: { + + r_w=8; + r_h=8; + + } break; + case FORMAT_ETC: { r_w=4; @@ -1339,7 +1354,7 @@ void Image::_get_format_min_data_size(Format p_format,int &r_w, int &r_h) { int Image::get_format_pixel_rshift(Format p_format) { - if (p_format==FORMAT_BC1 || p_format==FORMAT_BC4 || p_format==FORMAT_PVRTC4 || p_format==FORMAT_PVRTC4_ALPHA || p_format==FORMAT_ETC) + if (p_format==FORMAT_BC1 || p_format==FORMAT_BC4 || p_format==FORMAT_ATC || p_format==FORMAT_PVRTC4 || p_format==FORMAT_PVRTC4_ALPHA || p_format==FORMAT_ETC) return 1; else if (p_format==FORMAT_PVRTC2 || p_format==FORMAT_PVRTC2_ALPHA) return 2; diff --git a/core/image.h b/core/image.h index 4ab2870c235..186aceb1bfb 100644 --- a/core/image.h +++ b/core/image.h @@ -70,6 +70,9 @@ public: FORMAT_PVRTC4, FORMAT_PVRTC4_ALPHA, FORMAT_ETC, // regular ETC, no transparency + FORMAT_ATC, + FORMAT_ATC_ALPHA_EXPLICIT, + FORMAT_ATC_ALPHA_INTERPOLATED, /*FORMAT_ETC2_R, for the future.. FORMAT_ETC2_RG, FORMAT_ETC2_RGB, diff --git a/core/io/resource_format_binary.cpp b/core/io/resource_format_binary.cpp index d2461498a61..c54398935ef 100644 --- a/core/io/resource_format_binary.cpp +++ b/core/io/resource_format_binary.cpp @@ -90,6 +90,9 @@ enum { IMAGE_FORMAT_PVRTC4=14, IMAGE_FORMAT_PVRTC4_ALPHA=15, IMAGE_FORMAT_ETC=16, + IMAGE_FORMAT_ATC=17, + IMAGE_FORMAT_ATC_ALPHA_EXPLICIT=18, + IMAGE_FORMAT_ATC_ALPHA_INTERPOLATED=19, IMAGE_FORMAT_CUSTOM=30, @@ -283,6 +286,9 @@ Error ResourceInteractiveLoaderBinary::parse_variant(Variant& r_v) { case IMAGE_FORMAT_PVRTC4: { fmt=Image::FORMAT_PVRTC4; } break; case IMAGE_FORMAT_PVRTC4_ALPHA: { fmt=Image::FORMAT_PVRTC4_ALPHA; } break; case IMAGE_FORMAT_ETC: { fmt=Image::FORMAT_ETC; } break; + case IMAGE_FORMAT_ATC: { fmt=Image::FORMAT_ATC; } break; + case IMAGE_FORMAT_ATC_ALPHA_EXPLICIT: { fmt=Image::FORMAT_ATC_ALPHA_EXPLICIT; } break; + case IMAGE_FORMAT_ATC_ALPHA_INTERPOLATED: { fmt=Image::FORMAT_ATC_ALPHA_INTERPOLATED; } break; case IMAGE_FORMAT_CUSTOM: { fmt=Image::FORMAT_CUSTOM; } break; default: { @@ -1335,6 +1341,9 @@ void ResourceFormatSaverBinaryInstance::write_variant(const Variant& p_property, case Image::FORMAT_PVRTC4: f->store_32(IMAGE_FORMAT_PVRTC4 ); break; case Image::FORMAT_PVRTC4_ALPHA: f->store_32(IMAGE_FORMAT_PVRTC4_ALPHA ); break; case Image::FORMAT_ETC: f->store_32(IMAGE_FORMAT_ETC); break; + case Image::FORMAT_ATC: f->store_32(IMAGE_FORMAT_ATC); break; + case Image::FORMAT_ATC_ALPHA_EXPLICIT: f->store_32(IMAGE_FORMAT_ATC_ALPHA_EXPLICIT); break; + case Image::FORMAT_ATC_ALPHA_INTERPOLATED: f->store_32(IMAGE_FORMAT_ATC_ALPHA_INTERPOLATED); break; case Image::FORMAT_CUSTOM: f->store_32(IMAGE_FORMAT_CUSTOM ); break; default: {} diff --git a/core/io/resource_format_xml.cpp b/core/io/resource_format_xml.cpp index bd8e46556c7..fc5aecfd990 100644 --- a/core/io/resource_format_xml.cpp +++ b/core/io/resource_format_xml.cpp @@ -551,6 +551,12 @@ Error ResourceInteractiveLoaderXML::parse_property(Variant& r_v, String &r_name) imgformat=Image::FORMAT_PVRTC4_ALPHA; } else if (format=="etc") { imgformat=Image::FORMAT_ETC; + } else if (format=="atc") { + imgformat=Image::FORMAT_ATC; + } else if (format=="atcai") { + imgformat=Image::FORMAT_ATC_ALPHA_INTERPOLATED; + } else if (format=="atcae") { + imgformat=Image::FORMAT_ATC_ALPHA_EXPLICIT; } else if (format=="custom") { imgformat=Image::FORMAT_CUSTOM; } else { @@ -1937,6 +1943,9 @@ void ResourceFormatSaverXMLInstance::write_property(const String& p_name,const V case Image::FORMAT_PVRTC4: params+=" format=\"pvrtc4\""; break; case Image::FORMAT_PVRTC4_ALPHA: params+=" format=\"pvrtc4a\""; break; case Image::FORMAT_ETC: params+=" format=\"etc\""; break; + case Image::FORMAT_ATC: params+=" format=\"atc\""; break; + case Image::FORMAT_ATC_ALPHA_EXPLICIT: params+=" format=\"atcae\""; break; + case Image::FORMAT_ATC_ALPHA_INTERPOLATED: params+=" format=\"atcai\""; break; case Image::FORMAT_CUSTOM: params+=" format=\"custom\" custom_size=\""+itos(img.get_data().size())+"\""; break; default: {} } diff --git a/core/io/resource_loader.cpp b/core/io/resource_loader.cpp index 13dac6ed162..5ee48bae252 100644 --- a/core/io/resource_loader.cpp +++ b/core/io/resource_loader.cpp @@ -192,7 +192,7 @@ RES ResourceLoader::load(const String &p_path,const String& p_type_hint,bool p_n res->set_last_modified_time(mt); } #endif - print_line("LOADED: "+res->get_path()); + return res; } diff --git a/core/variant_call.cpp b/core/variant_call.cpp index 846b924a425..be1b0eb3d39 100644 --- a/core/variant_call.cpp +++ b/core/variant_call.cpp @@ -1487,6 +1487,9 @@ _VariantCall::addfunc(Variant::m_vtype,Variant::m_ret,_SCS(#m_method),VCALL(m_cl _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC4"]=Image::FORMAT_PVRTC4; _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_PVRTC4_ALPHA"]=Image::FORMAT_PVRTC4_ALPHA; _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ETC"]=Image::FORMAT_ETC; + _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC"]=Image::FORMAT_ATC; + _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC_ALPHA_EXPLICIT"]=Image::FORMAT_ATC_ALPHA_EXPLICIT; + _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_ATC_ALPHA_INTERPOLATED"]=Image::FORMAT_ATC_ALPHA_INTERPOLATED; _VariantCall::constant_data[Variant::IMAGE].value["FORMAT_CUSTOM"]=Image::FORMAT_CUSTOM; } diff --git a/demos/2d/platformer/engine.cfg b/demos/2d/platformer/engine.cfg index 0ca951ed008..5fc2c3b2bae 100644 --- a/demos/2d/platformer/engine.cfg +++ b/demos/2d/platformer/engine.cfg @@ -26,3 +26,7 @@ default_gravity=700 [render] mipmap_policy=1 + +[texture_import] + +filter=false diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index d29ecd64bb9..5be6045d508 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -303,6 +303,11 @@ void RasterizerGLES2::_draw_primitive(int p_points, const Vector3 *p_vertices, c #define _EXT_COMPRESSED_SIGNED_RED_GREEN_RGTC2_EXT 0x8DBE #define _EXT_ETC1_RGB8_OES 0x8D64 +#define _EXT_ATC_RGB_AMD 0x8C92 +#define _EXT_ATC_RGBA_EXPLICIT_ALPHA_AMD 0x8C93 +#define _EXT_ATC_RGBA_INTERPOLATED_ALPHA_AMD 0x87EE + + /* TEXTURE API */ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::Format p_format, uint32_t p_flags,GLenum& r_gl_format,int &r_gl_components,bool &r_has_alpha_cache,bool &r_compressed) { @@ -394,6 +399,7 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For } break; case Image::FORMAT_BC5: { + r_gl_format=_EXT_COMPRESSED_RG_RGTC2; r_gl_components=1; //doesn't matter much r_compressed=true; @@ -491,6 +497,63 @@ Image RasterizerGLES2::_get_gl_image_and_format(const Image& p_image, Image::For r_compressed=true; } + } break; + case Image::FORMAT_ATC: { + + if (!atitc_supported) { + + if (!image.empty()) { + image.decompress(); + } + r_gl_components=3; + r_gl_format=GL_RGB; + + + } else { + + r_gl_format=_EXT_ATC_RGB_AMD; + r_gl_components=1; //doesn't matter much + r_compressed=true; + } + + } break; + case Image::FORMAT_ATC_ALPHA_EXPLICIT: { + + if (!atitc_supported) { + + if (!image.empty()) { + image.decompress(); + } + r_gl_components=4; + r_gl_format=GL_RGBA; + + + } else { + + r_gl_format=_EXT_ATC_RGBA_EXPLICIT_ALPHA_AMD; + r_gl_components=1; //doesn't matter much + r_compressed=true; + } + + } break; + case Image::FORMAT_ATC_ALPHA_INTERPOLATED: { + + if (!atitc_supported) { + + if (!image.empty()) { + image.decompress(); + } + r_gl_components=4; + r_gl_format=GL_RGBA; + + + } else { + + r_gl_format=_EXT_ATC_RGBA_INTERPOLATED_ALPHA_AMD; + r_gl_components=1; //doesn't matter much + r_compressed=true; + } + } break; case Image::FORMAT_YUV_422: case Image::FORMAT_YUV_444: { @@ -557,7 +620,9 @@ void RasterizerGLES2::texture_allocate(RID p_texture,int p_width, int p_height,I texture->flags=p_flags; texture->target = (p_flags & VS::TEXTURE_FLAG_CUBEMAP) ? GL_TEXTURE_CUBE_MAP : GL_TEXTURE_2D; - bool scale_textures = !(p_flags&VS::TEXTURE_FLAG_VIDEO_SURFACE) && (!npo2_textures_available || p_flags&VS::TEXTURE_FLAG_MIPMAPS); + _get_gl_image_and_format(Image(),texture->format,texture->flags,format,components,has_alpha_cache,compressed); + + bool scale_textures = !compressed && !(p_flags&VS::TEXTURE_FLAG_VIDEO_SURFACE) && (!npo2_textures_available || p_flags&VS::TEXTURE_FLAG_MIPMAPS); if (scale_textures) { @@ -570,7 +635,6 @@ void RasterizerGLES2::texture_allocate(RID p_texture,int p_width, int p_height,I texture->alloc_height = texture->height; }; - _get_gl_image_and_format(Image(),texture->format,texture->flags,format,components,has_alpha_cache,compressed); texture->gl_components_cache=components; texture->gl_format_cache=format; @@ -584,32 +648,7 @@ void RasterizerGLES2::texture_allocate(RID p_texture,int p_width, int p_height,I glBindTexture(texture->target, texture->tex_id); - if (texture->flags&VS::TEXTURE_FLAG_MIPMAPS) - glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,use_fast_texture_filter?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR_MIPMAP_LINEAR); - else - glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_LINEAR); - if (texture->flags&VS::TEXTURE_FLAG_FILTER) { - - glTexParameteri(texture->target,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering - - } else { - - glTexParameteri(texture->target,GL_TEXTURE_MAG_FILTER,GL_NEAREST); // raw Filtering - } - - bool force_clamp_to_edge = !(p_flags&VS::TEXTURE_FLAG_MIPMAPS) && (nearest_power_of_2(texture->alloc_height)!=texture->alloc_height || nearest_power_of_2(texture->alloc_width)!=texture->alloc_width); - - if (!force_clamp_to_edge && texture->flags&VS::TEXTURE_FLAG_REPEAT && texture->target != GL_TEXTURE_CUBE_MAP) { - - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); - glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); - } else { - - //glTexParameterf( texture->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); - glTexParameterf( texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); - glTexParameterf( texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); - } if (p_flags&VS::TEXTURE_FLAG_VIDEO_SURFACE) { //prealloc if video @@ -652,6 +691,8 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu texture->has_alpha=true; } + + GLenum blit_target = (texture->target == GL_TEXTURE_CUBE_MAP)?_cube_side_enum[p_cube_side]:GL_TEXTURE_2D; texture->data_size=img.get_data().size(); @@ -660,6 +701,35 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu glActiveTexture(GL_TEXTURE0); glBindTexture(texture->target, texture->tex_id); + texture->ignore_mipmaps = compressed && img.get_mipmaps()==0; + + if (texture->flags&VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) + glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,use_fast_texture_filter?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR_MIPMAP_LINEAR); + else + glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + + if (texture->flags&VS::TEXTURE_FLAG_FILTER) { + + glTexParameteri(texture->target,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering + + } else { + + glTexParameteri(texture->target,GL_TEXTURE_MAG_FILTER,GL_NEAREST); // raw Filtering + } + + bool force_clamp_to_edge = !(texture->flags&VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) && (nearest_power_of_2(texture->alloc_height)!=texture->alloc_height || nearest_power_of_2(texture->alloc_width)!=texture->alloc_width); + + if (!force_clamp_to_edge && texture->flags&VS::TEXTURE_FLAG_REPEAT && texture->target != GL_TEXTURE_CUBE_MAP) { + + glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT ); + glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT ); + } else { + + //glTexParameterf( texture->target, GL_TEXTURE_WRAP_R, GL_CLAMP_TO_EDGE ); + glTexParameterf( texture->target, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE ); + glTexParameterf( texture->target, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE ); + } + int mipmaps= (texture->flags&VS::TEXTURE_FLAG_MIPMAPS && img.get_mipmaps()>0) ? img.get_mipmaps() +1 : 1; @@ -699,7 +769,7 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu //printf("texture: %i x %i - size: %i - total: %i\n",texture->width,texture->height,tsize,_rinfo.texture_mem); - if (texture->flags&VS::TEXTURE_FLAG_MIPMAPS && mipmaps==1) { + if (texture->flags&VS::TEXTURE_FLAG_MIPMAPS && mipmaps==1 && !texture->ignore_mipmaps) { //generate mipmaps if they were requested and the image does not contain them glGenerateMipmap(texture->target); } @@ -889,7 +959,7 @@ void RasterizerGLES2::texture_set_flags(RID p_texture,uint32_t p_flags) { uint32_t cube = texture->flags & VS::TEXTURE_FLAG_CUBEMAP; texture->flags=p_flags|cube; // can't remove a cube from being a cube - bool force_clamp_to_edge = !(p_flags&VS::TEXTURE_FLAG_MIPMAPS) && (nearest_power_of_2(texture->alloc_height)!=texture->alloc_height || nearest_power_of_2(texture->alloc_width)!=texture->alloc_width); + bool force_clamp_to_edge = !(p_flags&VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) && (nearest_power_of_2(texture->alloc_height)!=texture->alloc_height || nearest_power_of_2(texture->alloc_width)!=texture->alloc_width); if (!force_clamp_to_edge && texture->flags&VS::TEXTURE_FLAG_REPEAT && texture->target != GL_TEXTURE_CUBE_MAP) { @@ -903,17 +973,18 @@ void RasterizerGLES2::texture_set_flags(RID p_texture,uint32_t p_flags) { } + if (texture->flags&VS::TEXTURE_FLAG_MIPMAPS && !texture->ignore_mipmaps) + glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,use_fast_texture_filter?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR_MIPMAP_LINEAR); + else + glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_LINEAR); + if (texture->flags&VS::TEXTURE_FLAG_FILTER) { glTexParameteri(texture->target,GL_TEXTURE_MAG_FILTER,GL_LINEAR); // Linear Filtering - if (texture->flags&VS::TEXTURE_FLAG_MIPMAPS) - glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,use_fast_texture_filter?GL_LINEAR_MIPMAP_NEAREST:GL_LINEAR_MIPMAP_LINEAR); - else - glTexParameteri(texture->target,GL_TEXTURE_MIN_FILTER,GL_LINEAR); // Linear Filtering } else { - glTexParameteri(texture->target,GL_TEXTURE_MAG_FILTER,GL_NEAREST); // nearest + glTexParameteri(texture->target,GL_TEXTURE_MAG_FILTER,GL_NEAREST); // raw Filtering } } uint32_t RasterizerGLES2::texture_get_flags(RID p_texture) const { @@ -7493,6 +7564,7 @@ void RasterizerGLES2::init() { etc_supported=false; use_depth24 =true; s3tc_supported = true; + atitc_supported = false; use_hw_skeleton_xform = false; // use_texture_instancing=false; // use_attribute_instancing=true; @@ -7506,6 +7578,10 @@ void RasterizerGLES2::init() { use_half_float=true; #else + + for (Set::Element *E=extensions.front();E;E=E->next()) { + print_line(E->get()); + } read_depth_supported=extensions.has("GL_OES_depth_texture"); use_rgba_shadowmaps=!read_depth_supported; pvr_supported=extensions.has("GL_IMG_texture_compression_pvrtc"); @@ -7513,7 +7589,9 @@ void RasterizerGLES2::init() { use_depth24 = extensions.has("GL_OES_depth24"); s3tc_supported = extensions.has("GL_EXT_texture_compression_dxt1") || extensions.has("GL_EXT_texture_compression_s3tc") || extensions.has("WEBGL_compressed_texture_s3tc"); use_half_float = extensions.has("GL_OES_vertex_half_float"); + atitc_supported=extensions.has("GL_AMD_compressed_ATC_texture"); + print_line("S3TC: "+itos(s3tc_supported)+" ATITC: "+itos(atitc_supported)); GLint vtf; glGetIntegerv(GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS,&vtf); @@ -7885,6 +7963,7 @@ RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays,bool p_keep_ram_copy,boo use_fast_texture_filter=GLOBAL_DEF("rasterizer/trilinear_mipmap_filter",true); skel_default.resize(1024*4); for(int i=0;i<1024/3;i++) { + float * ptr = skel_default.ptr(); ptr+=i*4*4; ptr[0]=1.0; @@ -7901,7 +7980,6 @@ RasterizerGLES2::RasterizerGLES2(bool p_compress_arrays,bool p_keep_ram_copy,boo ptr[9]=0.0; ptr[10]=1.0; ptr[12]=0.0; - } base_framebuffer=0; diff --git a/drivers/gles2/rasterizer_gles2.h b/drivers/gles2/rasterizer_gles2.h index bab560dddb6..52c4c8d681a 100644 --- a/drivers/gles2/rasterizer_gles2.h +++ b/drivers/gles2/rasterizer_gles2.h @@ -75,6 +75,7 @@ class RasterizerGLES2 : public Rasterizer { bool pvr_supported; bool s3tc_supported; bool etc_supported; + bool atitc_supported; bool npo2_textures_available; bool read_depth_supported; bool use_framebuffers; @@ -111,6 +112,7 @@ class RasterizerGLES2 : public Rasterizer { bool compressed; bool disallow_mipmaps; int total_data_size; + bool ignore_mipmaps; ObjectID reloader; StringName reloader_func; @@ -123,6 +125,7 @@ class RasterizerGLES2 : public Rasterizer { Texture() { + ignore_mipmaps=false; render_target=NULL; flags=width=height=0; tex_id=0; diff --git a/scene/2d/node_2d.cpp b/scene/2d/node_2d.cpp index 9b2994ef849..a2bee43e58e 100644 --- a/scene/2d/node_2d.cpp +++ b/scene/2d/node_2d.cpp @@ -162,6 +162,10 @@ void Node2D::set_scale(const Size2& p_scale) { if (_xform_dirty) ((Node2D*)this)->_update_xform_values(); scale=p_scale; + if (scale.x==0) + scale.x=CMP_EPSILON; + if (scale.y==0) + scale.y=CMP_EPSILON; _update_transform(); _change_notify("transform/scale"); diff --git a/scene/gui/tree.cpp b/scene/gui/tree.cpp index 9be3c979014..fb85f0c6b79 100644 --- a/scene/gui/tree.cpp +++ b/scene/gui/tree.cpp @@ -1591,7 +1591,7 @@ int Tree::propagate_mouse_event(const Point2i &p_pos,int x_ofs,int y_ofs,bool p_ case TreeItem::CELL_MODE_CUSTOM: { edited_item=p_item; edited_col=col; - custom_popup_rect=Rect2i(get_global_pos() + Point2i(col_ofs,_get_title_button_height()+y_ofs+item_h-v_scroll->get_val()), Size2(get_column_width(col),item_h)); + custom_popup_rect=Rect2i(get_global_pos() + Point2i(col_ofs,_get_title_button_height()+y_ofs+item_h-cache.offset.y), Size2(get_column_width(col),item_h)); emit_signal("custom_popup_edited",((bool)(x >= (col_width-item_h/2)))); bring_up_editor=false; diff --git a/scene/main/node.cpp b/scene/main/node.cpp index 5ac09e837ff..9b592a77d54 100644 --- a/scene/main/node.cpp +++ b/scene/main/node.cpp @@ -552,6 +552,8 @@ void Node::_validate_child_name(Node *p_child) { int cc = data.children.size(); for(int i=0;idata.name==p_child->data.name) { unique=false; break; diff --git a/scene/main/viewport.cpp b/scene/main/viewport.cpp index ae2b9250088..4aed217cefb 100644 --- a/scene/main/viewport.cpp +++ b/scene/main/viewport.cpp @@ -782,16 +782,41 @@ void Viewport::_bind_methods() { ObjectTypeDB::bind_method(_MD("set_as_render_target","enable"), &Viewport::set_as_render_target); ObjectTypeDB::bind_method(_MD("is_set_as_render_target"), &Viewport::is_set_as_render_target); + ObjectTypeDB::bind_method(_MD("set_render_target_update_mode","mode"), &Viewport::set_render_target_update_mode); + ObjectTypeDB::bind_method(_MD("get_render_target_update_mode"), &Viewport::get_render_target_update_mode); + + ObjectTypeDB::bind_method(_MD("get_render_target_texture:RenderTargetTexture"), &Viewport::get_render_target_texture); + + ObjectTypeDB::bind_method(_MD("get_viewport"), &Viewport::get_viewport); + ObjectTypeDB::bind_method(_MD("update_worlds"), &Viewport::update_worlds); + + ObjectTypeDB::bind_method(_MD("set_as_audio_listener","enable"), &Viewport::set_as_audio_listener); + ObjectTypeDB::bind_method(_MD("is_audio_listener","enable"), &Viewport::is_audio_listener); + + ObjectTypeDB::bind_method(_MD("set_as_audio_listener_2d","enable"), &Viewport::set_as_audio_listener_2d); + ObjectTypeDB::bind_method(_MD("is_audio_listener_2d","enable"), &Viewport::is_audio_listener_2d); + + + ADD_PROPERTY( PropertyInfo(Variant::RECT2,"rect"), _SCS("set_rect"), _SCS("get_rect") ); ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world",PROPERTY_HINT_RESOURCE_TYPE,"World"), _SCS("set_world"), _SCS("get_world") ); // ADD_PROPERTY( PropertyInfo(Variant::OBJECT,"world_2d",PROPERTY_HINT_RESOURCE_TYPE,"World2D"), _SCS("set_world_2d"), _SCS("get_world_2d") ); ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transparent_bg"), _SCS("set_transparent_background"), _SCS("has_transparent_background") ); - ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target"), _SCS("set_as_render_target"), _SCS("is_set_as_render_target") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"render_target/enabled"), _SCS("set_as_render_target"), _SCS("is_set_as_render_target") ); + ADD_PROPERTY( PropertyInfo(Variant::INT,"render_target/update_mode",PROPERTY_HINT_ENUM,"Disabled,Once,When Visible,Always"), _SCS("set_render_target_update_mode"), _SCS("get_render_target_update_mode") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener/enable_2d"), _SCS("set_as_audio_listener_2d"), _SCS("is_audio_listener_2d") ); + ADD_PROPERTY( PropertyInfo(Variant::BOOL,"audio_listener/enable_3d"), _SCS("set_as_audio_listener"), _SCS("is_audio_listener") ); ADD_SIGNAL(MethodInfo("size_changed")); + + BIND_CONSTANT( RENDER_TARGET_UPDATE_DISABLED ); + BIND_CONSTANT( RENDER_TARGET_UPDATE_ONCE ); + BIND_CONSTANT( RENDER_TARGET_UPDATE_WHEN_VISIBLE ); + BIND_CONSTANT( RENDER_TARGET_UPDATE_ALWAYS ); + } diff --git a/scene/main/viewport.h b/scene/main/viewport.h index a35bc51e1e1..7fbae20f7d1 100644 --- a/scene/main/viewport.h +++ b/scene/main/viewport.h @@ -154,11 +154,9 @@ public: Camera* get_camera() const; - void set_listener_transform(const Transform& p_xform); void set_as_audio_listener(bool p_enable); bool is_audio_listener() const; - void set_listener_2d_transform(const Matrix32& p_xform); void set_as_audio_listener_2d(bool p_enable); bool is_audio_listener_2d() const; diff --git a/tools/editor/editor_import_export.cpp b/tools/editor/editor_import_export.cpp index 22b611fdcc7..1a5dd73040c 100644 --- a/tools/editor/editor_import_export.cpp +++ b/tools/editor/editor_import_export.cpp @@ -492,6 +492,7 @@ Error EditorExportPlatform::export_project_files(EditorExportSaveFunction p_func int group_format=0; float group_lossy_quality=EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(E->get()); int group_shrink=EditorImportExport::get_singleton()->image_export_group_get_shrink(E->get()); + group_shrink*=EditorImportExport::get_singleton()->get_export_image_shrink(); switch(EditorImportExport::get_singleton()->image_export_group_get_image_action(E->get())) { case EditorImportExport::IMAGE_ACTION_NONE: { @@ -1186,6 +1187,16 @@ EditorImportExport::ImageAction EditorImportExport::get_export_image_action() co return image_action; } +void EditorImportExport::set_export_image_shrink(int p_shrink) { + + image_shrink=p_shrink; +} + +int EditorImportExport::get_export_image_shrink() const{ + + return image_shrink; +} + void EditorImportExport::set_export_image_quality(float p_quality){ @@ -1336,6 +1347,10 @@ void EditorImportExport::load_config() { image_action=IMAGE_ACTION_COMPRESS_DISK; image_action_compress_quality = cf->get_value(ci,"compress_quality"); + if (cf->has_section_key(ci,"shrink")) + image_shrink = cf->get_value(ci,"shrink"); + else + image_shrink=1; String formats=cf->get_value(ci,"formats"); Vector f = formats.split(","); image_formats.clear(); @@ -1382,8 +1397,6 @@ void EditorImportExport::load_config() { List keys; cf->get_section_keys(s,&keys); for(List::Element *F=keys.front();F;F=F->next()) { - print_line("sk: "+F->get()); - ep->set(F->get(),cf->get_value(s,F->get())); } } @@ -1494,6 +1507,7 @@ void EditorImportExport::save_config() { case IMAGE_ACTION_COMPRESS_DISK: cf->set_value("convert_images","action","compress_disk"); break; } + cf->set_value("convert_images","shrink",image_shrink); cf->set_value("convert_images","compress_quality",image_action_compress_quality); String formats; @@ -1562,9 +1576,7 @@ EditorImportExport::EditorImportExport() { image_action=IMAGE_ACTION_NONE; image_action_compress_quality=0.7; image_formats.insert("png"); - - - + image_shrink=1; } diff --git a/tools/editor/editor_import_export.h b/tools/editor/editor_import_export.h index 17f2592ad54..94fbaba842e 100644 --- a/tools/editor/editor_import_export.h +++ b/tools/editor/editor_import_export.h @@ -243,6 +243,7 @@ protected: Map by_idx; ImageAction image_action; float image_action_compress_quality; + int image_shrink; Set image_formats; ExportFilter export_filter; @@ -288,6 +289,9 @@ public: void set_export_image_action(ImageAction p_action); ImageAction get_export_image_action() const; + void set_export_image_shrink(int p_shrink); + int get_export_image_shrink() const; + void set_export_image_quality(float p_quality); float get_export_image_quality() const; diff --git a/tools/editor/editor_node.cpp b/tools/editor/editor_node.cpp index 2f7b6759b94..d8f9dcc9479 100644 --- a/tools/editor/editor_node.cpp +++ b/tools/editor/editor_node.cpp @@ -3458,8 +3458,8 @@ EditorNode::EditorNode() { p->add_item("Run Script",FILE_RUN_SCRIPT,KEY_MASK_CMD+KEY_R); p->add_separator(); p->add_item("Project Settings",RUN_SETTINGS); - p->add_item("Project Manager",RUN_PROJECT_MANAGER); p->add_separator(); + p->add_item("Quit to Project List",RUN_PROJECT_MANAGER); p->add_item("Quit",FILE_QUIT,KEY_MASK_CMD+KEY_Q); recent_scenes = memnew( PopupMenu ); diff --git a/tools/editor/io_plugins/editor_texture_import_plugin.cpp b/tools/editor/io_plugins/editor_texture_import_plugin.cpp index 067edee5a04..ff4da6af13f 100644 --- a/tools/editor/io_plugins/editor_texture_import_plugin.cpp +++ b/tools/editor/io_plugins/editor_texture_import_plugin.cpp @@ -899,6 +899,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Refget_data(); @@ -952,6 +953,7 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Refget_data(); ERR_FAIL_COND_V(image.empty(),ERR_INVALID_DATA); @@ -988,13 +990,17 @@ Error EditorTextureImportPlugin::import2(const String& p_path, const Refcreate_from_image(image,tex_flags); + if (shrink>1) { texture->set_size_override(Size2(orig_w,orig_h)); } - Error err = ResourceSaver::save(p_path,texture); + uint32_t save_flags=ResourceSaver::FLAG_COMPRESS; + + Error err = ResourceSaver::save(p_path,texture,save_flags); if (err!=OK) { EditorNode::add_io_error("Couldn't save converted texture: "+p_path); return err; @@ -1021,6 +1027,7 @@ Vector EditorTextureImportPlugin::custom_export(const String& p_path, c int group_format=0; float group_lossy_quality=EditorImportExport::get_singleton()->image_export_group_get_lossy_quality(group); int group_shrink=EditorImportExport::get_singleton()->image_export_group_get_shrink(group); + group_shrink*=EditorImportExport::get_singleton()->get_export_image_shrink(); switch(EditorImportExport::get_singleton()->image_export_group_get_image_action(group)) { case EditorImportExport::IMAGE_ACTION_NONE: { @@ -1062,6 +1069,7 @@ Vector EditorTextureImportPlugin::custom_export(const String& p_path, c flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; + print_line("group format"+itos(group_format)); rimd->set_option("format",group_format); rimd->set_option("flags",flags); rimd->set_option("quality",group_lossy_quality); @@ -1090,6 +1098,7 @@ Vector EditorTextureImportPlugin::custom_export(const String& p_path, c flags|=IMAGE_FLAG_FIX_BORDER_ALPHA; + rimd->set_option("shrink",EditorImportExport::get_singleton()->get_export_image_shrink()); rimd->set_option("flags",flags); rimd->set_option("quality",EditorImportExport::get_singleton()->get_export_image_quality()); rimd->set_option("atlas",false); @@ -1108,18 +1117,21 @@ Vector EditorTextureImportPlugin::custom_export(const String& p_path, c } uint32_t flags = rimd->get_option("flags"); + uint8_t shrink = rimd->has_option("shrink") ? rimd->get_option("shrink"): Variant(1); + uint8_t format = rimd->get_option("format"); + uint8_t comp = (format==EditorTextureImportPlugin::IMAGE_FORMAT_COMPRESS_RAM)?uint8_t(p_platform->get_image_compression()):uint8_t(255); MD5_CTX ctx; uint8_t f4[4]; encode_uint32(flags,&f4[0]); - uint8_t ic = p_platform->get_image_compression(); MD5Init(&ctx); String gp = Globals::get_singleton()->globalize_path(p_path); CharString cs = gp.utf8(); MD5Update(&ctx,(unsigned char*)cs.get_data(),cs.length()); MD5Update(&ctx,f4,4); - MD5Update(&ctx,&ic,1); - + MD5Update(&ctx,&format,1); + MD5Update(&ctx,&comp,1); + MD5Update(&ctx,&shrink,1); MD5Final(&ctx); uint64_t sd=0; @@ -1137,6 +1149,7 @@ Vector EditorTextureImportPlugin::custom_export(const String& p_path, c uint64_t d = f->get_line().strip_edges().to_int64(); sd = FileAccess::get_modified_time(p_path); + if (d==sd) { valid=true; } else { diff --git a/tools/editor/project_export.cpp b/tools/editor/project_export.cpp index 192fcaa9080..eae5dacb272 100644 --- a/tools/editor/project_export.cpp +++ b/tools/editor/project_export.cpp @@ -207,6 +207,12 @@ void ProjectExportDialog::_quality_edited(float what) { _save_export_cfg(); } +void ProjectExportDialog::_shrink_edited(float what) { + + EditorImportExport::get_singleton()->set_export_image_shrink(what); + _save_export_cfg(); +} + void ProjectExportDialog::_image_export_edited(int what) { EditorImportExport::get_singleton()->set_export_image_action(EditorImportExport::ImageAction(what)); @@ -270,7 +276,9 @@ void ProjectExportDialog::_notification(int p_what) { image_action->select(EditorImportExport::get_singleton()->get_export_image_action()); image_quality->set_val(EditorImportExport::get_singleton()->get_export_image_quality()); + image_shrink->set_val(EditorImportExport::get_singleton()->get_export_image_quality()); image_quality->connect("value_changed",this,"_quality_edited"); + image_shrink->connect("value_changed",this,"_shrink_edited"); image_action->connect("item_selected",this,"_image_export_edited"); for(int i=0;iset_max(1); image_quality->set_step(0.01); image_vb->add_margin_child("Compress for Disk (Lossy) Quality:",qhb); + image_shrink = memnew( SpinBox ); + image_shrink->set_min(1); + image_shrink->set_max(8); + image_shrink->set_step(1); + image_vb->add_margin_child("Shrink All Images:",image_shrink); sections->add_child(image_vb); image_formats=memnew(Tree); diff --git a/tools/editor/project_export.h b/tools/editor/project_export.h index 25709babb9a..6ceffadc626 100644 --- a/tools/editor/project_export.h +++ b/tools/editor/project_export.h @@ -110,6 +110,7 @@ private: VBoxContainer *image_vb; OptionButton *image_action; HSlider *image_quality; + SpinBox *image_shrink; Tree *image_formats; Vector formats; @@ -150,6 +151,8 @@ private: void _quality_edited(float what); void _image_export_edited(int what); + void _shrink_edited(float what); + void _update_group_list(); void _select_group(const String& p_by_name);