fixed world vertex issues in canvas item shader
This commit is contained in:
parent
14ade5500f
commit
c6eabbbec5
@ -4588,7 +4588,7 @@ void RasterizerGLES2::_update_shader( Shader* p_shader) const {
|
|||||||
enablers.push_back("#define USE_TEXPIXEL_SIZE\n");
|
enablers.push_back("#define USE_TEXPIXEL_SIZE\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (fragment_flags.uses_worldvec) {
|
if (vertex_flags.uses_worldvec) {
|
||||||
enablers.push_back("#define USE_WORLD_VEC\n");
|
enablers.push_back("#define USE_WORLD_VEC\n");
|
||||||
}
|
}
|
||||||
canvas_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, light_code, fragment_globals,uniform_names,enablers);
|
canvas_shader.set_custom_shader_code(p_shader->custom_code_id,vertex_code, vertex_globals,fragment_code, light_code, fragment_globals,uniform_names,enablers);
|
||||||
|
@ -226,6 +226,9 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
|||||||
if (vnode->name==vname_var2_interp) {
|
if (vnode->name==vname_var2_interp) {
|
||||||
flags->use_var2_interp=true;
|
flags->use_var2_interp=true;
|
||||||
}
|
}
|
||||||
|
if (vnode->name==vname_world_vec) {
|
||||||
|
uses_worldvec=true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,9 +242,6 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
|||||||
if (vnode->name==vname_normal) {
|
if (vnode->name==vname_normal) {
|
||||||
uses_normal=true;
|
uses_normal=true;
|
||||||
}
|
}
|
||||||
if (vnode->name==vname_world_vec) {
|
|
||||||
uses_worldvec=true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (vnode->name==vname_screen_uv) {
|
if (vnode->name==vname_screen_uv) {
|
||||||
uses_screen_uv=true;
|
uses_screen_uv=true;
|
||||||
@ -310,13 +310,13 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
|||||||
|
|
||||||
String mul_l=dump_node_code(onode->arguments[0],p_level,true);
|
String mul_l=dump_node_code(onode->arguments[0],p_level,true);
|
||||||
String mul_r=dump_node_code(onode->arguments[1],p_level);
|
String mul_r=dump_node_code(onode->arguments[1],p_level);
|
||||||
code=mul_l+"=(vec4("+mul_l+",1.0,1.0)*("+mul_r+")).xy";
|
code=mul_l+"=(vec4("+mul_l+",0.0,1.0)*("+mul_r+")).xy";
|
||||||
break;
|
break;
|
||||||
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT4 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC2) {
|
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT4 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC2) {
|
||||||
|
|
||||||
String mul_l=dump_node_code(onode->arguments[0],p_level,true);
|
String mul_l=dump_node_code(onode->arguments[0],p_level,true);
|
||||||
String mul_r=dump_node_code(onode->arguments[1],p_level);
|
String mul_r=dump_node_code(onode->arguments[1],p_level);
|
||||||
code=mul_l+"=(("+mul_l+")*vec4("+mul_r+",1.0,1.0)).xy";
|
code=mul_l+"=(("+mul_l+")*vec4("+mul_r+",0.0,1.0)).xy";
|
||||||
break;
|
break;
|
||||||
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_VEC2 && onode->arguments[1]->get_datatype()==SL::TYPE_MAT3) {
|
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_VEC2 && onode->arguments[1]->get_datatype()==SL::TYPE_MAT3) {
|
||||||
String mul_l=dump_node_code(onode->arguments[0],p_level,true);
|
String mul_l=dump_node_code(onode->arguments[0],p_level,true);
|
||||||
@ -346,11 +346,11 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
|
|||||||
break;
|
break;
|
||||||
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT4 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC2) {
|
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT4 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC2) {
|
||||||
|
|
||||||
code="("+dump_node_code(onode->arguments[0],p_level)+"*vec4("+dump_node_code(onode->arguments[1],p_level)+",1.0,1.0)).xyz";
|
code="("+dump_node_code(onode->arguments[0],p_level)+"*vec4("+dump_node_code(onode->arguments[1],p_level)+",0.0,1.0)).xy";
|
||||||
break;
|
break;
|
||||||
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_VEC2 && onode->arguments[1]->get_datatype()==SL::TYPE_MAT4) {
|
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_VEC2 && onode->arguments[1]->get_datatype()==SL::TYPE_MAT4) {
|
||||||
|
|
||||||
code="(vec4("+dump_node_code(onode->arguments[0],p_level)+",1.0,1.0)*"+dump_node_code(onode->arguments[1],p_level)+").xyz";
|
code="(vec4("+dump_node_code(onode->arguments[0],p_level)+",0.0,1.0)*"+dump_node_code(onode->arguments[1],p_level)+").xy";
|
||||||
break;
|
break;
|
||||||
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT3 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC2) {
|
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT3 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC2) {
|
||||||
|
|
||||||
|
@ -396,7 +396,7 @@ void ShaderEditor::edit(const Ref<Shader>& p_shader) {
|
|||||||
light_editor->set_edited_shader(shader,ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT);
|
light_editor->set_edited_shader(shader,ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT);
|
||||||
}
|
}
|
||||||
|
|
||||||
vertex_editor->set_edited_shader(shader,ShaderLanguage::SHADER_MATERIAL_VERTEX);
|
//vertex_editor->set_edited_shader(shader,ShaderLanguage::SHADER_MATERIAL_VERTEX);
|
||||||
// see if already has it
|
// see if already has it
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user