-fixed issue with shader not being reset on layers, closes #1199
-ability for shader to use parent shader and params, closes #1198
This commit is contained in:
parent
544ce2a1db
commit
30d3658110
|
@ -4961,7 +4961,7 @@ _FORCE_INLINE_ void RasterizerGLES2::_update_material_shader_params(Material *p_
|
||||||
keep=false;
|
keep=false;
|
||||||
else if (old_mparams[E->key()].value.get_type()!=E->value().default_value.get_type()) {
|
else if (old_mparams[E->key()].value.get_type()!=E->value().default_value.get_type()) {
|
||||||
//type changed between old and new
|
//type changed between old and new
|
||||||
/*if (old_mparams[E->key()].value.get_type()==Variant::OBJECT) {
|
/* if (old_mparams[E->key()].value.get_type()==Variant::OBJECT) {
|
||||||
if (E->value().default_value.get_type()!=Variant::_RID) //hackfor textures
|
if (E->value().default_value.get_type()!=Variant::_RID) //hackfor textures
|
||||||
keep=false;
|
keep=false;
|
||||||
} else if (!old_mparams[E->key()].value.is_num() || !E->value().default_value.get_type())
|
} else if (!old_mparams[E->key()].value.is_num() || !E->value().default_value.get_type())
|
||||||
|
@ -7799,7 +7799,7 @@ void RasterizerGLES2::canvas_begin() {
|
||||||
canvas_shader.bind();
|
canvas_shader.bind();
|
||||||
canvas_shader.set_uniform(CanvasShaderGLES2::TEXTURE, 0);
|
canvas_shader.set_uniform(CanvasShaderGLES2::TEXTURE, 0);
|
||||||
_set_color_attrib(Color(1,1,1));
|
_set_color_attrib(Color(1,1,1));
|
||||||
Transform canvas_transform;
|
canvas_transform=Transform();
|
||||||
canvas_transform.translate(-(viewport.width / 2.0f), -(viewport.height / 2.0f), 0.0f);
|
canvas_transform.translate(-(viewport.width / 2.0f), -(viewport.height / 2.0f), 0.0f);
|
||||||
float csy = 1.0;
|
float csy = 1.0;
|
||||||
if (current_rt && current_rt_vflip)
|
if (current_rt && current_rt_vflip)
|
||||||
|
@ -7813,6 +7813,9 @@ void RasterizerGLES2::canvas_begin() {
|
||||||
canvas_opacity=1.0;
|
canvas_opacity=1.0;
|
||||||
canvas_blend_mode=VS::MATERIAL_BLEND_MODE_MIX;
|
canvas_blend_mode=VS::MATERIAL_BLEND_MODE_MIX;
|
||||||
|
|
||||||
|
canvas_texscreen_used=false;
|
||||||
|
uses_texpixel_size=false;
|
||||||
|
canvas_last_shader=RID();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8294,26 +8297,13 @@ void RasterizerGLES2::canvas_set_transform(const Matrix32& p_transform) {
|
||||||
//canvas_transform = Variant(p_transform);
|
//canvas_transform = Variant(p_transform);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
|
void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
|
||||||
|
|
||||||
|
|
||||||
CanvasItem *current_clip=NULL;
|
CanvasItem *current_clip=NULL;
|
||||||
RID last_shader;
|
|
||||||
|
|
||||||
Transform canvas_transform;
|
|
||||||
canvas_transform.translate(-(viewport.width / 2.0f), -(viewport.height / 2.0f), 0.0f);
|
|
||||||
float csy = 1.0;
|
|
||||||
if (current_rt && current_rt_vflip)
|
|
||||||
csy = -1.0;
|
|
||||||
|
|
||||||
canvas_transform.scale( Vector3( 2.0f / viewport.width, csy * -2.0f / viewport.height, 1.0f ) );
|
|
||||||
canvas_opacity=1.0;
|
canvas_opacity=1.0;
|
||||||
uses_texpixel_size=false;
|
|
||||||
|
|
||||||
|
|
||||||
canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX,canvas_transform);
|
|
||||||
canvas_shader.set_uniform(CanvasShaderGLES2::EXTRA_MATRIX,Matrix32());
|
|
||||||
|
|
||||||
while(p_item_list) {
|
while(p_item_list) {
|
||||||
|
|
||||||
CanvasItem *ci=p_item_list;
|
CanvasItem *ci=p_item_list;
|
||||||
|
@ -8324,7 +8314,7 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
|
||||||
}
|
}
|
||||||
memdelete(ci->vp_render);
|
memdelete(ci->vp_render);
|
||||||
ci->vp_render=NULL;
|
ci->vp_render=NULL;
|
||||||
last_shader=RID();
|
canvas_last_shader=RID();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_clip!=ci->final_clip_owner) {
|
if (current_clip!=ci->final_clip_owner) {
|
||||||
|
@ -8345,12 +8335,13 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
|
||||||
|
|
||||||
|
|
||||||
//begin rect
|
//begin rect
|
||||||
|
CanvasItem *shader_owner = ci->shader_owner?ci->shader_owner:ci;
|
||||||
|
|
||||||
if (ci->shader!=last_shader) {
|
if (shader_owner->shader!=canvas_last_shader) {
|
||||||
|
|
||||||
Shader *shader = NULL;
|
Shader *shader = NULL;
|
||||||
if (ci->shader.is_valid()) {
|
if (shader_owner->shader.is_valid()) {
|
||||||
shader = shader_owner.get(ci->shader);
|
shader = this->shader_owner.get(shader_owner->shader);
|
||||||
if (shader && !shader->valid) {
|
if (shader && !shader->valid) {
|
||||||
shader=NULL;
|
shader=NULL;
|
||||||
}
|
}
|
||||||
|
@ -8361,9 +8352,9 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
|
||||||
if (canvas_shader.bind())
|
if (canvas_shader.bind())
|
||||||
rebind_texpixel_size=true;
|
rebind_texpixel_size=true;
|
||||||
|
|
||||||
if (ci->shader_version!=shader->version) {
|
if (shader_owner->shader_version!=shader->version) {
|
||||||
//todo optimize uniforms
|
//todo optimize uniforms
|
||||||
ci->shader_version=shader->version;
|
shader_owner->shader_version=shader->version;
|
||||||
}
|
}
|
||||||
//this can be optimized..
|
//this can be optimized..
|
||||||
int tex_id=1;
|
int tex_id=1;
|
||||||
|
@ -8371,7 +8362,7 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
|
||||||
for(Map<StringName,ShaderLanguage::Uniform>::Element *E=shader->uniforms.front();E;E=E->next()) {
|
for(Map<StringName,ShaderLanguage::Uniform>::Element *E=shader->uniforms.front();E;E=E->next()) {
|
||||||
|
|
||||||
|
|
||||||
Map<StringName,Variant>::Element *F=ci->shader_param.find(E->key());
|
Map<StringName,Variant>::Element *F=shader_owner->shader_param.find(E->key());
|
||||||
Variant &v=F?F->get():E->get().default_value;
|
Variant &v=F?F->get():E->get().default_value;
|
||||||
if (v.get_type()==Variant::_RID || v.get_type()==Variant::OBJECT) {
|
if (v.get_type()==Variant::_RID || v.get_type()==Variant::OBJECT) {
|
||||||
int loc = canvas_shader.get_custom_uniform_location(idx); //should be automatic..
|
int loc = canvas_shader.get_custom_uniform_location(idx); //should be automatic..
|
||||||
|
@ -8422,7 +8413,7 @@ void RasterizerGLES2::canvas_render_items(CanvasItem *p_item_list) {
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX,canvas_transform);
|
canvas_shader.set_uniform(CanvasShaderGLES2::PROJECTION_MATRIX,canvas_transform);
|
||||||
last_shader=ci->shader;
|
canvas_last_shader=shader_owner->shader;
|
||||||
}
|
}
|
||||||
|
|
||||||
canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,ci->final_transform);
|
canvas_shader.set_uniform(CanvasShaderGLES2::MODELVIEW_MATRIX,ci->final_transform);
|
||||||
|
|
|
@ -1174,6 +1174,11 @@ class RasterizerGLES2 : public Rasterizer {
|
||||||
float canvas_opacity;
|
float canvas_opacity;
|
||||||
bool uses_texpixel_size;
|
bool uses_texpixel_size;
|
||||||
bool rebind_texpixel_size;
|
bool rebind_texpixel_size;
|
||||||
|
Transform canvas_transform;
|
||||||
|
RID canvas_last_shader;
|
||||||
|
bool canvas_texscreen_used;
|
||||||
|
|
||||||
|
|
||||||
_FORCE_INLINE_ Texture* _bind_canvas_texture(const RID& p_texture);
|
_FORCE_INLINE_ Texture* _bind_canvas_texture(const RID& p_texture);
|
||||||
VS::MaterialBlendMode canvas_blend_mode;
|
VS::MaterialBlendMode canvas_blend_mode;
|
||||||
|
|
||||||
|
@ -1542,6 +1547,7 @@ public:
|
||||||
virtual void canvas_draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width);
|
virtual void canvas_draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width);
|
||||||
virtual void canvas_draw_polygon(int p_vertex_count, const int* p_indices, const Vector2* p_vertices, const Vector2* p_uvs, const Color* p_colors,const RID& p_texture,bool p_singlecolor);
|
virtual void canvas_draw_polygon(int p_vertex_count, const int* p_indices, const Vector2* p_vertices, const Vector2* p_uvs, const Color* p_colors,const RID& p_texture,bool p_singlecolor);
|
||||||
virtual void canvas_set_transform(const Matrix32& p_transform);
|
virtual void canvas_set_transform(const Matrix32& p_transform);
|
||||||
|
|
||||||
virtual void canvas_render_items(CanvasItem *p_item_list);
|
virtual void canvas_render_items(CanvasItem *p_item_list);
|
||||||
|
|
||||||
/* ENVIRONMENT */
|
/* ENVIRONMENT */
|
||||||
|
|
|
@ -746,6 +746,17 @@ void CanvasItem::set_shader(const Ref<Shader>& p_shader) {
|
||||||
_change_notify(); //properties for shader exposed
|
_change_notify(); //properties for shader exposed
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CanvasItem::set_use_parent_shader(bool p_use_parent_shader) {
|
||||||
|
|
||||||
|
use_parent_shader=p_use_parent_shader;
|
||||||
|
VS::get_singleton()->canvas_item_set_use_parent_shader(canvas_item,p_use_parent_shader);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool CanvasItem::get_use_parent_shader() const{
|
||||||
|
|
||||||
|
return use_parent_shader;
|
||||||
|
}
|
||||||
|
|
||||||
Ref<Shader> CanvasItem::get_shader() const{
|
Ref<Shader> CanvasItem::get_shader() const{
|
||||||
|
|
||||||
return shader;
|
return shader;
|
||||||
|
@ -868,17 +879,20 @@ void CanvasItem::_bind_methods() {
|
||||||
|
|
||||||
ObjectTypeDB::bind_method(_MD("set_shader","shader"),&CanvasItem::set_shader);
|
ObjectTypeDB::bind_method(_MD("set_shader","shader"),&CanvasItem::set_shader);
|
||||||
ObjectTypeDB::bind_method(_MD("get_shader"),&CanvasItem::get_shader);
|
ObjectTypeDB::bind_method(_MD("get_shader"),&CanvasItem::get_shader);
|
||||||
|
ObjectTypeDB::bind_method(_MD("set_use_parent_shader","enable"),&CanvasItem::set_use_parent_shader);
|
||||||
|
ObjectTypeDB::bind_method(_MD("get_use_parent_shader"),&CanvasItem::get_use_parent_shader);
|
||||||
|
|
||||||
BIND_VMETHOD(MethodInfo("_draw"));
|
BIND_VMETHOD(MethodInfo("_draw"));
|
||||||
|
|
||||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") );
|
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/visible"), _SCS("_set_visible_"),_SCS("_is_visible_") );
|
||||||
ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") );
|
ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_opacity"),_SCS("get_opacity") );
|
||||||
ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") );
|
ADD_PROPERTY( PropertyInfo(Variant::REAL,"visibility/self_opacity",PROPERTY_HINT_RANGE, "0,1,0.01"), _SCS("set_self_opacity"),_SCS("get_self_opacity") );
|
||||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
|
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"visibility/behind_parent"), _SCS("set_draw_behind_parent"),_SCS("is_draw_behind_parent_enabled") );
|
||||||
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility
|
ADD_PROPERTY( PropertyInfo(Variant::BOOL,"visibility/on_top",PROPERTY_HINT_NONE,"",0), _SCS("_set_on_top"),_SCS("_is_on_top") ); //compatibility
|
||||||
|
|
||||||
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,PMAlpha"), _SCS("set_blend_mode"),_SCS("get_blend_mode") );
|
ADD_PROPERTYNZ( PropertyInfo(Variant::INT,"visibility/blend_mode",PROPERTY_HINT_ENUM, "Mix,Add,Sub,Mul,PMAlpha"), _SCS("set_blend_mode"),_SCS("get_blend_mode") );
|
||||||
ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"shader/shader",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemShader,CanvasItemShaderGraph"), _SCS("set_shader"),_SCS("get_shader") );
|
ADD_PROPERTYNZ( PropertyInfo(Variant::OBJECT,"shader/shader",PROPERTY_HINT_RESOURCE_TYPE, "CanvasItemShader,CanvasItemShaderGraph"), _SCS("set_shader"),_SCS("get_shader") );
|
||||||
|
ADD_PROPERTYNZ( PropertyInfo(Variant::BOOL,"shader/use_parent"), _SCS("set_use_parent_shader"),_SCS("get_use_parent_shader") );
|
||||||
//exporting these two things doesn't really make much sense i think
|
//exporting these two things doesn't really make much sense i think
|
||||||
//ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transform/toplevel"), _SCS("set_as_toplevel"),_SCS("is_set_as_toplevel") );
|
//ADD_PROPERTY( PropertyInfo(Variant::BOOL,"transform/toplevel"), _SCS("set_as_toplevel"),_SCS("is_set_as_toplevel") );
|
||||||
//ADD_PROPERTY(PropertyInfo(Variant::BOOL,"transform/notify"),_SCS("set_transform_notify"),_SCS("is_transform_notify_enabled"));
|
//ADD_PROPERTY(PropertyInfo(Variant::BOOL,"transform/notify"),_SCS("set_transform_notify"),_SCS("is_transform_notify_enabled"));
|
||||||
|
@ -955,6 +969,7 @@ CanvasItem::CanvasItem() : xform_change(this) {
|
||||||
block_transform_notify=false;
|
block_transform_notify=false;
|
||||||
// viewport=NULL;
|
// viewport=NULL;
|
||||||
canvas_layer=NULL;
|
canvas_layer=NULL;
|
||||||
|
use_parent_shader;
|
||||||
global_invalid=true;
|
global_invalid=true;
|
||||||
|
|
||||||
C=NULL;
|
C=NULL;
|
||||||
|
|
|
@ -81,6 +81,7 @@ private:
|
||||||
bool block_transform_notify;
|
bool block_transform_notify;
|
||||||
bool behind;
|
bool behind;
|
||||||
|
|
||||||
|
bool use_parent_shader;
|
||||||
Ref<Shader> shader;
|
Ref<Shader> shader;
|
||||||
|
|
||||||
mutable Matrix32 global_transform;
|
mutable Matrix32 global_transform;
|
||||||
|
@ -214,6 +215,9 @@ public:
|
||||||
void set_shader(const Ref<Shader>& p_shader);
|
void set_shader(const Ref<Shader>& p_shader);
|
||||||
Ref<Shader> get_shader() const;
|
Ref<Shader> get_shader() const;
|
||||||
|
|
||||||
|
void set_use_parent_shader(bool p_use_parent_shader);
|
||||||
|
bool get_use_parent_shader() const;
|
||||||
|
|
||||||
void set_shader_param(const StringName& p_param,const Variant& p_value);
|
void set_shader_param(const StringName& p_param,const Variant& p_value);
|
||||||
Variant get_shader_param(const StringName& p_param) const;
|
Variant get_shader_param(const StringName& p_param) const;
|
||||||
|
|
||||||
|
|
|
@ -703,6 +703,7 @@ public:
|
||||||
Matrix32 final_transform;
|
Matrix32 final_transform;
|
||||||
Rect2 final_clip_rect;
|
Rect2 final_clip_rect;
|
||||||
CanvasItem* final_clip_owner;
|
CanvasItem* final_clip_owner;
|
||||||
|
CanvasItem* shader_owner;
|
||||||
ViewportRender *vp_render;
|
ViewportRender *vp_render;
|
||||||
|
|
||||||
const Rect2& get_rect() const {
|
const Rect2& get_rect() const {
|
||||||
|
@ -829,8 +830,8 @@ public:
|
||||||
return rect;
|
return rect;
|
||||||
}
|
}
|
||||||
|
|
||||||
void clear() { for (int i=0;i<commands.size();i++) memdelete( commands[i] ); commands.clear(); clip=false; rect_dirty=true; final_clip_owner=NULL; }
|
void clear() { for (int i=0;i<commands.size();i++) memdelete( commands[i] ); commands.clear(); clip=false; rect_dirty=true; final_clip_owner=NULL; shader_owner=NULL;}
|
||||||
CanvasItem() { vp_render=NULL; next=NULL; final_clip_owner=NULL; clip=false; final_opacity=1; blend_mode=VS::MATERIAL_BLEND_MODE_MIX; visible=true; rect_dirty=true; custom_rect=false; ontop=true; shader_version=0;}
|
CanvasItem() { vp_render=NULL; next=NULL; final_clip_owner=NULL; clip=false; final_opacity=1; blend_mode=VS::MATERIAL_BLEND_MODE_MIX; visible=true; rect_dirty=true; custom_rect=false; ontop=true; shader_version=0; shader_owner=NULL;}
|
||||||
virtual ~CanvasItem() { clear(); }
|
virtual ~CanvasItem() { clear(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -851,6 +852,7 @@ public:
|
||||||
virtual void canvas_draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width)=0;
|
virtual void canvas_draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width)=0;
|
||||||
virtual void canvas_draw_polygon(int p_vertex_count, const int* p_indices, const Vector2* p_vertices, const Vector2* p_uvs, const Color* p_colors,const RID& p_texture,bool p_singlecolor)=0;
|
virtual void canvas_draw_polygon(int p_vertex_count, const int* p_indices, const Vector2* p_vertices, const Vector2* p_uvs, const Color* p_colors,const RID& p_texture,bool p_singlecolor)=0;
|
||||||
virtual void canvas_set_transform(const Matrix32& p_transform)=0;
|
virtual void canvas_set_transform(const Matrix32& p_transform)=0;
|
||||||
|
|
||||||
virtual void canvas_render_items(CanvasItem *p_item_list)=0;
|
virtual void canvas_render_items(CanvasItem *p_item_list)=0;
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -709,6 +709,7 @@ public:
|
||||||
virtual void canvas_draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width);
|
virtual void canvas_draw_primitive(const Vector<Point2>& p_points, const Vector<Color>& p_colors,const Vector<Point2>& p_uvs, RID p_texture,float p_width);
|
||||||
virtual void canvas_draw_polygon(int p_vertex_count, const int* p_indices, const Vector2* p_vertices, const Vector2* p_uvs, const Color* p_colors,const RID& p_texture,bool p_singlecolor);
|
virtual void canvas_draw_polygon(int p_vertex_count, const int* p_indices, const Vector2* p_vertices, const Vector2* p_uvs, const Color* p_colors,const RID& p_texture,bool p_singlecolor);
|
||||||
virtual void canvas_set_transform(const Matrix32& p_transform);
|
virtual void canvas_set_transform(const Matrix32& p_transform);
|
||||||
|
|
||||||
virtual void canvas_render_items(CanvasItem *p_item_list);
|
virtual void canvas_render_items(CanvasItem *p_item_list);
|
||||||
|
|
||||||
/* ENVIRONMENT */
|
/* ENVIRONMENT */
|
||||||
|
|
|
@ -1120,8 +1120,7 @@ const ShaderLanguage::BuiltinsDef ShaderLanguage::ci_vertex_builtins_defs[]={
|
||||||
//builtins
|
//builtins
|
||||||
{ "WORLD_MATRIX", TYPE_MAT4},
|
{ "WORLD_MATRIX", TYPE_MAT4},
|
||||||
{ "PROJECTION_MATRIX", TYPE_MAT4},
|
{ "PROJECTION_MATRIX", TYPE_MAT4},
|
||||||
{ "EXTRA_MATRIX", TYPE_MAT4},
|
{ "EXTRA_MATRIX", TYPE_MAT4},
|
||||||
{ "MODELVIEW_MATRIX", TYPE_MAT4},
|
|
||||||
{ "TIME", TYPE_FLOAT},
|
{ "TIME", TYPE_FLOAT},
|
||||||
{ NULL, TYPE_VOID},
|
{ NULL, TYPE_VOID},
|
||||||
};
|
};
|
||||||
|
|
|
@ -3699,6 +3699,15 @@ void VisualServerRaster::canvas_item_set_z(RID p_item, int p_z) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void VisualServerRaster::canvas_item_set_use_parent_shader(RID p_item, bool p_enable) {
|
||||||
|
|
||||||
|
VS_CHANGED;
|
||||||
|
CanvasItem *canvas_item = canvas_item_owner.get( p_item );
|
||||||
|
ERR_FAIL_COND(!canvas_item);
|
||||||
|
canvas_item->use_parent_shader=p_enable;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
void VisualServerRaster::canvas_item_set_shader(RID p_item, RID p_shader) {
|
void VisualServerRaster::canvas_item_set_shader(RID p_item, RID p_shader) {
|
||||||
|
|
||||||
VS_CHANGED;
|
VS_CHANGED;
|
||||||
|
@ -6139,7 +6148,7 @@ void VisualServerRaster::_render_canvas_item_tree(CanvasItem *p_canvas_item,cons
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
_render_canvas_item(p_canvas_item,p_transform,p_clip_rect,1.0,z_list,z_last_list,NULL);
|
_render_canvas_item(p_canvas_item,p_transform,p_clip_rect,1.0,z_list,z_last_list,NULL,NULL);
|
||||||
|
|
||||||
for(int i=0;i<CANVAS_ITEM_Z_MAX;i++) {
|
for(int i=0;i<CANVAS_ITEM_Z_MAX;i++) {
|
||||||
if (!z_list[i])
|
if (!z_list[i])
|
||||||
|
@ -6156,9 +6165,10 @@ void VisualServerRaster::_render_canvas_item_viewport(VisualServer* p_self,void
|
||||||
Viewport *vp=(Viewport*)p_vp;
|
Viewport *vp=(Viewport*)p_vp;
|
||||||
self->_draw_viewport(vp,p_rect.pos.x,p_rect.pos.y,p_rect.size.x,p_rect.size.y);
|
self->_draw_viewport(vp,p_rect.pos.x,p_rect.pos.y,p_rect.size.x,p_rect.size.y);
|
||||||
self->rasterizer->canvas_begin();
|
self->rasterizer->canvas_begin();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void VisualServerRaster::_render_canvas_item(CanvasItem *p_canvas_item,const Matrix32& p_transform,const Rect2& p_clip_rect, float p_opacity,Rasterizer::CanvasItem **z_list,Rasterizer::CanvasItem **z_last_list,CanvasItem *p_canvas_clip) {
|
void VisualServerRaster::_render_canvas_item(CanvasItem *p_canvas_item,const Matrix32& p_transform,const Rect2& p_clip_rect, float p_opacity,Rasterizer::CanvasItem **z_list,Rasterizer::CanvasItem **z_last_list,CanvasItem *p_canvas_clip,CanvasItem *p_shader_owner) {
|
||||||
|
|
||||||
CanvasItem *ci = p_canvas_item;
|
CanvasItem *ci = p_canvas_item;
|
||||||
|
|
||||||
|
@ -6203,6 +6213,12 @@ void VisualServerRaster::_render_canvas_item(CanvasItem *p_canvas_item,const Mat
|
||||||
ci->vp_render=NULL;
|
ci->vp_render=NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (ci->use_parent_shader && p_shader_owner)
|
||||||
|
ci->shader_owner=p_shader_owner;
|
||||||
|
else {
|
||||||
|
p_shader_owner=ci;
|
||||||
|
ci->shader_owner=NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
float opacity = ci->opacity * p_opacity;
|
float opacity = ci->opacity * p_opacity;
|
||||||
|
@ -6231,7 +6247,7 @@ void VisualServerRaster::_render_canvas_item(CanvasItem *p_canvas_item,const Mat
|
||||||
|
|
||||||
if (child_items[i]->ontop)
|
if (child_items[i]->ontop)
|
||||||
continue;
|
continue;
|
||||||
_render_canvas_item(child_items[i],xform,p_clip_rect,opacity,z_list,z_last_list,(CanvasItem*)ci->final_clip_owner);
|
_render_canvas_item(child_items[i],xform,p_clip_rect,opacity,z_list,z_last_list,(CanvasItem*)ci->final_clip_owner,p_shader_owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -6257,7 +6273,7 @@ void VisualServerRaster::_render_canvas_item(CanvasItem *p_canvas_item,const Mat
|
||||||
|
|
||||||
if (!child_items[i]->ontop)
|
if (!child_items[i]->ontop)
|
||||||
continue;
|
continue;
|
||||||
_render_canvas_item(child_items[i],xform,p_clip_rect,opacity,z_list,z_last_list,(CanvasItem*)ci->final_clip_owner);
|
_render_canvas_item(child_items[i],xform,p_clip_rect,opacity,z_list,z_last_list,(CanvasItem*)ci->final_clip_owner,p_shader_owner);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -6266,6 +6282,7 @@ void VisualServerRaster::_render_canvas(Canvas *p_canvas,const Matrix32 &p_trans
|
||||||
|
|
||||||
rasterizer->canvas_begin();
|
rasterizer->canvas_begin();
|
||||||
|
|
||||||
|
|
||||||
int l = p_canvas->child_items.size();
|
int l = p_canvas->child_items.size();
|
||||||
|
|
||||||
for(int i=0;i<l;i++) {
|
for(int i=0;i<l;i++) {
|
||||||
|
@ -6452,7 +6469,7 @@ void VisualServerRaster::_draw_viewports() {
|
||||||
rasterizer->set_viewport(viewport_rect);
|
rasterizer->set_viewport(viewport_rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
rasterizer->canvas_begin();
|
rasterizer->canvas_begin();
|
||||||
rasterizer->canvas_disable_blending();
|
rasterizer->canvas_disable_blending();
|
||||||
rasterizer->canvas_begin_rect(Matrix32());
|
rasterizer->canvas_begin_rect(Matrix32());
|
||||||
rasterizer->canvas_draw_rect(E->get()->rt_to_screen_rect,0,Rect2(Point2(),E->get()->rt_to_screen_rect.size),E->get()->render_target_texture,Color(1,1,1));
|
rasterizer->canvas_draw_rect(E->get()->rt_to_screen_rect,0,Rect2(Point2(),E->get()->rt_to_screen_rect.size),E->get()->render_target_texture,Color(1,1,1));
|
||||||
|
|
|
@ -85,6 +85,7 @@ class VisualServerRaster : public VisualServer {
|
||||||
Vector<Point2> shape;
|
Vector<Point2> shape;
|
||||||
Rect2 bounds;
|
Rect2 bounds;
|
||||||
|
|
||||||
|
|
||||||
Portal() { enabled=true; disable_distance=50; disable_color=Color(); connect_range=0.8; }
|
Portal() { enabled=true; disable_distance=50; disable_color=Color(); connect_range=0.8; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -382,6 +383,7 @@ class VisualServerRaster : public VisualServer {
|
||||||
bool sort_y;
|
bool sort_y;
|
||||||
float opacity;
|
float opacity;
|
||||||
float self_opacity;
|
float self_opacity;
|
||||||
|
bool use_parent_shader;
|
||||||
|
|
||||||
|
|
||||||
Vector<CanvasItem*> child_items;
|
Vector<CanvasItem*> child_items;
|
||||||
|
@ -393,6 +395,7 @@ class VisualServerRaster : public VisualServer {
|
||||||
opacity=1;
|
opacity=1;
|
||||||
self_opacity=1;
|
self_opacity=1;
|
||||||
sort_y=false;
|
sort_y=false;
|
||||||
|
use_parent_shader=false;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -597,7 +600,7 @@ class VisualServerRaster : public VisualServer {
|
||||||
void _render_camera(Viewport *p_viewport,Camera *p_camera, Scenario *p_scenario);
|
void _render_camera(Viewport *p_viewport,Camera *p_camera, Scenario *p_scenario);
|
||||||
static void _render_canvas_item_viewport(VisualServer* p_self,void *p_vp,const Rect2& p_rect);
|
static void _render_canvas_item_viewport(VisualServer* p_self,void *p_vp,const Rect2& p_rect);
|
||||||
void _render_canvas_item_tree(CanvasItem *p_canvas_item,const Matrix32& p_transform,const Rect2& p_clip_rect);
|
void _render_canvas_item_tree(CanvasItem *p_canvas_item,const Matrix32& p_transform,const Rect2& p_clip_rect);
|
||||||
void _render_canvas_item(CanvasItem *p_canvas_item,const Matrix32& p_transform,const Rect2& p_clip_rect,float p_opacity,Rasterizer::CanvasItem **z_list,Rasterizer::CanvasItem **z_last_list,CanvasItem *p_canvas_clip);
|
void _render_canvas_item(CanvasItem *p_canvas_item,const Matrix32& p_transform,const Rect2& p_clip_rect,float p_opacity,Rasterizer::CanvasItem **z_list,Rasterizer::CanvasItem **z_last_list,CanvasItem *p_canvas_clip,CanvasItem *p_shader_owner);
|
||||||
void _render_canvas(Canvas *p_canvas,const Matrix32 &p_transform);
|
void _render_canvas(Canvas *p_canvas,const Matrix32 &p_transform);
|
||||||
Vector<Vector3> _camera_generate_endpoints(Instance *p_light,Camera *p_camera,float p_range_min, float p_range_max);
|
Vector<Vector3> _camera_generate_endpoints(Instance *p_light,Camera *p_camera,float p_range_min, float p_range_max);
|
||||||
Vector<Plane> _camera_generate_orthogonal_planes(Instance *p_light,Camera *p_camera,float p_range_min, float p_range_max);
|
Vector<Plane> _camera_generate_orthogonal_planes(Instance *p_light,Camera *p_camera,float p_range_min, float p_range_max);
|
||||||
|
@ -1113,6 +1116,9 @@ public:
|
||||||
virtual void canvas_item_set_shader(RID p_item, RID p_shader);
|
virtual void canvas_item_set_shader(RID p_item, RID p_shader);
|
||||||
virtual RID canvas_item_get_shader(RID p_item) const;
|
virtual RID canvas_item_get_shader(RID p_item) const;
|
||||||
|
|
||||||
|
virtual void canvas_item_set_use_parent_shader(RID p_item, bool p_enable);
|
||||||
|
|
||||||
|
|
||||||
virtual void canvas_item_set_shader_param(RID p_canvas_item, const StringName& p_param, const Variant& p_value);
|
virtual void canvas_item_set_shader_param(RID p_canvas_item, const StringName& p_param, const Variant& p_value);
|
||||||
virtual Variant canvas_item_get_shader_param(RID p_canvas_item, const StringName& p_param) const;
|
virtual Variant canvas_item_get_shader_param(RID p_canvas_item, const StringName& p_param) const;
|
||||||
|
|
||||||
|
|
|
@ -1136,6 +1136,9 @@ public:
|
||||||
FUNC2(canvas_item_set_shader,RID, RID );
|
FUNC2(canvas_item_set_shader,RID, RID );
|
||||||
FUNC1RC(RID,canvas_item_get_shader,RID );
|
FUNC1RC(RID,canvas_item_get_shader,RID );
|
||||||
|
|
||||||
|
FUNC2(canvas_item_set_use_parent_shader,RID, bool );
|
||||||
|
|
||||||
|
|
||||||
FUNC3(canvas_item_set_shader_param,RID,const StringName&,const Variant&);
|
FUNC3(canvas_item_set_shader_param,RID,const StringName&,const Variant&);
|
||||||
FUNC2RC(Variant,canvas_item_get_shader_param,RID,const StringName&);
|
FUNC2RC(Variant,canvas_item_get_shader_param,RID,const StringName&);
|
||||||
|
|
||||||
|
|
|
@ -992,6 +992,8 @@ public:
|
||||||
virtual void canvas_item_set_shader(RID p_item, RID p_shader)=0;
|
virtual void canvas_item_set_shader(RID p_item, RID p_shader)=0;
|
||||||
virtual RID canvas_item_get_shader(RID p_item) const=0;
|
virtual RID canvas_item_get_shader(RID p_item) const=0;
|
||||||
|
|
||||||
|
virtual void canvas_item_set_use_parent_shader(RID p_item, bool p_enable)=0;
|
||||||
|
|
||||||
virtual void canvas_item_set_shader_param(RID p_canvas_item, const StringName& p_param, const Variant& p_value)=0;
|
virtual void canvas_item_set_shader_param(RID p_canvas_item, const StringName& p_param, const Variant& p_value)=0;
|
||||||
virtual Variant canvas_item_get_shader_param(RID p_canvas_item, const StringName& p_param) const=0;
|
virtual Variant canvas_item_get_shader_param(RID p_canvas_item, const StringName& p_param) const=0;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue