|
@@ -4957,12 +4957,22 @@ _FORCE_INLINE_ void RasterizerGLES2::_update_material_shader_params(Material *p_
|
|
Material::UniformData ud;
|
|
Material::UniformData ud;
|
|
|
|
|
|
bool keep=true; //keep material value
|
|
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;
|
|
bool old_inuse=has_old && old_mparams[E->key()].inuse;
|
|
|
|
|
|
if (!has_old || !old_inuse)
|
|
if (!has_old || !old_inuse)
|
|
keep=false;
|
|
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
|
|
//type changed between old and new
|
|
/* if (old_mparams[E->key()].value.get_type()==Variant::OBJECT) {
|
|
/* if (old_mparams[E->key()].value.get_type()==Variant::OBJECT) {
|
|
if (E->value().default_value.get_type()!=Variant::_RID) //hackfor textures
|
|
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;*/
|
|
keep=false;*/
|
|
|
|
|
|
//value is invalid because type differs and default is not null
|
|
//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);
|
|
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;
|
|
int texcoord=0;
|
|
for (Map<StringName,Material::UniformData>::Element *E=p_material->shader_params.front();E;E=E->next()) {
|
|
for (Map<StringName,Material::UniformData>::Element *E=p_material->shader_params.front();E;E=E->next()) {
|
|
|
|
|
|
|
|
+
|
|
if (E->get().index<0)
|
|
if (E->get().index<0)
|
|
continue;
|
|
continue;
|
|
|
|
+// print_line(String(E->key())+": "+E->get().value);
|
|
if (E->get().istexture) {
|
|
if (E->get().istexture) {
|
|
//clearly a texture..
|
|
//clearly a texture..
|
|
RID rid = E->get().value;
|
|
RID rid = E->get().value;
|