Merge pull request #2187 from romulox-x/mirroredRepeat
added support for mirrored repeat texture wrapping
This commit is contained in:
commit
71cc2561c6
6 changed files with 30 additions and 7 deletions
|
@ -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 );
|
||||
|
|
|
@ -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")) {
|
||||
|
||||
|
|
|
@ -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();
|
||||
|
|
|
@ -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"));
|
||||
|
|
|
@ -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
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue