| 1689 | } |
| 1690 | |
| 1691 | void SceneGraph::DrawDepthMap(const mat4& proj_view_matrix, const vec4* cull_planes, int num_cull_planes, SceneGraph::DepthType depth_type, SceneDrawType scene_draw_type) { |
| 1692 | if (g_debug_runtime_disable_scene_graph_draw_depth_map) { |
| 1693 | return; |
| 1694 | } |
| 1695 | |
| 1696 | Object::DrawType object_draw_type = Object::kUnknown; |
| 1697 | if (depth_type == SceneGraph::kDepthPrePass) { |
| 1698 | object_draw_type = Object::kDrawDepthOnly; |
| 1699 | } else if (depth_type == SceneGraph::kDepthShadow) { |
| 1700 | object_draw_type = Object::kDrawDepthNoAA; |
| 1701 | } else if (depth_type == SceneGraph::kDepthAllShadowCascades) { |
| 1702 | object_draw_type = Object::kDrawAllShadowCascades; |
| 1703 | } |
| 1704 | |
| 1705 | UpdateShaderSuffix(this, object_draw_type); |
| 1706 | |
| 1707 | { |
| 1708 | static object_list visible_objects_copy; |
| 1709 | visible_objects_copy = visible_objects_; |
| 1710 | PROFILER_ZONE(g_profiler_ctx, "Draw dynamic objects"); |
| 1711 | if (scene_draw_type == kStaticAndDynamic) { |
| 1712 | for (auto& it : visible_objects_copy) { |
| 1713 | Object& obj = *it; |
| 1714 | if (obj.enabled_ && obj.GetType() != _decal_object && obj.GetType() != _env_object) { |
| 1715 | obj.DrawDepthMap(proj_view_matrix, cull_planes, num_cull_planes, object_draw_type); |
| 1716 | } |
| 1717 | } |
| 1718 | } else { |
| 1719 | for (auto& it : visible_objects_copy) { |
| 1720 | Object& obj = *it; |
| 1721 | if (obj.enabled_ && obj.GetType() == _terrain_type) { |
| 1722 | obj.DrawDepthMap(proj_view_matrix, cull_planes, num_cull_planes, object_draw_type); |
| 1723 | } |
| 1724 | } |
| 1725 | } |
| 1726 | } |
| 1727 | |
| 1728 | if (!kUseShadowCache) { |
| 1729 | if (visible_objects_need_sort) { |
| 1730 | PROFILER_ENTER(g_profiler_ctx, "Sort visible objects"); |
| 1731 | g_static_mesh_draw_sort_entries = &visible_static_meshes_; |
| 1732 | std::sort(visible_static_mesh_indices_.begin(), visible_static_mesh_indices_.end(), StaticMeshDrawSortIndices); |
| 1733 | visible_objects_need_sort = false; |
| 1734 | PROFILER_LEAVE(g_profiler_ctx); |
| 1735 | } |
| 1736 | vec3 cam_pos = ActiveCameras::Get()->GetPos(); |
| 1737 | // List static meshes |
| 1738 | PROFILER_ENTER(g_profiler_ctx, "Draw env object batches (depth only)"); |
| 1739 | static std::vector<EnvObject*> static_meshes_to_draw; |
| 1740 | static_meshes_to_draw.clear(); |
| 1741 | static_meshes_to_draw.reserve(visible_static_meshes_.size()); |
| 1742 | PROFILER_ENTER(g_profiler_ctx, "List visible objects / frustum cull"); |
| 1743 | for (unsigned short index : visible_static_mesh_indices_) { |
| 1744 | EnvObject* eo = visible_static_meshes_[index]; |
| 1745 | if (!eo->transparent && eo->enabled_) { |
| 1746 | bool culled = false; |
| 1747 | for (int plane = 0; plane < num_cull_planes; ++plane) { |
| 1748 | if (dot(eo->sphere_center_, cull_planes[plane].xyz()) + |
no test coverage detected