summaryrefslogtreecommitdiff
path: root/scene/resources
diff options
context:
space:
mode:
Diffstat (limited to 'scene/resources')
-rw-r--r--scene/resources/environment.cpp15
-rw-r--r--scene/resources/environment.h10
-rw-r--r--scene/resources/material.cpp9
-rw-r--r--scene/resources/material.h2
-rw-r--r--scene/resources/texture.cpp43
-rw-r--r--scene/resources/texture.h2
6 files changed, 79 insertions, 2 deletions
diff --git a/scene/resources/environment.cpp b/scene/resources/environment.cpp
index 0c55d22dbe..99447c0a0e 100644
--- a/scene/resources/environment.cpp
+++ b/scene/resources/environment.cpp
@@ -109,9 +109,13 @@ void Environment::_bind_methods() {
ADD_PROPERTYI( PropertyInfo(Variant::OBJECT,"background/cubemap",PROPERTY_HINT_RESOURCE_TYPE,"Texture"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_CUBEMAP);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/energy",PROPERTY_HINT_RANGE,"0,128,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_ENERGY);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/scale",PROPERTY_HINT_RANGE,"0.001,16,0.001"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_SCALE);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"background/glow",PROPERTY_HINT_RANGE,"0.00,8,0.01"),_SCS("set_background_param"),_SCS("get_background_param"), BG_PARAM_GLOW);
ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"glow/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_GLOW);
ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_passes",PROPERTY_HINT_RANGE,"1,4,1"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_PASSES);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/blur_scale",PROPERTY_HINT_RANGE,"0.01,4,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_SCALE);
+ ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/blur_strength",PROPERTY_HINT_RANGE,"0.01,4,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_STRENGTH);
+ ADD_PROPERTYI( PropertyInfo(Variant::INT,"glow/blur_blend_mode",PROPERTY_HINT_ENUM,"Additive,Screen,SoftLight"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLUR_BLEND_MODE);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/bloom",PROPERTY_HINT_RANGE,"0,8,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM);
ADD_PROPERTYI( PropertyInfo(Variant::REAL,"glow/bloom_treshold",PROPERTY_HINT_RANGE,"0,1,0.01"),_SCS("fx_set_param"),_SCS("fx_get_param"), FX_PARAM_GLOW_BLOOM_TRESHOLD);
ADD_PROPERTYI( PropertyInfo(Variant::BOOL,"dof_blur/enabled"),_SCS("set_enable_fx"),_SCS("is_fx_enabled"), FX_DOF_BLUR);
@@ -180,6 +184,7 @@ void Environment::_bind_methods() {
BIND_CONSTANT( BG_PARAM_TEXTURE );
BIND_CONSTANT( BG_PARAM_CUBEMAP );
BIND_CONSTANT( BG_PARAM_ENERGY );
+ BIND_CONSTANT( BG_PARAM_GLOW );
BIND_CONSTANT( BG_PARAM_MAX );
@@ -193,7 +198,14 @@ void Environment::_bind_methods() {
BIND_CONSTANT( FX_MAX );
+ BIND_CONSTANT( FX_BLUR_BLEND_MODE_ADDITIVE );
+ BIND_CONSTANT( FX_BLUR_BLEND_MODE_SCREEN );
+ BIND_CONSTANT( FX_BLUR_BLEND_MODE_SOFTLIGHT );
+
BIND_CONSTANT( FX_PARAM_GLOW_BLUR_PASSES );
+ BIND_CONSTANT( FX_PARAM_GLOW_BLUR_SCALE );
+ BIND_CONSTANT( FX_PARAM_GLOW_BLUR_STRENGTH );
+ BIND_CONSTANT( FX_PARAM_GLOW_BLUR_BLEND_MODE );
BIND_CONSTANT( FX_PARAM_GLOW_BLOOM);
BIND_CONSTANT( FX_PARAM_GLOW_BLOOM_TRESHOLD);
BIND_CONSTANT( FX_PARAM_DOF_BLUR_PASSES );
@@ -229,11 +241,14 @@ Environment::Environment() {
set_background_param(BG_PARAM_CUBEMAP,Ref<CubeMap>());
set_background_param(BG_PARAM_ENERGY,1.0);
set_background_param(BG_PARAM_SCALE,1.0);
+ set_background_param(BG_PARAM_GLOW,0.0);
for(int i=0;i<FX_MAX;i++)
set_enable_fx(Fx(i),false);
fx_set_param(FX_PARAM_GLOW_BLUR_PASSES,1);
+ fx_set_param(FX_PARAM_GLOW_BLUR_SCALE,1);
+ fx_set_param(FX_PARAM_GLOW_BLUR_STRENGTH,1);
fx_set_param(FX_PARAM_GLOW_BLOOM,0.0);
fx_set_param(FX_PARAM_GLOW_BLOOM_TRESHOLD,0.5);
fx_set_param(FX_PARAM_DOF_BLUR_PASSES,1);
diff --git a/scene/resources/environment.h b/scene/resources/environment.h
index b90a043634..627fbb7cc0 100644
--- a/scene/resources/environment.h
+++ b/scene/resources/environment.h
@@ -56,6 +56,7 @@ public:
BG_PARAM_CUBEMAP=VS::ENV_BG_PARAM_CUBEMAP,
BG_PARAM_ENERGY=VS::ENV_BG_PARAM_ENERGY,
BG_PARAM_SCALE=VS::ENV_BG_PARAM_SCALE,
+ BG_PARAM_GLOW=VS::ENV_BG_PARAM_GLOW,
BG_PARAM_MAX=VS::ENV_BG_PARAM_MAX
};
@@ -70,8 +71,17 @@ public:
FX_MAX=VS::ENV_FX_MAX,
};
+ enum FxBlurBlendMode {
+ FX_BLUR_BLEND_MODE_ADDITIVE,
+ FX_BLUR_BLEND_MODE_SCREEN,
+ FX_BLUR_BLEND_MODE_SOFTLIGHT,
+ };
+
enum FxParam {
FX_PARAM_GLOW_BLUR_PASSES=VS::ENV_FX_PARAM_GLOW_BLUR_PASSES,
+ FX_PARAM_GLOW_BLUR_SCALE=VS::ENV_FX_PARAM_GLOW_BLUR_SCALE,
+ FX_PARAM_GLOW_BLUR_STRENGTH=VS::ENV_FX_PARAM_GLOW_BLUR_STRENGTH,
+ FX_PARAM_GLOW_BLUR_BLEND_MODE=VS::ENV_FX_PARAM_GLOW_BLUR_BLEND_MODE,
FX_PARAM_GLOW_BLOOM=VS::ENV_FX_PARAM_GLOW_BLOOM,
FX_PARAM_GLOW_BLOOM_TRESHOLD=VS::ENV_FX_PARAM_GLOW_BLOOM_TRESHOLD,
FX_PARAM_DOF_BLUR_PASSES=VS::ENV_FX_PARAM_DOF_BLUR_PASSES,
diff --git a/scene/resources/material.cpp b/scene/resources/material.cpp
index 2ddfa1078b..091a46d4ab 100644
--- a/scene/resources/material.cpp
+++ b/scene/resources/material.cpp
@@ -45,6 +45,7 @@ static const char*_hint_names[Material::HINT_MAX]={
"opaque_pre_zpass",
"no_shadow",
"no_depth_draw",
+ "no_alpha_depth_draw",
};
static const Material::Flag _flag_indices[Material::FLAG_MAX]={
@@ -175,6 +176,7 @@ void Material::_bind_methods() {
BIND_CONSTANT( HINT_OPAQUE_PRE_PASS );
BIND_CONSTANT( HINT_NO_SHADOW );
BIND_CONSTANT( HINT_NO_DEPTH_DRAW );
+ BIND_CONSTANT( HINT_NO_DEPTH_DRAW_FOR_ALPHA );
BIND_CONSTANT( HINT_MAX );
BIND_CONSTANT( SHADE_MODEL_LAMBERT );
@@ -208,6 +210,7 @@ Material::Material(const RID& p_material) {
for(int i=0;i<HINT_MAX;i++)
hints[i]=false;
+ hints[HINT_NO_DEPTH_DRAW_FOR_ALPHA]=true;
blend_mode=BLEND_MODE_MIX;
shade_model = SHADE_MODEL_LAMBERT;
@@ -365,14 +368,14 @@ Material::BlendMode FixedMaterial::get_detail_blend_mode() const {
}
void FixedMaterial::set_fixed_flag(FixedFlag p_flag, bool p_value) {
- ERR_FAIL_INDEX(p_flag,3);
+ ERR_FAIL_INDEX(p_flag,4);
fixed_flags[p_flag]=p_value;
VisualServer::get_singleton()->fixed_material_set_flag(material,(VS::FixedMaterialFlags)p_flag,p_value);
}
bool FixedMaterial::get_fixed_flag(FixedFlag p_flag) const {
- ERR_FAIL_INDEX_V(p_flag,3,false);
+ ERR_FAIL_INDEX_V(p_flag,4,false);
return fixed_flags[p_flag];
}
@@ -419,6 +422,7 @@ void FixedMaterial::_bind_methods() {
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_alpha" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_ALPHA);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_color_array" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_COLOR_ARRAY);
ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/use_point_size" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_USE_POINT_SIZE);
+ ADD_PROPERTYI( PropertyInfo( Variant::BOOL, "fixed_flags/discard_alpha" ), _SCS("set_fixed_flag"), _SCS("get_fixed_flag"), FLAG_DISCARD_ALPHA);
ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/diffuse" ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_DIFFUSE);
ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/specular", PROPERTY_HINT_COLOR_NO_ALPHA ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_SPECULAR );
ADD_PROPERTYI( PropertyInfo( Variant::COLOR, "params/emission", PROPERTY_HINT_COLOR_NO_ALPHA ), _SCS("set_parameter"), _SCS("get_parameter"), PARAM_EMISSION );
@@ -457,6 +461,7 @@ void FixedMaterial::_bind_methods() {
BIND_CONSTANT( FLAG_USE_ALPHA );
BIND_CONSTANT( FLAG_USE_COLOR_ARRAY );
BIND_CONSTANT( FLAG_USE_POINT_SIZE );
+ BIND_CONSTANT( FLAG_DISCARD_ALPHA );
}
diff --git a/scene/resources/material.h b/scene/resources/material.h
index 1f2afb70b9..2057b3cac9 100644
--- a/scene/resources/material.h
+++ b/scene/resources/material.h
@@ -85,6 +85,7 @@ public:
HINT_OPAQUE_PRE_PASS=VS::MATERIAL_HINT_OPAQUE_PRE_PASS,
HINT_NO_SHADOW=VS::MATERIAL_HINT_NO_SHADOW,
HINT_NO_DEPTH_DRAW=VS::MATERIAL_HINT_NO_DEPTH_DRAW,
+ HINT_NO_DEPTH_DRAW_FOR_ALPHA=VS::MATERIAL_HINT_NO_DEPTH_DRAW_FOR_ALPHA,
HINT_MAX=VS::MATERIAL_HINT_MAX
};
@@ -159,6 +160,7 @@ public:
FLAG_USE_ALPHA=VS::FIXED_MATERIAL_FLAG_USE_ALPHA,
FLAG_USE_COLOR_ARRAY=VS::FIXED_MATERIAL_FLAG_USE_COLOR_ARRAY,
FLAG_USE_POINT_SIZE=VS::FIXED_MATERIAL_FLAG_USE_POINT_SIZE,
+ FLAG_DISCARD_ALPHA=VS::FIXED_MATERIAL_FLAG_DISCARD_ALPHA
};
private:
diff --git a/scene/resources/texture.cpp b/scene/resources/texture.cpp
index 5402a28d92..5b31ba1f1b 100644
--- a/scene/resources/texture.cpp
+++ b/scene/resources/texture.cpp
@@ -53,6 +53,13 @@ void Texture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect
VisualServer::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,p_rect,get_rid(),p_src_rect,p_modulate);
}
+bool Texture::get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const {
+
+ r_rect=p_rect;
+ r_src_rect=p_src_rect;
+
+ return true;
+}
void Texture::_bind_methods() {
@@ -609,6 +616,42 @@ void AtlasTexture::draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const
VS::get_singleton()->canvas_item_add_texture_rect_region(p_canvas_item,dr,atlas->get_rid(),src_c,p_modulate);
}
+bool AtlasTexture::get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const {
+
+ Rect2 rc=region;
+
+ if (!atlas.is_valid())
+ return false;
+
+ Rect2 src=p_src_rect;
+ src.pos+=(rc.pos-margin.pos);
+ Rect2 src_c = rc.clip(src);
+ if (src_c.size==Size2())
+ return false;
+ Vector2 ofs = (src_c.pos-src.pos);
+
+ Vector2 scale = p_rect.size / p_src_rect.size;
+ if(scale.x < 0)
+ {
+ float mx = (margin.size.width - margin.pos.x);
+ mx -= margin.pos.x;
+ ofs.x = -(ofs.x + mx);
+ }
+ if(scale.y < 0)
+ {
+ float my = margin.size.height - margin.pos.y;
+ my -= margin.pos.y;
+ ofs.y = -(ofs.y + my);
+ }
+ Rect2 dr( p_rect.pos+ofs*scale,src_c.size*scale );
+
+
+
+ r_rect=dr;
+ r_src_rect=src_c;
+ return true;
+}
+
AtlasTexture::AtlasTexture() {
diff --git a/scene/resources/texture.h b/scene/resources/texture.h
index b780d70e1a..86ff246498 100644
--- a/scene/resources/texture.h
+++ b/scene/resources/texture.h
@@ -70,6 +70,7 @@ public:
virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1)) const;
virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1)) const;
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1)) const;
+ virtual bool get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const;
@@ -191,6 +192,7 @@ public:
virtual void draw(RID p_canvas_item, const Point2& p_pos, const Color& p_modulate=Color(1,1,1)) const;
virtual void draw_rect(RID p_canvas_item,const Rect2& p_rect, bool p_tile=false,const Color& p_modulate=Color(1,1,1)) const;
virtual void draw_rect_region(RID p_canvas_item,const Rect2& p_rect, const Rect2& p_src_rect,const Color& p_modulate=Color(1,1,1)) const;
+ virtual bool get_rect_region(const Rect2& p_rect, const Rect2& p_src_rect,Rect2& r_rect,Rect2& r_src_rect) const;
AtlasTexture();