From d148a0384821a05f8714099cf00e1b521643a2ad Mon Sep 17 00:00:00 2001 From: Juan Linietsky Date: Thu, 9 Apr 2015 00:29:21 -0300 Subject: -Fixes bug in ShaderGraph material, when uniform property is not used, fixes #1634 and #1610 --- drivers/gles2/rasterizer_gles2.cpp | 3 +++ scene/resources/shader.cpp | 5 +++-- scene/resources/shader_graph.cpp | 3 +++ servers/visual_server.cpp | 3 +-- 4 files changed, 10 insertions(+), 4 deletions(-) diff --git a/drivers/gles2/rasterizer_gles2.cpp b/drivers/gles2/rasterizer_gles2.cpp index 4f486897d1..3c7026daf1 100644 --- a/drivers/gles2/rasterizer_gles2.cpp +++ b/drivers/gles2/rasterizer_gles2.cpp @@ -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; diff --git a/scene/resources/shader.cpp b/scene/resources/shader.cpp index 42251124bd..c15288fdb4 100644 --- a/scene/resources/shader.cpp +++ b/scene/resources/shader.cpp @@ -136,8 +136,10 @@ 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::Element *E=names.front();E;E=E->next()) { + set_default_texture_param(E->get(),Ref()); } @@ -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]); } diff --git a/servers/visual_server.cpp b/servers/visual_server.cpp index 5ddfaf7967..1dd078731b 100644 --- a/servers/visual_server.cpp +++ b/servers/visual_server.cpp @@ -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) ); -- cgit v1.2.3