diff options
Diffstat (limited to 'drivers/gles2/shader_compiler_gles2.cpp')
-rw-r--r-- | drivers/gles2/shader_compiler_gles2.cpp | 1032 |
1 files changed, 511 insertions, 521 deletions
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp index a5aa570e33..25decb37a2 100644 --- a/drivers/gles2/shader_compiler_gles2.cpp +++ b/drivers/gles2/shader_compiler_gles2.cpp @@ -38,14 +38,13 @@ typedef ShaderLanguage SL; struct CodeGLSL2 { String code; - }; static String _mktab(int p_level) { String tb; - for(int i=0;i<p_level;i++) { - tb+="\t"; + for (int i = 0; i < p_level; i++) { + tb += "\t"; } return tb; @@ -53,7 +52,7 @@ static String _mktab(int p_level) { static String _typestr(SL::DataType p_type) { - switch(p_type) { + switch (p_type) { case SL::TYPE_VOID: return "void"; case SL::TYPE_BOOL: return "bool"; @@ -77,7 +76,7 @@ static String _mknum(float p_num) { static String _opstr(SL::Operator p_op) { - switch(p_op) { + switch (p_op) { case SL::OP_ASSIGN: return "="; case SL::OP_ADD: return "+"; case SL::OP_SUB: return "-"; @@ -103,7 +102,6 @@ static String _opstr(SL::Operator p_op) { return ""; } - //#ifdef DEBUG_SHADER_ENABLED #if 1 #define ENDL "\n" @@ -111,275 +109,278 @@ static String _opstr(SL::Operator p_op) { #define ENDL "" #endif - - -String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_assign_left) { +String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node, int p_level, bool p_assign_left) { String code; - switch(p_node->type) { + switch (p_node->type) { case SL::Node::TYPE_PROGRAM: { - SL::ProgramNode *pnode=(SL::ProgramNode*)p_node; + SL::ProgramNode *pnode = (SL::ProgramNode *)p_node; - code+=dump_node_code(pnode->body,p_level); + code += dump_node_code(pnode->body, p_level); } break; case SL::Node::TYPE_FUNCTION: { } break; case SL::Node::TYPE_BLOCK: { - SL::BlockNode *bnode=(SL::BlockNode*)p_node; + SL::BlockNode *bnode = (SL::BlockNode *)p_node; //variables - code+="{" ENDL; - for(Map<StringName,SL::DataType>::Element *E=bnode->variables.front();E;E=E->next()) { + code += "{" ENDL; + for (Map<StringName, SL::DataType>::Element *E = bnode->variables.front(); E; E = E->next()) { - code+=_mktab(p_level)+_typestr(E->value())+" "+replace_string(E->key())+";" ENDL; + code += _mktab(p_level) + _typestr(E->value()) + " " + replace_string(E->key()) + ";" ENDL; } - for(int i=0;i<bnode->statements.size();i++) { + for (int i = 0; i < bnode->statements.size(); i++) { - code+=_mktab(p_level)+dump_node_code(bnode->statements[i],p_level)+";" ENDL; + code += _mktab(p_level) + dump_node_code(bnode->statements[i], p_level) + ";" ENDL; } - code+="}" ENDL; + code += "}" ENDL; } break; case SL::Node::TYPE_VARIABLE: { - SL::VariableNode *vnode=(SL::VariableNode*)p_node; + SL::VariableNode *vnode = (SL::VariableNode *)p_node; - if (type==ShaderLanguage::SHADER_MATERIAL_VERTEX) { + if (type == ShaderLanguage::SHADER_MATERIAL_VERTEX) { - if (vnode->name==vname_vertex && p_assign_left) { - vertex_code_writes_vertex=true; + if (vnode->name == vname_vertex && p_assign_left) { + vertex_code_writes_vertex = true; } if (vnode->name == vname_position && p_assign_left) { vertex_code_writes_position = true; } - if (vnode->name==vname_color_interp) { - flags->use_color_interp=true; + if (vnode->name == vname_color_interp) { + flags->use_color_interp = true; } - if (vnode->name==vname_uv_interp) { - flags->use_uv_interp=true; + if (vnode->name == vname_uv_interp) { + flags->use_uv_interp = true; } - if (vnode->name==vname_uv2_interp) { - flags->use_uv2_interp=true; + if (vnode->name == vname_uv2_interp) { + flags->use_uv2_interp = true; } - if (vnode->name==vname_var1_interp) { - flags->use_var1_interp=true; + if (vnode->name == vname_var1_interp) { + flags->use_var1_interp = true; } - if (vnode->name==vname_var2_interp) { - flags->use_var2_interp=true; + if (vnode->name == vname_var2_interp) { + flags->use_var2_interp = true; } - if (vnode->name==vname_tangent_interp || vnode->name==vname_binormal_interp) { - flags->use_tangent_interp=true; + if (vnode->name == vname_tangent_interp || vnode->name == vname_binormal_interp) { + flags->use_tangent_interp = true; } - - } + if (type == ShaderLanguage::SHADER_MATERIAL_FRAGMENT) { - - if (type==ShaderLanguage::SHADER_MATERIAL_FRAGMENT) { - - if (vnode->name==vname_discard) { - uses_discard=true; + if (vnode->name == vname_discard) { + uses_discard = true; } - if (vnode->name==vname_normalmap) { - uses_normalmap=true; + if (vnode->name == vname_normalmap) { + uses_normalmap = true; } - if (vnode->name==vname_screen_uv) { - uses_screen_uv=true; + if (vnode->name == vname_screen_uv) { + uses_screen_uv = true; } - if (vnode->name==vname_diffuse_alpha && p_assign_left) { - uses_alpha=true; + if (vnode->name == vname_diffuse_alpha && p_assign_left) { + uses_alpha = true; } - if (vnode->name==vname_color_interp) { - flags->use_color_interp=true; + if (vnode->name == vname_color_interp) { + flags->use_color_interp = true; } - if (vnode->name==vname_uv_interp) { - flags->use_uv_interp=true; + if (vnode->name == vname_uv_interp) { + flags->use_uv_interp = true; } - if (vnode->name==vname_uv2_interp) { - flags->use_uv2_interp=true; + if (vnode->name == vname_uv2_interp) { + flags->use_uv2_interp = true; } - if (vnode->name==vname_var1_interp) { - flags->use_var1_interp=true; + if (vnode->name == vname_var1_interp) { + flags->use_var1_interp = true; } - if (vnode->name==vname_var2_interp) { - flags->use_var2_interp=true; + if (vnode->name == vname_var2_interp) { + flags->use_var2_interp = true; } - if (vnode->name==vname_tangent_interp || vnode->name==vname_binormal_interp) { - flags->use_tangent_interp=true; + if (vnode->name == vname_tangent_interp || vnode->name == vname_binormal_interp) { + flags->use_tangent_interp = true; } - } - if (type==ShaderLanguage::SHADER_MATERIAL_LIGHT) { + if (type == ShaderLanguage::SHADER_MATERIAL_LIGHT) { - if (vnode->name==vname_light) { - uses_light=true; + if (vnode->name == vname_light) { + uses_light = true; } - if (vnode->name==vname_shadow) { - uses_shadow_color=true; + if (vnode->name == vname_shadow) { + uses_shadow_color = true; } - } - if (type==ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX) { + if (type == ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX) { - if (vnode->name==vname_var1_interp) { - flags->use_var1_interp=true; + if (vnode->name == vname_var1_interp) { + flags->use_var1_interp = true; } - if (vnode->name==vname_var2_interp) { - flags->use_var2_interp=true; + if (vnode->name == vname_var2_interp) { + flags->use_var2_interp = true; } - if (vnode->name==vname_world_vec) { - uses_worldvec=true; + if (vnode->name == vname_world_vec) { + uses_worldvec = true; } - } + if (type == ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT) { - if (type==ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT) { - - - if (vnode->name==vname_texpixel_size) { - uses_texpixel_size=true; + if (vnode->name == vname_texpixel_size) { + uses_texpixel_size = true; } - if (vnode->name==vname_normal) { - uses_normal=true; + if (vnode->name == vname_normal) { + uses_normal = true; } - if (vnode->name==vname_normalmap || vnode->name==vname_normalmap_depth) { - uses_normalmap=true; - uses_normal=true; + if (vnode->name == vname_normalmap || vnode->name == vname_normalmap_depth) { + uses_normalmap = true; + uses_normal = true; } - if (vnode->name==vname_screen_uv) { - uses_screen_uv=true; + if (vnode->name == vname_screen_uv) { + uses_screen_uv = true; } - if (vnode->name==vname_var1_interp) { - flags->use_var1_interp=true; + if (vnode->name == vname_var1_interp) { + flags->use_var1_interp = true; } - if (vnode->name==vname_var2_interp) { - flags->use_var2_interp=true; + if (vnode->name == vname_var2_interp) { + flags->use_var2_interp = true; } } - if (type==ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT) { + if (type == ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT) { - if (vnode->name==vname_light) { - uses_light=true; + if (vnode->name == vname_light) { + uses_light = true; } - if (vnode->name==vname_normal) { - uses_normal=true; + if (vnode->name == vname_normal) { + uses_normal = true; } - if (vnode->name==vname_shadow) { - uses_shadow_color=true; + if (vnode->name == vname_shadow) { + uses_shadow_color = true; } - } - if (vnode->name==vname_time) { - uses_time=true; + if (vnode->name == vname_time) { + uses_time = true; } - code=replace_string(vnode->name); + code = replace_string(vnode->name); } break; case SL::Node::TYPE_CONSTANT: { - SL::ConstantNode *cnode=(SL::ConstantNode*)p_node; - switch(cnode->datatype) { - - - case SL::TYPE_BOOL: code=cnode->value.operator bool()?"true":"false"; break; - case SL::TYPE_FLOAT: code=_mknum(cnode->value); break; //force zeros, so GLSL doesn't confuse with integer. - case SL::TYPE_VEC2: { Vector2 v = cnode->value; code="vec2("+_mknum(v.x)+", "+_mknum(v.y)+")"; } break; - case SL::TYPE_VEC3: { Vector3 v = cnode->value; code="vec3("+_mknum(v.x)+", "+_mknum(v.y)+", "+_mknum(v.z)+")"; } break; - case SL::TYPE_VEC4: { Plane v = cnode->value; code="vec4("+_mknum(v.normal.x)+", "+_mknum(v.normal.y)+", "+_mknum(v.normal.z)+", "+_mknum(v.d)+")"; } break; - case SL::TYPE_MAT2: { Transform2D x = cnode->value; code="mat2( vec2("+_mknum(x[0][0])+", "+_mknum(x[0][1])+"), vec2("+_mknum(x[1][0])+", "+_mknum(x[1][1])+"))"; } break; - case SL::TYPE_MAT3: { Basis x = cnode->value; code="mat3( vec3("+_mknum(x.get_axis(0).x)+", "+_mknum(x.get_axis(0).y)+", "+_mknum(x.get_axis(0).z)+"), vec3("+_mknum(x.get_axis(1).x)+", "+_mknum(x.get_axis(1).y)+", "+_mknum(x.get_axis(1).z)+"), vec3("+_mknum(x.get_axis(2).x)+", "+_mknum(x.get_axis(2).y)+", "+_mknum(x.get_axis(2).z)+"))"; } break; - case SL::TYPE_MAT4: { Transform x = cnode->value; code="mat4( vec4("+_mknum(x.basis.get_axis(0).x)+", "+_mknum(x.basis.get_axis(0).y)+", "+_mknum(x.basis.get_axis(0).z)+",0.0), vec4("+_mknum(x.basis.get_axis(1).x)+", "+_mknum(x.basis.get_axis(1).y)+", "+_mknum(x.basis.get_axis(1).z)+",0.0), vec4("+_mknum(x.basis.get_axis(2).x)+", "+_mknum(x.basis.get_axis(2).y)+", "+_mknum(x.basis.get_axis(2).z)+",0.0), vec4("+_mknum(x.origin.x)+", "+_mknum(x.origin.y)+", "+_mknum(x.origin.z)+",1.0))"; } break; - default: code="<error: "+Variant::get_type_name(cnode->value.get_type())+" ("+itos(cnode->datatype)+">"; + SL::ConstantNode *cnode = (SL::ConstantNode *)p_node; + switch (cnode->datatype) { + + case SL::TYPE_BOOL: code = cnode->value.operator bool() ? "true" : "false"; break; + case SL::TYPE_FLOAT: + code = _mknum(cnode->value); + break; //force zeros, so GLSL doesn't confuse with integer. + case SL::TYPE_VEC2: { + Vector2 v = cnode->value; + code = "vec2(" + _mknum(v.x) + ", " + _mknum(v.y) + ")"; + } break; + case SL::TYPE_VEC3: { + Vector3 v = cnode->value; + code = "vec3(" + _mknum(v.x) + ", " + _mknum(v.y) + ", " + _mknum(v.z) + ")"; + } break; + case SL::TYPE_VEC4: { + Plane v = cnode->value; + code = "vec4(" + _mknum(v.normal.x) + ", " + _mknum(v.normal.y) + ", " + _mknum(v.normal.z) + ", " + _mknum(v.d) + ")"; + } break; + case SL::TYPE_MAT2: { + Transform2D x = cnode->value; + code = "mat2( vec2(" + _mknum(x[0][0]) + ", " + _mknum(x[0][1]) + "), vec2(" + _mknum(x[1][0]) + ", " + _mknum(x[1][1]) + "))"; + } break; + case SL::TYPE_MAT3: { + Basis x = cnode->value; + code = "mat3( vec3(" + _mknum(x.get_axis(0).x) + ", " + _mknum(x.get_axis(0).y) + ", " + _mknum(x.get_axis(0).z) + "), vec3(" + _mknum(x.get_axis(1).x) + ", " + _mknum(x.get_axis(1).y) + ", " + _mknum(x.get_axis(1).z) + "), vec3(" + _mknum(x.get_axis(2).x) + ", " + _mknum(x.get_axis(2).y) + ", " + _mknum(x.get_axis(2).z) + "))"; + } break; + case SL::TYPE_MAT4: { + Transform x = cnode->value; + code = "mat4( vec4(" + _mknum(x.basis.get_axis(0).x) + ", " + _mknum(x.basis.get_axis(0).y) + ", " + _mknum(x.basis.get_axis(0).z) + ",0.0), vec4(" + _mknum(x.basis.get_axis(1).x) + ", " + _mknum(x.basis.get_axis(1).y) + ", " + _mknum(x.basis.get_axis(1).z) + ",0.0), vec4(" + _mknum(x.basis.get_axis(2).x) + ", " + _mknum(x.basis.get_axis(2).y) + ", " + _mknum(x.basis.get_axis(2).z) + ",0.0), vec4(" + _mknum(x.origin.x) + ", " + _mknum(x.origin.y) + ", " + _mknum(x.origin.z) + ",1.0))"; + } break; + default: code = "<error: " + Variant::get_type_name(cnode->value.get_type()) + " (" + itos(cnode->datatype) + ">"; } } break; case SL::Node::TYPE_OPERATOR: { - SL::OperatorNode *onode=(SL::OperatorNode*)p_node; + SL::OperatorNode *onode = (SL::OperatorNode *)p_node; - - switch(onode->op) { + switch (onode->op) { case SL::OP_ASSIGN_MUL: { + if (onode->arguments[0]->get_datatype() == SL::TYPE_VEC3 && onode->arguments[1]->get_datatype() == SL::TYPE_MAT4) { - if (onode->arguments[0]->get_datatype()==SL::TYPE_VEC3 && onode->arguments[1]->get_datatype()==SL::TYPE_MAT4) { - - String mul_l=dump_node_code(onode->arguments[0],p_level,true); - String mul_r=dump_node_code(onode->arguments[1],p_level); - code=mul_l+"=(vec4("+mul_l+",1.0)*("+mul_r+")).xyz"; + String mul_l = dump_node_code(onode->arguments[0], p_level, true); + String mul_r = dump_node_code(onode->arguments[1], p_level); + code = mul_l + "=(vec4(" + mul_l + ",1.0)*(" + mul_r + ")).xyz"; break; - } else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT4 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC3) { + } else if (onode->arguments[0]->get_datatype() == SL::TYPE_MAT4 && onode->arguments[1]->get_datatype() == SL::TYPE_VEC3) { - String mul_l=dump_node_code(onode->arguments[0],p_level,true); - String mul_r=dump_node_code(onode->arguments[1],p_level); - code=mul_l+"=(("+mul_l+")*vec4("+mul_r+",1.0)).xyz"; + String mul_l = dump_node_code(onode->arguments[0], p_level, true); + String mul_r = dump_node_code(onode->arguments[1], p_level); + code = mul_l + "=((" + mul_l + ")*vec4(" + mul_r + ",1.0)).xyz"; 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) { - String mul_l=dump_node_code(onode->arguments[0],p_level,true); - String mul_r=dump_node_code(onode->arguments[1],p_level); - code=mul_l+"=(vec4("+mul_l+",0.0,1.0)*("+mul_r+")).xy"; + String mul_l = dump_node_code(onode->arguments[0], p_level, true); + String mul_r = dump_node_code(onode->arguments[1], p_level); + code = mul_l + "=(vec4(" + mul_l + ",0.0,1.0)*(" + mul_r + ")).xy"; 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_r=dump_node_code(onode->arguments[1],p_level); - code=mul_l+"=(("+mul_l+")*vec4("+mul_r+",0.0,1.0)).xy"; + String mul_l = dump_node_code(onode->arguments[0], p_level, true); + String mul_r = dump_node_code(onode->arguments[1], p_level); + code = mul_l + "=((" + mul_l + ")*vec4(" + mul_r + ",0.0,1.0)).xy"; break; - } 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_r=dump_node_code(onode->arguments[1],p_level); - code=mul_l+"=(("+mul_l+")*vec3("+mul_r+",1.0)).xy"; + } 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_r = dump_node_code(onode->arguments[1], p_level); + code = mul_l + "=((" + mul_l + ")*vec3(" + mul_r + ",1.0)).xy"; break; } - - }; case SL::OP_ASSIGN: case SL::OP_ASSIGN_ADD: case SL::OP_ASSIGN_SUB: case SL::OP_ASSIGN_DIV: - code="("+dump_node_code(onode->arguments[0],p_level,true)+_opstr(onode->op)+dump_node_code(onode->arguments[1],p_level)+")"; + code = "(" + dump_node_code(onode->arguments[0], p_level, true) + _opstr(onode->op) + dump_node_code(onode->arguments[1], p_level) + ")"; break; case SL::OP_MUL: - if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT4 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC3) { + if (onode->arguments[0]->get_datatype() == SL::TYPE_MAT4 && onode->arguments[1]->get_datatype() == SL::TYPE_VEC3) { - code="("+dump_node_code(onode->arguments[0],p_level)+"*vec4("+dump_node_code(onode->arguments[1],p_level)+",1.0)).xyz"; + code = "(" + dump_node_code(onode->arguments[0], p_level) + "*vec4(" + dump_node_code(onode->arguments[1], p_level) + ",1.0)).xyz"; break; - } else if (onode->arguments[0]->get_datatype()==SL::TYPE_VEC3 && onode->arguments[1]->get_datatype()==SL::TYPE_MAT4) { + } else if (onode->arguments[0]->get_datatype() == SL::TYPE_VEC3 && onode->arguments[1]->get_datatype() == SL::TYPE_MAT4) { - code="(vec4("+dump_node_code(onode->arguments[0],p_level)+",1.0)*"+dump_node_code(onode->arguments[1],p_level)+").xyz"; + code = "(vec4(" + dump_node_code(onode->arguments[0], p_level) + ",1.0)*" + dump_node_code(onode->arguments[1], p_level) + ").xyz"; 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)+",0.0,1.0)).xy"; + code = "(" + dump_node_code(onode->arguments[0], p_level) + "*vec4(" + dump_node_code(onode->arguments[1], p_level) + ",0.0,1.0)).xy"; 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)+",0.0,1.0)*"+dump_node_code(onode->arguments[1],p_level)+").xy"; + code = "(vec4(" + dump_node_code(onode->arguments[0], p_level) + ",0.0,1.0)*" + dump_node_code(onode->arguments[1], p_level) + ").xy"; 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) { - code="("+dump_node_code(onode->arguments[0],p_level)+"*vec3("+dump_node_code(onode->arguments[1],p_level)+",1.0)).xy"; + code = "(" + dump_node_code(onode->arguments[0], p_level) + "*vec3(" + dump_node_code(onode->arguments[1], p_level) + ",1.0)).xy"; 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) { - code="(vec3("+dump_node_code(onode->arguments[0],p_level)+",1.0)*"+dump_node_code(onode->arguments[1],p_level)+").xy"; + code = "(vec3(" + dump_node_code(onode->arguments[0], p_level) + ",1.0)*" + dump_node_code(onode->arguments[1], p_level) + ").xy"; break; } @@ -395,19 +396,18 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a case SL::OP_CMP_OR: case SL::OP_CMP_AND: //handle binary - code="("+dump_node_code(onode->arguments[0],p_level)+_opstr(onode->op)+dump_node_code(onode->arguments[1],p_level)+")"; + code = "(" + dump_node_code(onode->arguments[0], p_level) + _opstr(onode->op) + dump_node_code(onode->arguments[1], p_level) + ")"; break; case SL::OP_NEG: case SL::OP_NOT: //handle unary - code=_opstr(onode->op)+dump_node_code(onode->arguments[0],p_level); + code = _opstr(onode->op) + dump_node_code(onode->arguments[0], p_level); break; case SL::OP_CONSTRUCT: case SL::OP_CALL: { - String callfunc=dump_node_code(onode->arguments[0],p_level); - + String callfunc = dump_node_code(onode->arguments[0], p_level); - code=callfunc+"("; + code = callfunc + "("; /*if (callfunc=="mat4") { //fix constructor for mat4 for(int i=1;i<onode->arguments.size();i++) { @@ -417,78 +417,80 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a code+="vec4( "+dump_node_code(onode->arguments[i],p_level)+(i==4?",1.0)":",0.0)"); } - } else*/ if (callfunc=="tex") { + } else*/ if (callfunc == "tex") { - code="texture2D( "+dump_node_code(onode->arguments[1],p_level)+","+dump_node_code(onode->arguments[2],p_level)+")"; + code = "texture2D( " + dump_node_code(onode->arguments[1], p_level) + "," + dump_node_code(onode->arguments[2], p_level) + ")"; break; - } else if (callfunc=="texcube") { + } else if (callfunc == "texcube") { - code="(textureCube( "+dump_node_code(onode->arguments[1],p_level)+",("+dump_node_code(onode->arguments[2],p_level)+")).xyz"; + code = "(textureCube( " + dump_node_code(onode->arguments[1], p_level) + ",(" + dump_node_code(onode->arguments[2], p_level) + ")).xyz"; break; - } else if (callfunc=="texscreen") { + } else if (callfunc == "texscreen") { //create the call to sample the screen, and clamp it - uses_texscreen=true; - code="(texture2D( texscreen_tex, clamp(("+dump_node_code(onode->arguments[1],p_level)+").xy*texscreen_screen_mult,texscreen_screen_clamp.xy,texscreen_screen_clamp.zw))).rgb"; + uses_texscreen = true; + code = "(texture2D( texscreen_tex, clamp((" + dump_node_code(onode->arguments[1], p_level) + ").xy*texscreen_screen_mult,texscreen_screen_clamp.xy,texscreen_screen_clamp.zw))).rgb"; //code="(texture2D( screen_texture, ("+dump_node_code(onode->arguments[1],p_level)+").xy).rgb"; break; - } else if (callfunc=="texpos") { + } else if (callfunc == "texpos") { //create the call to sample the screen, and clamp it - uses_texpos=true; - code="get_texpos("+dump_node_code(onode->arguments[1],p_level)+""; + uses_texpos = true; + code = "get_texpos(" + dump_node_code(onode->arguments[1], p_level) + ""; //code="get_texpos(gl_ProjectionMatrixInverse * texture2D( depth_texture, clamp(("+dump_node_code(onode->arguments[1],p_level)+").xy,vec2(0.0),vec2(1.0))*gl_LightSource[5].specular.zw+gl_LightSource[5].specular.xy)"; //code="(texture2D( screen_texture, ("+dump_node_code(onode->arguments[1],p_level)+").xy).rgb"; break; - } else if (custom_h && callfunc=="cosh_custom") { + } else if (custom_h && callfunc == "cosh_custom") { if (!cosh_used) { - global_code= - "float cosh_custom(float val)\n"\ - "{\n"\ - " float tmp = exp(val);\n"\ - " float cosH = (tmp + 1.0 / tmp) / 2.0;\n"\ - " return cosH;\n"\ - "}\n"+global_code; - cosh_used=true; + global_code = + "float cosh_custom(float val)\n" + "{\n" + " float tmp = exp(val);\n" + " float cosH = (tmp + 1.0 / tmp) / 2.0;\n" + " return cosH;\n" + "}\n" + + global_code; + cosh_used = true; } - code="cosh_custom("+dump_node_code(onode->arguments[1],p_level)+""; - } else if (custom_h && callfunc=="sinh_custom") { + code = "cosh_custom(" + dump_node_code(onode->arguments[1], p_level) + ""; + } else if (custom_h && callfunc == "sinh_custom") { if (!sinh_used) { - global_code= - "float sinh_custom(float val)\n"\ - "{\n"\ - " float tmp = exp(val);\n"\ - " float sinH = (tmp - 1.0 / tmp) / 2.0;\n"\ - " return sinH;\n"\ - "}\n"+global_code; - sinh_used=true; + global_code = + "float sinh_custom(float val)\n" + "{\n" + " float tmp = exp(val);\n" + " float sinH = (tmp - 1.0 / tmp) / 2.0;\n" + " return sinH;\n" + "}\n" + + global_code; + sinh_used = true; } - code="sinh_custom("+dump_node_code(onode->arguments[1],p_level)+""; - } else if (custom_h && callfunc=="tanh_custom") { + code = "sinh_custom(" + dump_node_code(onode->arguments[1], p_level) + ""; + } else if (custom_h && callfunc == "tanh_custom") { if (!tanh_used) { - global_code= - "float tanh_custom(float val)\n"\ - "{\n"\ - " float tmp = exp(val);\n"\ - " float tanH = (tmp - 1.0 / tmp) / (tmp + 1.0 / tmp);\n"\ - " return tanH;\n"\ - "}\n"+global_code; - tanh_used=true; + global_code = + "float tanh_custom(float val)\n" + "{\n" + " float tmp = exp(val);\n" + " float tanH = (tmp - 1.0 / tmp) / (tmp + 1.0 / tmp);\n" + " return tanH;\n" + "}\n" + + global_code; + tanh_used = true; } - code="tanh_custom("+dump_node_code(onode->arguments[1],p_level)+""; + code = "tanh_custom(" + dump_node_code(onode->arguments[1], p_level) + ""; } else { - for(int i=1;i<onode->arguments.size();i++) { - if (i>1) - code+=", "; - //transform - code+=dump_node_code(onode->arguments[i],p_level); - + for (int i = 1; i < onode->arguments.size(); i++) { + if (i > 1) + code += ", "; + //transform + code += dump_node_code(onode->arguments[i], p_level); } } - code+=")"; + code += ")"; break; } break; default: {} @@ -496,83 +498,81 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a } break; case SL::Node::TYPE_CONTROL_FLOW: { - SL::ControlFlowNode *cfnode=(SL::ControlFlowNode*)p_node; - if (cfnode->flow_op==SL::FLOW_OP_IF) { + SL::ControlFlowNode *cfnode = (SL::ControlFlowNode *)p_node; + if (cfnode->flow_op == SL::FLOW_OP_IF) { - code+="if ("+dump_node_code(cfnode->statements[0],p_level)+") {" ENDL; - code+=dump_node_code(cfnode->statements[1],p_level+1); - if (cfnode->statements.size()==3) { + code += "if (" + dump_node_code(cfnode->statements[0], p_level) + ") {" ENDL; + code += dump_node_code(cfnode->statements[1], p_level + 1); + if (cfnode->statements.size() == 3) { - code+="} else {" ENDL; - code+=dump_node_code(cfnode->statements[2],p_level+1); + code += "} else {" ENDL; + code += dump_node_code(cfnode->statements[2], p_level + 1); } - code+="}" ENDL; + code += "}" ENDL; - } else if (cfnode->flow_op==SL::FLOW_OP_RETURN) { + } else if (cfnode->flow_op == SL::FLOW_OP_RETURN) { if (cfnode->statements.size()) { - code="return "+dump_node_code(cfnode->statements[0],p_level); + code = "return " + dump_node_code(cfnode->statements[0], p_level); } else { - code="return"; + code = "return"; } } } break; case SL::Node::TYPE_MEMBER: { - SL::MemberNode *mnode=(SL::MemberNode*)p_node; + SL::MemberNode *mnode = (SL::MemberNode *)p_node; String m; - if (mnode->basetype==SL::TYPE_MAT4) { - if (mnode->name=="x") - m="[0]"; - else if (mnode->name=="y") - m="[1]"; - else if (mnode->name=="z") - m="[2]"; - else if (mnode->name=="w") - m="[3]"; - } else if (mnode->basetype==SL::TYPE_MAT2) { - if (mnode->name=="x") - m="[0]"; - else if (mnode->name=="y") - m="[1]"; - - } else if (mnode->basetype==SL::TYPE_MAT3) { - if (mnode->name=="x") - m="[0]"; - else if (mnode->name=="y") - m="[1]"; - else if (mnode->name=="z") - m="[2]"; + if (mnode->basetype == SL::TYPE_MAT4) { + if (mnode->name == "x") + m = "[0]"; + else if (mnode->name == "y") + m = "[1]"; + else if (mnode->name == "z") + m = "[2]"; + else if (mnode->name == "w") + m = "[3]"; + } else if (mnode->basetype == SL::TYPE_MAT2) { + if (mnode->name == "x") + m = "[0]"; + else if (mnode->name == "y") + m = "[1]"; + + } else if (mnode->basetype == SL::TYPE_MAT3) { + if (mnode->name == "x") + m = "[0]"; + else if (mnode->name == "y") + m = "[1]"; + else if (mnode->name == "z") + m = "[2]"; } else { - m="."+mnode->name; + m = "." + mnode->name; } - code=dump_node_code(mnode->owner,p_level)+m; + code = dump_node_code(mnode->owner, p_level) + m; } break; } return code; - } - Error ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) { // feed the local replace table and global code - global_code=""; + global_code = ""; // uniforms first! - int ubase=0; + int ubase = 0; if (uniforms) - ubase=uniforms->size(); - for(Map<StringName,SL::Uniform>::Element *E=p_program->uniforms.front();E;E=E->next()) { + ubase = uniforms->size(); + for (Map<StringName, SL::Uniform>::Element *E = p_program->uniforms.front(); E; E = E->next()) { - String uline="uniform "+_typestr(E->get().type)+" _"+E->key().operator String()+";" ENDL; + String uline = "uniform " + _typestr(E->get().type) + " _" + E->key().operator String() + ";" ENDL; - global_code+=uline; + global_code += uline; if (uniforms) { /* if (uniforms->has(E->key())) { @@ -582,138 +582,134 @@ Error ShaderCompilerGLES2::compile_node(SL::ProgramNode *p_program) { } */ SL::Uniform u = E->get(); - u.order+=ubase; - uniforms->insert(E->key(),u); + u.order += ubase; + uniforms->insert(E->key(), u); } } - for(int i=0;i<p_program->functions.size();i++) { - + for (int i = 0; i < p_program->functions.size(); i++) { - SL::FunctionNode *fnode=p_program->functions[i].function; + SL::FunctionNode *fnode = p_program->functions[i].function; - StringName funcname=fnode->name; - String newfuncname=replace_string(funcname); + StringName funcname = fnode->name; + String newfuncname = replace_string(funcname); String header; - header=_typestr(fnode->return_type)+" "+newfuncname+"("; - for(int i=0;i<fnode->arguments.size();i++) { + header = _typestr(fnode->return_type) + " " + newfuncname + "("; + for (int i = 0; i < fnode->arguments.size(); i++) { - if (i>0) - header+=", "; - header+=_typestr(fnode->arguments[i].type)+" "+replace_string(fnode->arguments[i].name); + if (i > 0) + header += ", "; + header += _typestr(fnode->arguments[i].type) + " " + replace_string(fnode->arguments[i].name); } - header+=") {" ENDL; - String fcode=header; - fcode+=dump_node_code(fnode->body,1); - fcode+="}" ENDL; - global_code+=fcode; - + header += ") {" ENDL; + String fcode = header; + fcode += dump_node_code(fnode->body, 1); + fcode += "}" ENDL; + global_code += fcode; } -/* for(Map<StringName,SL::DataType>::Element *E=p_program->preexisting_variables.front();E;E=E->next()) { + /* for(Map<StringName,SL::DataType>::Element *E=p_program->preexisting_variables.front();E;E=E->next()) { StringName varname=E->key(); String newvarname=replace_string(varname); global_code+="uniform "+_typestr(E->get())+" "+newvarname+";" ENDL; }*/ - code=dump_node_code(p_program,0); + code = dump_node_code(p_program, 0); #ifdef DEBUG_SHADER_ENABLED print_line("GLOBAL CODE:\n\n"); print_line(global_code); - global_code=global_code.replace("\n",""); + global_code = global_code.replace("\n", ""); print_line("CODE:\n\n"); print_line(code); - code=code.replace("\n",""); + code = code.replace("\n", ""); #endif return OK; } -Error ShaderCompilerGLES2::create_glsl_120_code(void *p_str,SL::ProgramNode *p_program) { +Error ShaderCompilerGLES2::create_glsl_120_code(void *p_str, SL::ProgramNode *p_program) { - ShaderCompilerGLES2 *compiler=(ShaderCompilerGLES2*)p_str; + ShaderCompilerGLES2 *compiler = (ShaderCompilerGLES2 *)p_str; return compiler->compile_node(p_program); } +String ShaderCompilerGLES2::replace_string(const StringName &p_string) { -String ShaderCompilerGLES2::replace_string(const StringName& p_string) { - - Map<StringName,StringName>::Element *E=NULL; - E=replace_table.find(p_string); + Map<StringName, StringName>::Element *E = NULL; + E = replace_table.find(p_string); if (E) return E->get(); - E=mode_replace_table[type].find(p_string); + E = mode_replace_table[type].find(p_string); if (E) return E->get(); - - return "_"+p_string.operator String(); + return "_" + p_string.operator String(); } -Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderType p_type, String& r_code_line, String& r_globals_line, Flags& r_flags, Map<StringName,ShaderLanguage::Uniform> *r_uniforms) { - - uses_texscreen=false; - uses_texpos=false; - uses_alpha=false; - uses_discard=false; - uses_screen_uv=false; - uses_light=false; - uses_time=false; - uses_normalmap=false; - uses_normal=false; - uses_texpixel_size=false; - uses_worldvec=false; - vertex_code_writes_vertex=false; +Error ShaderCompilerGLES2::compile(const String &p_code, ShaderLanguage::ShaderType p_type, String &r_code_line, String &r_globals_line, Flags &r_flags, Map<StringName, ShaderLanguage::Uniform> *r_uniforms) { + + uses_texscreen = false; + uses_texpos = false; + uses_alpha = false; + uses_discard = false; + uses_screen_uv = false; + uses_light = false; + uses_time = false; + uses_normalmap = false; + uses_normal = false; + uses_texpixel_size = false; + uses_worldvec = false; + vertex_code_writes_vertex = false; vertex_code_writes_position = false; - uses_shadow_color=false; - uniforms=r_uniforms; - flags=&r_flags; - r_flags.use_color_interp=false; - r_flags.use_uv_interp=false; - r_flags.use_uv2_interp=false; - r_flags.use_tangent_interp=false; - r_flags.use_var1_interp=false; - r_flags.use_var2_interp=false; - r_flags.uses_normalmap=false; - r_flags.uses_normal=false; - sinh_used=false; - tanh_used=false; - cosh_used=false; + uses_shadow_color = false; + uniforms = r_uniforms; + flags = &r_flags; + r_flags.use_color_interp = false; + r_flags.use_uv_interp = false; + r_flags.use_uv2_interp = false; + r_flags.use_tangent_interp = false; + r_flags.use_var1_interp = false; + r_flags.use_var2_interp = false; + r_flags.uses_normalmap = false; + r_flags.uses_normal = false; + sinh_used = false; + tanh_used = false; + cosh_used = false; String error; - int errline,errcol; + int errline, errcol; - type=p_type; - Error err = SL::compile(p_code,p_type,create_glsl_120_code,this,&error,&errline,&errcol); + type = p_type; + Error err = SL::compile(p_code, p_type, create_glsl_120_code, this, &error, &errline, &errcol); if (err) { - print_line("***Error precompiling shader: "+error); - print_line("error "+itos(errline)+":"+itos(errcol)); + print_line("***Error precompiling shader: " + error); + print_line("error " + itos(errline) + ":" + itos(errcol)); return err; } - r_flags.uses_alpha=uses_alpha; - r_flags.uses_texscreen=uses_texscreen; - r_flags.uses_texpos=uses_texpos; - r_flags.vertex_code_writes_vertex=vertex_code_writes_vertex; - r_flags.vertex_code_writes_position=vertex_code_writes_position; - r_flags.uses_discard=uses_discard; - r_flags.uses_screen_uv=uses_screen_uv; - r_flags.uses_light=uses_light; - r_flags.uses_time=uses_time; - r_flags.uses_normalmap=uses_normalmap; - r_flags.uses_normal=uses_normal; - r_flags.uses_texpixel_size=uses_texpixel_size; - r_flags.uses_worldvec=uses_worldvec; - r_flags.uses_shadow_color=uses_shadow_color; - r_code_line=code; - r_globals_line=global_code; + r_flags.uses_alpha = uses_alpha; + r_flags.uses_texscreen = uses_texscreen; + r_flags.uses_texpos = uses_texpos; + r_flags.vertex_code_writes_vertex = vertex_code_writes_vertex; + r_flags.vertex_code_writes_position = vertex_code_writes_position; + r_flags.uses_discard = uses_discard; + r_flags.uses_screen_uv = uses_screen_uv; + r_flags.uses_light = uses_light; + r_flags.uses_time = uses_time; + r_flags.uses_normalmap = uses_normalmap; + r_flags.uses_normal = uses_normal; + r_flags.uses_texpixel_size = uses_texpixel_size; + r_flags.uses_worldvec = uses_worldvec; + r_flags.uses_shadow_color = uses_shadow_color; + r_code_line = code; + r_globals_line = global_code; return OK; } @@ -721,228 +717,222 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() { #ifdef GLEW_ENABLED //use custom functions because they are not supported in GLSL120 - custom_h=true; + custom_h = true; #else - custom_h=false; + custom_h = false; #endif - replace_table["bool"]= "bool"; - replace_table["float" ]= "float"; - replace_table["vec2" ]= "vec2"; - replace_table["vec3" ]= "vec3"; - replace_table["vec4" ]= "vec4"; - replace_table["mat2" ]= "mat2"; - replace_table["mat3" ]= "mat3"; - replace_table["mat4" ]= "mat4"; - replace_table["texture" ]= "sampler2D"; - replace_table["cubemap" ]= "samplerCube"; - - replace_table["sin"]= "sin"; - replace_table["cos" ]= "cos"; - replace_table["tan" ]= "tan"; - replace_table["asin" ]= "asin"; - replace_table["acos" ]= "acos"; - replace_table["atan" ]= "atan"; - replace_table["atan2"]= "atan"; + replace_table["bool"] = "bool"; + replace_table["float"] = "float"; + replace_table["vec2"] = "vec2"; + replace_table["vec3"] = "vec3"; + replace_table["vec4"] = "vec4"; + replace_table["mat2"] = "mat2"; + replace_table["mat3"] = "mat3"; + replace_table["mat4"] = "mat4"; + replace_table["texture"] = "sampler2D"; + replace_table["cubemap"] = "samplerCube"; + + replace_table["sin"] = "sin"; + replace_table["cos"] = "cos"; + replace_table["tan"] = "tan"; + replace_table["asin"] = "asin"; + replace_table["acos"] = "acos"; + replace_table["atan"] = "atan"; + replace_table["atan2"] = "atan"; if (custom_h) { - replace_table["sinh" ]= "sinh_custom"; - replace_table["cosh" ]= "cosh_custom"; - replace_table["tanh" ]= "tanh_custom"; + replace_table["sinh"] = "sinh_custom"; + replace_table["cosh"] = "cosh_custom"; + replace_table["tanh"] = "tanh_custom"; } else { - replace_table["sinh" ]= "sinh"; - replace_table["cosh" ]= "cosh"; - replace_table["tanh" ]= "tanh"; + replace_table["sinh"] = "sinh"; + replace_table["cosh"] = "cosh"; + replace_table["tanh"] = "tanh"; } - replace_table["pow" ]= "pow"; - replace_table["exp" ]= "exp"; - replace_table["log" ]= "log"; - replace_table["sqrt"]= "sqrt"; - replace_table["abs" ]= "abs"; - replace_table["sign"]= "sign"; - replace_table["floor"]= "floor"; - replace_table["trunc"]= "trunc"; + replace_table["pow"] = "pow"; + replace_table["exp"] = "exp"; + replace_table["log"] = "log"; + replace_table["sqrt"] = "sqrt"; + replace_table["abs"] = "abs"; + replace_table["sign"] = "sign"; + replace_table["floor"] = "floor"; + replace_table["trunc"] = "trunc"; #ifdef GLEW_ENABLED - replace_table["round"]= "roundfix"; + replace_table["round"] = "roundfix"; #else - replace_table["round"]= "round"; + replace_table["round"] = "round"; #endif - replace_table["ceil" ]= "ceil"; - replace_table["fract"]= "fract"; - replace_table["mod" ]= "mod"; - replace_table["min" ]= "min"; - replace_table["max"]= "max"; - replace_table["clamp"]= "clamp"; - replace_table["mix" ]= "mix"; - replace_table["step" ]= "step"; - replace_table["smoothstep" ]= "smoothstep"; - replace_table["length"]= "length"; - replace_table["distance"]= "distance"; - replace_table["dot" ]= "dot"; - replace_table["cross" ]="cross"; - replace_table["normalize"]= "normalize"; - replace_table["reflect"]= "reflect"; - replace_table["refract"]= "refract"; - replace_table["tex"]= "tex"; - replace_table["texa"]= "texa"; - replace_table["tex2"]= "tex2"; - replace_table["texcube"]= "textureCube"; - replace_table["texscreen"]= "texscreen"; - replace_table["texpos"]= "texpos"; - - + replace_table["ceil"] = "ceil"; + replace_table["fract"] = "fract"; + replace_table["mod"] = "mod"; + replace_table["min"] = "min"; + replace_table["max"] = "max"; + replace_table["clamp"] = "clamp"; + replace_table["mix"] = "mix"; + replace_table["step"] = "step"; + replace_table["smoothstep"] = "smoothstep"; + replace_table["length"] = "length"; + replace_table["distance"] = "distance"; + replace_table["dot"] = "dot"; + replace_table["cross"] = "cross"; + replace_table["normalize"] = "normalize"; + replace_table["reflect"] = "reflect"; + replace_table["refract"] = "refract"; + replace_table["tex"] = "tex"; + replace_table["texa"] = "texa"; + replace_table["tex2"] = "tex2"; + replace_table["texcube"] = "textureCube"; + replace_table["texscreen"] = "texscreen"; + replace_table["texpos"] = "texpos"; mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_VERTEX"] = "vertex_in.xyz"; mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_NORMAL"] = "normal_in"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_TANGENT"]="tangent_in"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_BINORMALF"]="binormalf"; - + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_TANGENT"] = "tangent_in"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SRC_BINORMALF"] = "binormalf"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["POSITION"] = "gl_Position"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VERTEX"]="vertex_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["NORMAL"]="normal_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TANGENT"]="tangent_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["BINORMAL"]="binormal_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["UV"]="uv_interp.xy"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["UV2"]="uv_interp.zw"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["COLOR"]="color_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VERTEX"] = "vertex_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["NORMAL"] = "normal_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TANGENT"] = "tangent_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["BINORMAL"] = "binormal_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["UV"] = "uv_interp.xy"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["UV2"] = "uv_interp.zw"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["COLOR"] = "color_interp"; //@TODO convert to glsl stuff - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SPEC_EXP"]="vertex_specular_exp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["WORLD_MATRIX"]="world_transform"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INV_CAMERA_MATRIX"]="camera_inverse_transform"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["PROJECTION_MATRIX"]="projection_transform"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["MODELVIEW_MATRIX"]="modelview"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["POINT_SIZE"]="gl_PointSize"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR1"]="var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR2"]="var2_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SPEC_EXP"] = "vertex_specular_exp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["WORLD_MATRIX"] = "world_transform"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INV_CAMERA_MATRIX"] = "camera_inverse_transform"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["PROJECTION_MATRIX"] = "projection_transform"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["MODELVIEW_MATRIX"] = "modelview"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["POINT_SIZE"] = "gl_PointSize"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR1"] = "var1_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["VAR2"] = "var2_interp"; //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_POS"]="SCREEN_POS"; //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["SCREEN_SIZE"]="SCREEN_SIZE"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INSTANCE_ID"]="instance_id"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TIME"]="time"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["INSTANCE_ID"] = "instance_id"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_VERTEX]["TIME"] = "time"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VERTEX"]="vertex"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VERTEX"] = "vertex"; //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POSITION"]="IN_POSITION"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMAL"]="normal"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["TANGENT"]="tangent"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POSITION"]="gl_Position"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["BINORMAL"]="binormal"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMALMAP"]="normalmap"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMALMAP_DEPTH"]="normaldepth"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR1"]="var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR2"]="var2_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["UV"]="uv"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["UV2"]="uv2"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_UV"]="screen_uv"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR1"]="var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR2"]="var2_interp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["COLOR"]="color"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DIFFUSE"]="diffuse.rgb"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DIFFUSE_ALPHA"]="diffuse"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SPECULAR"]="specular"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["EMISSION"]="emission"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SHADE_PARAM"]="shade_param"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SPEC_EXP"]="specular_exp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["GLOW"]="glow"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DISCARD"]="discard_"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POINT_COORD"]="gl_PointCoord"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["INV_CAMERA_MATRIX"]="camera_inverse_transform"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMAL"] = "normal"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["TANGENT"] = "tangent"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POSITION"] = "gl_Position"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["BINORMAL"] = "binormal"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMALMAP"] = "normalmap"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["NORMALMAP_DEPTH"] = "normaldepth"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR1"] = "var1_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR2"] = "var2_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["UV"] = "uv"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["UV2"] = "uv2"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_UV"] = "screen_uv"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR1"] = "var1_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["VAR2"] = "var2_interp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["COLOR"] = "color"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DIFFUSE"] = "diffuse.rgb"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DIFFUSE_ALPHA"] = "diffuse"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SPECULAR"] = "specular"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["EMISSION"] = "emission"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SHADE_PARAM"] = "shade_param"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SPEC_EXP"] = "specular_exp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["GLOW"] = "glow"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["DISCARD"] = "discard_"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["POINT_COORD"] = "gl_PointCoord"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["INV_CAMERA_MATRIX"] = "camera_inverse_transform"; //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_POS"]="SCREEN_POS"; //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["TIME"]="time"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_FRAGMENT]["TIME"] = "time"; ////////////// - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["NORMAL"]="normal"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["NORMAL"] = "normal"; //mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["POSITION"]="IN_POSITION"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_DIR"]="light_dir"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_DIFFUSE"]="light_diffuse"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_SPECULAR"]="light_specular"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["EYE_VEC"]="eye_vec"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["DIFFUSE"]="mdiffuse"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SPECULAR"]="specular"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SPECULAR_EXP"]="specular_exp"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SHADE_PARAM"]="shade_param"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT"]="light"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["POINT_COORD"]="gl_PointCoord"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["TIME"]="time"; - mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SHADOW"]="shadow_color"; - - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["SRC_VERTEX"]="src_vtx"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VERTEX"]="outvec.xy"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["WORLD_VERTEX"]="outvec.xy"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["UV"]="uv_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["COLOR"]="color_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VAR1"]="var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VAR2"]="var2_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["POINT_SIZE"]="gl_PointSize"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["WORLD_MATRIX"]="modelview_matrix"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["PROJECTION_MATRIX"]="projection_matrix"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["EXTRA_MATRIX"]="extra_matrix"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["TIME"]="time"; - - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["POSITION"]="gl_Position"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMAL"]="normal"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMALMAP"]="normal_map"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMALMAP_DEPTH"]="normal_depth"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["UV"]="uv_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["SRC_COLOR"]="color_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["COLOR"]="color"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TEXTURE"]="texture"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TEXTURE_PIXEL_SIZE"]="texpixel_size"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["VAR1"]="var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["VAR2"]="var2_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["SCREEN_UV"]="screen_uv"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["POINT_COORD"]="gl_PointCoord"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TIME"]="time"; - - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["POSITION"]="gl_Position"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["NORMAL"]="normal"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["UV"]="uv_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["COLOR"]="color"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TEXTURE"]="texture"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TEXTURE_PIXEL_SIZE"]="texpixel_size"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["VAR1"]="var1_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["VAR2"]="var2_interp"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_VEC"]="light_vec"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_HEIGHT"]="light_height"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_COLOR"]="light"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_SHADOW"]="light_shadow_color"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_UV"]="light_uv"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT"]="light_out"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SHADOW"]="shadow_color"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SCREEN_UV"]="screen_uv"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["POINT_COORD"]="gl_PointCoord"; - mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TIME"]="time"; - - + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_DIR"] = "light_dir"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_DIFFUSE"] = "light_diffuse"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT_SPECULAR"] = "light_specular"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["EYE_VEC"] = "eye_vec"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["DIFFUSE"] = "mdiffuse"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SPECULAR"] = "specular"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SPECULAR_EXP"] = "specular_exp"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SHADE_PARAM"] = "shade_param"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["LIGHT"] = "light"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["POINT_COORD"] = "gl_PointCoord"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["TIME"] = "time"; + mode_replace_table[ShaderLanguage::SHADER_MATERIAL_LIGHT]["SHADOW"] = "shadow_color"; + + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["SRC_VERTEX"] = "src_vtx"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VERTEX"] = "outvec.xy"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["WORLD_VERTEX"] = "outvec.xy"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["UV"] = "uv_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["COLOR"] = "color_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VAR1"] = "var1_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["VAR2"] = "var2_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["POINT_SIZE"] = "gl_PointSize"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["WORLD_MATRIX"] = "modelview_matrix"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["PROJECTION_MATRIX"] = "projection_matrix"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["EXTRA_MATRIX"] = "extra_matrix"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_VERTEX]["TIME"] = "time"; + + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["POSITION"] = "gl_Position"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMAL"] = "normal"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMALMAP"] = "normal_map"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["NORMALMAP_DEPTH"] = "normal_depth"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["UV"] = "uv_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["SRC_COLOR"] = "color_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["COLOR"] = "color"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TEXTURE"] = "texture"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TEXTURE_PIXEL_SIZE"] = "texpixel_size"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["VAR1"] = "var1_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["VAR2"] = "var2_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["SCREEN_UV"] = "screen_uv"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["POINT_COORD"] = "gl_PointCoord"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_FRAGMENT]["TIME"] = "time"; + + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["POSITION"] = "gl_Position"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["NORMAL"] = "normal"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["UV"] = "uv_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["COLOR"] = "color"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TEXTURE"] = "texture"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TEXTURE_PIXEL_SIZE"] = "texpixel_size"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["VAR1"] = "var1_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["VAR2"] = "var2_interp"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_VEC"] = "light_vec"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_HEIGHT"] = "light_height"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_COLOR"] = "light"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_SHADOW"] = "light_shadow_color"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT_UV"] = "light_uv"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["LIGHT"] = "light_out"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SHADOW"] = "shadow_color"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["SCREEN_UV"] = "screen_uv"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["POINT_COORD"] = "gl_PointCoord"; + mode_replace_table[ShaderLanguage::SHADER_CANVAS_ITEM_LIGHT]["TIME"] = "time"; //mode_replace_table[2]["SCREEN_POS"]="SCREEN_POS"; //mode_replace_table[2]["SCREEN_TEXEL_SIZE"]="SCREEN_TEXEL_SIZE"; - - out_vertex_name="VERTEX"; - - vname_discard="DISCARD"; - vname_screen_uv="SCREEN_UV"; - vname_diffuse_alpha="DIFFUSE_ALPHA"; - vname_color_interp="COLOR"; - vname_uv_interp="UV"; - vname_uv2_interp="UV2"; - vname_tangent_interp="TANGENT"; - vname_binormal_interp="BINORMAL"; - vname_var1_interp="VAR1"; - vname_var2_interp="VAR2"; - vname_vertex="VERTEX"; + out_vertex_name = "VERTEX"; + + vname_discard = "DISCARD"; + vname_screen_uv = "SCREEN_UV"; + vname_diffuse_alpha = "DIFFUSE_ALPHA"; + vname_color_interp = "COLOR"; + vname_uv_interp = "UV"; + vname_uv2_interp = "UV2"; + vname_tangent_interp = "TANGENT"; + vname_binormal_interp = "BINORMAL"; + vname_var1_interp = "VAR1"; + vname_var2_interp = "VAR2"; + vname_vertex = "VERTEX"; vname_position = "POSITION"; - vname_light="LIGHT"; - vname_time="TIME"; - vname_normalmap="NORMALMAP"; - vname_normalmap_depth="NORMALMAP_DEPTH"; - vname_normal="NORMAL"; - vname_texpixel_size="TEXTURE_PIXEL_SIZE"; - vname_world_vec="WORLD_VERTEX"; - vname_shadow="SHADOW"; - + vname_light = "LIGHT"; + vname_time = "TIME"; + vname_normalmap = "NORMALMAP"; + vname_normalmap_depth = "NORMALMAP_DEPTH"; + vname_normal = "NORMAL"; + vname_texpixel_size = "TEXTURE_PIXEL_SIZE"; + vname_world_vec = "WORLD_VERTEX"; + vname_shadow = "SHADOW"; } |