diff options
Diffstat (limited to 'drivers')
-rw-r--r-- | drivers/gles2/rasterizer_gles2.cpp | 19 |
1 files changed, 15 insertions, 4 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; |