summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJuan Linietsky <juan@okamstudio.com>2015-01-20 22:31:32 -0300
committerJuan Linietsky <juan@okamstudio.com>2015-01-20 22:31:32 -0300
commitda0d4e4dea021c1fc10549cd5374d1baca2e4006 (patch)
tree5e7524a9d9f37c4207275474a4d0446465285d75
parent11c1756257368f3cd41702016c3303c0d22e3b59 (diff)
Fixes to texscreen, fixes to white testcube
-rw-r--r--drivers/gles2/rasterizer_gles2.cpp19
-rw-r--r--scene/resources/shader_graph.cpp4
2 files changed, 17 insertions, 6 deletions
diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp
index 4990e81f42..43bd45ae80 100644
--- a/drivers/gles2/rasterizer_gles2.cpp
+++ b/drivers/gles2/rasterizer_gles2.cpp
@@ -4957,12 +4957,22 @@ _FORCE_INLINE_ void RasterizerGLES2::_update_material_shader_params(Material *p_
Material::UniformData ud;
bool keep=true; //keep material value
- bool has_old = old_mparams.has(E->key());
+
+ Map<StringName,Material::UniformData>::Element *OLD=old_mparams.find(E->key());
+ bool has_old = OLD;
bool old_inuse=has_old && old_mparams[E->key()].inuse;
if (!has_old || !old_inuse)
keep=false;
- else if (old_mparams[E->key()].value.get_type()!=E->value().default_value.get_type()) {
+ else if (OLD->get().value.get_type()!=E->value().default_value.get_type()) {
+
+ if (OLD->get().value.get_type()==Variant::INT && E->get().type==ShaderLanguage::TYPE_FLOAT) {
+ //handle common mistake using shaders (feeding ints instead of float)
+ OLD->get().value=float(OLD->get().value);
+ keep=true;
+ } else if (E->value().default_value.get_type()!=Variant::NIL) {
+ keep=false;
+ }
//type changed between old and new
/* if (old_mparams[E->key()].value.get_type()==Variant::OBJECT) {
if (E->value().default_value.get_type()!=Variant::_RID) //hackfor textures
@@ -4971,8 +4981,7 @@ _FORCE_INLINE_ void RasterizerGLES2::_update_material_shader_params(Material *p_
keep=false;*/
//value is invalid because type differs and default is not null
- if (E->value().default_value.get_type()!=Variant::NIL)
- keep=false;
+ ;
}
ud.istexture=(E->get().type==ShaderLanguage::TYPE_TEXTURE || E->get().type==ShaderLanguage::TYPE_CUBEMAP);
@@ -5099,8 +5108,10 @@ bool RasterizerGLES2::_setup_material(const Geometry *p_geometry,const Material
int texcoord=0;
for (Map<StringName,Material::UniformData>::Element *E=p_material->shader_params.front();E;E=E->next()) {
+
if (E->get().index<0)
continue;
+// print_line(String(E->key())+": "+E->get().value);
if (E->get().istexture) {
//clearly a texture..
RID rid = E->get().value;
diff --git a/scene/resources/shader_graph.cpp b/scene/resources/shader_graph.cpp
index 73812a7ae5..2630bc5bad 100644
--- a/scene/resources/shader_graph.cpp
+++ b/scene/resources/shader_graph.cpp
@@ -1790,7 +1790,7 @@ void ShaderGraph::_update_shader() {
all_ok=false;
}
-/* print_line("VERTEX: \n"+code[0]);
+ /*print_line("VERTEX: \n"+code[0]);
print_line("FRAGMENT: \n"+code[1]);
print_line("LIGHT: \n"+code[2]);*/
@@ -1973,7 +1973,7 @@ void ShaderGraph::_add_node_code(ShaderType p_type,Node *p_node,const Vector<Str
code+=OUTNAME(p_node->id,0)+"=TIME;\n";
}break;
case NODE_SCREEN_TEX: {
- code+=OUTNAME(p_node->id,0)+"=texscreen("+p_inputs[0]+");\n";
+ code+=OUTNAME(p_node->id,0)+"=texscreen("+p_inputs[0]+".xy);\n";
}break;
case NODE_SCALAR_OP: {
int op = p_node->param1;