summaryrefslogtreecommitdiff
path: root/drivers/gles2/shader_compiler_gles2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/gles2/shader_compiler_gles2.cpp')
-rw-r--r--drivers/gles2/shader_compiler_gles2.cpp22
1 files changed, 17 insertions, 5 deletions
diff --git a/drivers/gles2/shader_compiler_gles2.cpp b/drivers/gles2/shader_compiler_gles2.cpp
index f1ddcf8009..b2052c7cbb 100644
--- a/drivers/gles2/shader_compiler_gles2.cpp
+++ b/drivers/gles2/shader_compiler_gles2.cpp
@@ -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) {
flags->use_var2_interp=true;
}
+ if (vnode->name==vname_world_vec) {
+ uses_worldvec=true;
+ }
}
@@ -258,6 +261,11 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
uses_light=true;
}
+ if (vnode->name==vname_normal) {
+ uses_normal=true;
+ }
+
+
}
if (vnode->name==vname_time) {
@@ -307,13 +315,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_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;
} 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+",1.0,1.0)).xy";
+ 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);
@@ -343,11 +351,11 @@ String ShaderCompilerGLES2::dump_node_code(SL::Node *p_node,int p_level,bool p_a
break;
} 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;
} 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;
} else if (onode->arguments[0]->get_datatype()==SL::TYPE_MAT3 && onode->arguments[1]->get_datatype()==SL::TYPE_VEC2) {
@@ -599,6 +607,7 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
uses_normalmap=false;
uses_normal=false;
uses_texpixel_size=false;
+ uses_worldvec=false;
vertex_code_writes_vertex=false;
uniforms=r_uniforms;
flags=&r_flags;
@@ -632,8 +641,9 @@ Error ShaderCompilerGLES2::compile(const String& p_code, ShaderLanguage::ShaderT
r_flags.uses_light=uses_light;
r_flags.uses_time=uses_time;
r_flags.uses_normalmap=uses_normalmap;
- r_flags.uses_normal=uses_normalmap;
+ r_flags.uses_normal=uses_normal;
r_flags.uses_texpixel_size=uses_texpixel_size;
+ r_flags.uses_worldvec=uses_worldvec;
r_code_line=code;
r_globals_line=global_code;
@@ -774,6 +784,7 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
mode_replace_table[3]["SRC_VERTEX"]="src_vtx";
mode_replace_table[3]["VERTEX"]="outvec.xy";
+ mode_replace_table[3]["WORLD_VERTEX"]="outvec.xy";
mode_replace_table[3]["UV"]="uv_interp";
mode_replace_table[3]["COLOR"]="color_interp";
mode_replace_table[3]["VAR1"]="var1_interp";
@@ -830,5 +841,6 @@ ShaderCompilerGLES2::ShaderCompilerGLES2() {
vname_normalmap="NORMALMAP";
vname_normal="NORMAL";
vname_texpixel_size="TEXTURE_PIXEL_SIZE";
+ vname_world_vec="WORLD_VERTEX";
}