summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/material.cpp4
-rw-r--r--scene/resources/material.h1
-rw-r--r--scene/resources/texture.cpp12
-rw-r--r--scene/resources/texture.h1
4 files changed, 17 insertions, 1 deletions
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 637a816112..2ddfa1078b 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -158,7 +158,7 @@ void Material::_bind_methods() {
for(int i=0;i<HINT_MAX;i++)
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, String()+"hints/"+_hint_names[i] ),_SCS("set_hint"),_SCS("get_hint"),_hint_indices[i]);
- ADD_PROPERTY( PropertyInfo( Variant::INT, "params/blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub" ), _SCS("set_blend_mode"),_SCS("get_blend_mode"));
+ ADD_PROPERTY( PropertyInfo( Variant::INT, "params/blend_mode",PROPERTY_HINT_ENUM,"Mix,Add,Sub,PMAlpha" ), _SCS("set_blend_mode"),_SCS("get_blend_mode"));
ADD_PROPERTY( PropertyInfo( Variant::REAL, "params/line_width",PROPERTY_HINT_RANGE,"0.1,32.0,0.1" ), _SCS("set_line_width"),_SCS("get_line_width"));
@@ -189,6 +189,8 @@ void Material::_bind_methods() {
BIND_CONSTANT( BLEND_MODE_MIX );
BIND_CONSTANT( BLEND_MODE_ADD );
BIND_CONSTANT( BLEND_MODE_SUB );
+ BIND_CONSTANT( BLEND_MODE_MUL );
+ BIND_CONSTANT( BLEND_MODE_PREMULT_ALPHA );
}
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 7bd8b70fa4..1f2afb70b9 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -75,6 +75,7 @@ public:
BLEND_MODE_MUL = VS::MATERIAL_BLEND_MODE_MUL,
BLEND_MODE_ADD = VS::MATERIAL_BLEND_MODE_ADD,
BLEND_MODE_SUB = VS::MATERIAL_BLEND_MODE_SUB,
+ BLEND_MODE_PREMULT_ALPHA = VS::MATERIAL_BLEND_MODE_PREMULT_ALPHA,
};
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index baf6fa9d8d..5402a28d92 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -302,6 +302,16 @@ void ImageTexture::fix_alpha_edges() {
}
}
+void ImageTexture::premultiply_alpha() {
+
+ if (format==Image::FORMAT_RGBA /*&& !(flags&FLAG_CUBEMAP)*/) {
+
+ Image img = get_data();
+ img.premultiply_alpha();
+ set_data(img);
+ }
+}
+
bool ImageTexture::has_alpha() const {
return ( format==Image::FORMAT_GRAYSCALE_ALPHA || format==Image::FORMAT_INDEXED_ALPHA || format==Image::FORMAT_RGBA );
@@ -386,8 +396,10 @@ void ImageTexture::_bind_methods() {
ObjectTypeDB::bind_method(_MD("set_lossy_storage_quality","quality"),&ImageTexture::set_lossy_storage_quality);
ObjectTypeDB::bind_method(_MD("get_lossy_storage_quality"),&ImageTexture::get_lossy_storage_quality);
ObjectTypeDB::bind_method(_MD("fix_alpha_edges"),&ImageTexture::fix_alpha_edges);
+ ObjectTypeDB::bind_method(_MD("premultiply_alpha"),&ImageTexture::premultiply_alpha);
ObjectTypeDB::bind_method(_MD("set_size_override","size"),&ImageTexture::set_size_override);
ObjectTypeDB::set_method_flags(get_type_static(),_SCS("fix_alpha_edges"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
+ ObjectTypeDB::set_method_flags(get_type_static(),_SCS("premultiply_alpha"),METHOD_FLAGS_DEFAULT|METHOD_FLAG_EDITOR);
ObjectTypeDB::bind_method(_MD("_reload_hook","rid"),&ImageTexture::_reload_hook);
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index 6259362882..b780d70e1a 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -143,6 +143,7 @@ public:
float get_lossy_storage_quality() const;
void fix_alpha_edges();
+ void premultiply_alpha();
void set_size_override(const Size2& p_size);