diff --git a/drivers/gles3/shaders/scene.glsl b/drivers/gles3/shaders/scene.glsl index acece2e6397..340a1f24d24 100644 --- a/drivers/gles3/shaders/scene.glsl +++ b/drivers/gles3/shaders/scene.glsl @@ -810,6 +810,9 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) { vec2 screen_rel = to_screen - from_screen; + if (length(screen_rel)<0.00001) + return 1.0; //too small, don't do anything + /*float pixel_size; //approximate pixel size if (screen_rel.x > screen_rel.y) { @@ -825,15 +828,16 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) { vec2 pixel_incr = normalize(screen_rel)*screen_pixel_size; - float steps = length(screen_rel) / length(pixel_incr); + float steps = length(screen_rel) / length(pixel_incr); + steps = min(2000.0,steps); //put a limit to avoid freezing in some strange situation //steps=10.0; vec4 incr = (dest - source)/steps; float ratio=0.0; float ratio_incr = 1.0/steps; - do { + while(steps>0.0) { source += incr*2.0; bias+=incr*2.0; @@ -851,7 +855,7 @@ float contact_shadow_compute(vec3 pos, vec3 dir, float max_distance) { ratio+=ratio_incr; steps-=1.0; - } while (steps>0.0); + } return 1.0; } diff --git a/editor/import/resource_importer_obj.cpp b/editor/import/resource_importer_obj.cpp index 25548f7899b..8f86e64cf22 100644 --- a/editor/import/resource_importer_obj.cpp +++ b/editor/import/resource_importer_obj.cpp @@ -323,8 +323,8 @@ Node *EditorOBJImporter::import_scene(const String &p_path, uint32_t p_flags, in surf_tool->add_smooth_group(false); else surf_tool->add_smooth_group(true); - } else if (l.begins_with("g ") || l.begins_with("usemtl ") || (l.begins_with("o ") || f->eof_reached())) { //commit group to mesh - + } else if (/*l.begins_with("g ") ||*/ l.begins_with("usemtl ") || (l.begins_with("o ") || f->eof_reached())) { //commit group to mesh + //groups are too annoying if (surf_tool->get_vertex_array().size()) { //another group going on, commit it if (normals.size() == 0) { diff --git a/scene/3d/gi_probe.cpp b/scene/3d/gi_probe.cpp index 0c31282a6c5..7aaf4a6e3d2 100644 --- a/scene/3d/gi_probe.cpp +++ b/scene/3d/gi_probe.cpp @@ -999,7 +999,7 @@ GIProbe::Baker::MaterialCache GIProbe::_get_material_cache(Ref p_mater return mc; } -void GIProbe::_plot_mesh(const Transform &p_xform, Ref &p_mesh, Baker *p_baker, const Vector > &p_materials, const Ref &p_override_material) { +void GIProbe::_plot_mesh(const Transform &p_xform, Ref &p_mesh, Baker *p_baker, const Vector > &p_materials, const Ref &p_override_material) { for (int i = 0; i < p_mesh->get_surface_count(); i++) { @@ -1093,7 +1093,7 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) { MeshInstance *mi = p_at_node->cast_to(); if (mi && mi->get_flag(GeometryInstance::FLAG_USE_BAKED_LIGHT)) { - Ref mesh = mi->get_mesh(); + Ref mesh = mi->get_mesh(); if (mesh.is_valid()) { Rect3 aabb = mesh->get_aabb(); @@ -1120,7 +1120,7 @@ void GIProbe::_find_meshes(Node *p_at_node, Baker *p_baker) { for (int i = 0; i < meshes.size(); i += 2) { Transform mxf = meshes[i]; - Ref mesh = meshes[i + 1]; + Ref mesh = meshes[i + 1]; if (!mesh.is_valid()) continue; diff --git a/scene/3d/gi_probe.h b/scene/3d/gi_probe.h index 3f5a50a560b..8346437ebdc 100644 --- a/scene/3d/gi_probe.h +++ b/scene/3d/gi_probe.h @@ -148,7 +148,7 @@ private: struct PlotMesh { Ref override_material; Vector > instance_materials; - Ref mesh; + Ref mesh; Transform local_xform; }; @@ -177,7 +177,7 @@ private: Vector _get_bake_texture(Ref p_image, const Color &p_color); Baker::MaterialCache _get_material_cache(Ref p_material, Baker *p_baker); void _plot_face(int p_idx, int p_level, int p_x, int p_y, int p_z, const Vector3 *p_vtx, const Vector2 *p_uv, const Baker::MaterialCache &p_material, const Rect3 &p_aabb, Baker *p_baker); - void _plot_mesh(const Transform &p_xform, Ref &p_mesh, Baker *p_baker, const Vector > &p_materials, const Ref &p_override_material); + void _plot_mesh(const Transform &p_xform, Ref &p_mesh, Baker *p_baker, const Vector > &p_materials, const Ref &p_override_material); void _find_meshes(Node *p_at_node, Baker *p_baker); void _fixup_plot(int p_idx, int p_level, int p_x, int p_y, int p_z, Baker *p_baker); diff --git a/servers/visual/visual_server_scene.cpp b/servers/visual/visual_server_scene.cpp index 97583dc8490..c383be549b9 100644 --- a/servers/visual/visual_server_scene.cpp +++ b/servers/visual/visual_server_scene.cpp @@ -2716,8 +2716,8 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header, co success_count++; } } - print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0)); - print_line("valid cells: " + itos(success_count)); + //print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0)); + //print_line("valid cells: " + itos(success_count)); } break; case VS::LIGHT_OMNI: @@ -2822,7 +2822,7 @@ void VisualServerScene::_bake_gi_probe_light(const GIProbeDataHeader *header, co light->energy[2] += int32_t(light_b * att * ((cell->albedo) & 0xFF) / 255.0); } } - print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0)); + //print_line("BAKE TIME: " + rtos((OS::get_singleton()->get_ticks_usec() - us) / 1000000.0)); } break; } @@ -2921,7 +2921,7 @@ void VisualServerScene::_bake_gi_probe(Instance *p_gi_probe) { if (stage >= probe_data->dynamic.mipmaps_3d.size()) continue; //no mipmap for this one - print_line("generating mipmap stage: " + itos(stage)); + //print_line("generating mipmap stage: " + itos(stage)); int level_cell_count = probe_data->dynamic.level_cell_lists[i].size(); const uint32_t *level_cells = probe_data->dynamic.level_cell_lists[i].ptr();