Fixes to texscreen, fixes to white testcube
This commit is contained in:
parent
11c1756257
commit
da0d4e4dea
2 changed files with 17 additions and 6 deletions
|
@ -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;
|
||||||
|
|
|
@ -1790,7 +1790,7 @@ void ShaderGraph::_update_shader() {
|
||||||
all_ok=false;
|
all_ok=false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* print_line("VERTEX: \n"+code[0]);
|
/*print_line("VERTEX: \n"+code[0]);
|
||||||
print_line("FRAGMENT: \n"+code[1]);
|
print_line("FRAGMENT: \n"+code[1]);
|
||||||
print_line("LIGHT: \n"+code[2]);*/
|
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";
|
code+=OUTNAME(p_node->id,0)+"=TIME;\n";
|
||||||
}break;
|
}break;
|
||||||
case NODE_SCREEN_TEX: {
|
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;
|
}break;
|
||||||
case NODE_SCALAR_OP: {
|
case NODE_SCALAR_OP: {
|
||||||
int op = p_node->param1;
|
int op = p_node->param1;
|
||||||
|
|
Loading…
Reference in a new issue