-Fixes bug in ShaderGraph material, when uniform property is not used, fixes #1634 and #1610

This commit is contained in:
Juan Linietsky 2015-04-09 00:29:21 -03:00
parent e18c6ef63b
commit d148a03848
4 changed files with 10 additions and 4 deletions

View File

@ -1652,6 +1652,9 @@ void RasterizerGLES2::material_set_param(RID p_material, const StringName& p_par
}
} else {
if (p_value.get_type()==Variant::NIL)
return;
Material::UniformData ud;
ud.index=-1;
ud.value=p_value;

View File

@ -136,11 +136,13 @@ void Shader::_set_code(const Dictionary& p_string) {
if (p_string.has("default_tex")) {
Array arr=p_string["default_tex"];
if ((arr.size()&1)==0) {
for(int i=0;i<arr.size();i+=2)
for(int i=0;i<arr.size();i+=2) {
set_default_texture_param(arr[i],arr[i+1]);
}
}
}
}
void Shader::set_default_texture_param(const StringName& p_param,const Ref<Texture>& p_texture) {
@ -338,7 +340,6 @@ RES ResourceFormatLoaderShader::load(const String &p_path,const String& p_origin
String type = right.substr(0,popenpos);
String param = right.substr(popenpos+1,pclosepos-popenpos-1).strip_edges();
print_line("type: "+type+" param: "+param);
if (type=="tex") {

View File

@ -92,6 +92,7 @@ void ShaderGraph::_set_data(const Dictionary &p_data) {
}
}
_pending_update_shader=true;
_update_shader();
}
@ -1607,6 +1608,7 @@ void ShaderGraph::_update_shader() {
get_default_texture_param_list(&names);
for (List<StringName>::Element *E=names.front();E;E=E->next()) {
set_default_texture_param(E->get(),Ref<Texture>());
}
@ -1750,6 +1752,7 @@ void ShaderGraph::_update_shader() {
if (n->type==NODE_TEXTURE_INPUT || n->type==NODE_CUBEMAP_INPUT) {
set_default_texture_param(n->param1,n->param2);
}
_add_node_code(ShaderType(i),n,inputs,code[i]);
}

View File

@ -146,7 +146,6 @@ RID VisualServer::_make_test_cube() {
tangents.push_back( normal_points[m_idx][0] );\
tangents.push_back( 1.0 );\
uvs.push_back( Vector3(uv_points[m_idx*2+0],uv_points[m_idx*2+1],0) );\
print_line(itos( (face_points[m_idx][0]>0?1:0)|(face_points[m_idx][1]>0?2:0)|(face_points[m_idx][2]>0?4:0)));\
vtx_idx++;\
for (int i=0;i<6;i++) {
@ -207,7 +206,7 @@ RID VisualServer::_make_test_cube() {
//material_set_flag(material, MATERIAL_FLAG_BILLBOARD_TOGGLE,true);
fixed_material_set_texture( material, FIXED_MATERIAL_PARAM_DIFFUSE, get_test_texture() );
fixed_material_set_param( material, FIXED_MATERIAL_PARAM_SPECULAR_EXP, 70 );
fixed_material_set_param( material, FIXED_MATERIAL_PARAM_EMISSION, Vector3(0.2,0.2,0.2) );
fixed_material_set_param( material, FIXED_MATERIAL_PARAM_EMISSION, Color(0.2,0.2,0.2) );
fixed_material_set_param( material, FIXED_MATERIAL_PARAM_DIFFUSE, Color(1, 1, 1) );
fixed_material_set_param( material, FIXED_MATERIAL_PARAM_SPECULAR, Color(1,1,1) );