diff options
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 24 | ||||
-rw-r--r-- | drivers/png/resource_saver_png.cpp | 3 | ||||
-rw-r--r-- | scene/io/resource_format_image.cpp | 5 | ||||
-rw-r--r-- | scene/resources/texture.cpp | 3 | ||||
-rw-r--r-- | scene/resources/texture.h | 1 | ||||
-rw-r--r-- | servers/visual_server.h | 1 |
6 files changed, 30 insertions, 7 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 9d0e0ce0cc..d3a5f3b5bc 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -1013,10 +1013,16 @@ void RasterizerGLES2::texture_set_data(RID p_texture,const Image& p_image,VS::Cu 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) { + if (!force_clamp_to_edge && (texture->flags&VS::TEXTURE_FLAG_REPEAT || texture->flags&VS::TEXTURE_FLAG_MIRRORED_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 ); + if (texture->flags&VS::TEXTURE_FLAG_MIRRORED_REPEAT){ + glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT ); + glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT ); + } + else{ + 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 ); @@ -1270,10 +1276,16 @@ void RasterizerGLES2::texture_set_flags(RID p_texture,uint32_t p_flags) { 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) { + if (!force_clamp_to_edge && (texture->flags&VS::TEXTURE_FLAG_REPEAT || texture->flags&VS::TEXTURE_FLAG_MIRRORED_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 ); + if (texture->flags&VS::TEXTURE_FLAG_MIRRORED_REPEAT){ + glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_MIRRORED_REPEAT ); + glTexParameterf( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_MIRRORED_REPEAT ); + } + else { + 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 ); diff --git a/drivers/png/resource_saver_png.cpp b/drivers/png/resource_saver_png.cpp index 8524aa2121..76e0c03c46 100644 --- a/drivers/png/resource_saver_png.cpp +++ b/drivers/png/resource_saver_png.cpp @@ -75,6 +75,9 @@ Error ResourceSaverPNG::save(const String &p_path,const RES& p_resource,uint32_t if (bool(texture->get_flags()&Texture::FLAG_CONVERT_TO_LINEAR)) { text+="tolinear=true\n"; } + if (bool(texture->get_flags()&Texture::FLAG_MIRRORED_REPEAT)) { + text+="mirroredrepeat=true\n"; + } if (text!="" || FileAccess::exists(p_path+".flags")) { diff --git a/scene/io/resource_format_image.cpp b/scene/io/resource_format_image.cpp index 2663ac0762..8527498fc2 100644 --- a/scene/io/resource_format_image.cpp +++ b/scene/io/resource_format_image.cpp @@ -180,6 +180,11 @@ RES ResourceFormatLoaderImage::load(const String &p_path,const String& p_origina if (flags_found["tolinear"]) flags|=Texture::FLAG_CONVERT_TO_LINEAR; } + + if (flags_found.has("mirroredrepeat")) { + if (flags_found["mirroredrepeat"]) + flags|=Texture::FLAG_MIRRORED_REPEAT; + } if (debug_load_times) begtime=OS::get_singleton()->get_ticks_usec(); diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp index 018af0e5db..7b261f7791 100644 --- a/scene/resources/texture.cpp +++ b/scene/resources/texture.cpp @@ -81,6 +81,7 @@ void Texture::_bind_methods() { BIND_CONSTANT( FLAGS_DEFAULT ); BIND_CONSTANT( FLAG_ANISOTROPIC_FILTER ); BIND_CONSTANT( FLAG_CONVERT_TO_LINEAR ); + BIND_CONSTANT( FLAG_MIRRORED_REPEAT ); } @@ -181,7 +182,7 @@ void ImageTexture::_get_property_list( List<PropertyInfo> *p_list) const { - p_list->push_back( PropertyInfo( Variant::INT, "flags", PROPERTY_HINT_FLAGS,"Mipmaps,Repeat,Filter,Anisotropic,sRGB") ); + p_list->push_back( PropertyInfo( Variant::INT, "flags", PROPERTY_HINT_FLAGS,"Mipmaps,Repeat,Filter,Anisotropic,sRGB,Mirrored Repeat") ); p_list->push_back( PropertyInfo( Variant::IMAGE, "image", img_hint,String::num(lossy_storage_quality)) ); p_list->push_back( PropertyInfo( Variant::VECTOR2, "size",PROPERTY_HINT_NONE, "")); p_list->push_back( PropertyInfo( Variant::INT, "storage", PROPERTY_HINT_ENUM,"Uncompressed,Compress Lossy,Compress Lossless")); diff --git a/scene/resources/texture.h b/scene/resources/texture.h index 9be8e24a83..ad0e21093d 100644 --- a/scene/resources/texture.h +++ b/scene/resources/texture.h @@ -56,6 +56,7 @@ public: FLAG_CONVERT_TO_LINEAR=VisualServer::TEXTURE_FLAG_CONVERT_TO_LINEAR, FLAG_VIDEO_SURFACE=VisualServer::TEXTURE_FLAG_VIDEO_SURFACE, FLAGS_DEFAULT=FLAG_MIPMAPS|FLAG_REPEAT|FLAG_FILTER, + FLAG_MIRRORED_REPEAT=VisualServer::TEXTURE_FLAG_MIRRORED_REPEAT }; diff --git a/servers/visual_server.h b/servers/visual_server.h index 8108030e0d..dd71650801 100644 --- a/servers/visual_server.h +++ b/servers/visual_server.h @@ -104,6 +104,7 @@ public: TEXTURE_FLAG_FILTER=4, /// Create texure with linear (or available) filter TEXTURE_FLAG_ANISOTROPIC_FILTER=8, TEXTURE_FLAG_CONVERT_TO_LINEAR=16, + TEXTURE_FLAG_MIRRORED_REPEAT=32, /// Repeat texture, with alternate sections mirrored TEXTURE_FLAG_CUBEMAP=2048, TEXTURE_FLAG_VIDEO_SURFACE=4096, TEXTURE_FLAGS_DEFAULT=TEXTURE_FLAG_REPEAT|TEXTURE_FLAG_MIPMAPS|TEXTURE_FLAG_FILTER |