@@ -106,7 +106,7 @@ void NextRendererGameInstance::BeforeSceneRebuild(std::vector<std::shared_ptr<As
106106 boxModelId_ = static_cast <uint32_t >(models.size () - 1 );
107107
108108 matIds_.clear ();
109-
109+
110110 MatPreparedForAdd.push_back ({Assets::Material::Lambertian (glm::vec3 (1 ,1 ,1 ))});
111111 materials.push_back (MatPreparedForAdd.back ());matIds_.push_back (uint32_t (materials.size () - 1 ));
112112 MatPreparedForAdd.push_back ({Assets::Material::Metallic (glm::vec3 (0.5 ,0.5 ,0.5 ), 0 .4f )});
@@ -132,6 +132,12 @@ void NextRendererGameInstance::OnPreConfigUI()
132132
133133bool NextRendererGameInstance::OnRenderUI ()
134134{
135+ if (GOption->AgentValidation && !agentValidationCaptured_ && GetEngine ().GetTotalFrames () >= 120 )
136+ {
137+ RequestScreenshot (false , " agent_validation" );
138+ agentValidationCaptured_ = true ;
139+ }
140+
135141 if (isTakingScreenshot_)
136142 {
137143 return true ;
@@ -188,6 +194,36 @@ void NextRendererGameInstance::OnInitUI()
188194 }
189195}
190196
197+ void NextRendererGameInstance::RequestScreenshot (bool openFolder, const std::string& tag)
198+ {
199+ if (isTakingScreenshot_)
200+ {
201+ return ;
202+ }
203+
204+ std::string folderPath = Utilities::FileHelper::GetPlatformFilePath (" screenshots" );
205+ Utilities::FileHelper::EnsureDirectoryExists (folderPath);
206+
207+ auto now = std::chrono::system_clock::now ();
208+ std::time_t in_time_t = std::chrono::system_clock::to_time_t (now);
209+ std::tm* tm_ptr = std::localtime (&in_time_t );
210+ std::string timestamp = fmt::format (" {:%Y-%m-%d_%H-%M-%S}" , *tm_ptr);
211+ std::string suffix = tag.empty () ? " " : " _" + tag;
212+ std::string filename = (std::filesystem::path (folderPath) / (timestamp + suffix)).string ();
213+
214+ isTakingScreenshot_ = true ;
215+
216+ GetEngine ().AddTimerTask (0.2 , [this , filename, folderPath, openFolder]() {
217+ ScreenShot::SaveSwapChainToFile (&GetEngine ().GetRenderer (), filename, 0 , 0 , 0 , 0 );
218+ if (openFolder)
219+ {
220+ NextRenderer::OSCommand (folderPath.c_str ());
221+ }
222+ isTakingScreenshot_ = false ;
223+ return true ;
224+ });
225+ }
226+
191227bool NextRendererGameInstance::OverrideRenderCamera (Assets::Camera& outRenderCamera) const
192228{
193229 outRenderCamera.ModelView = modelViewController_.ModelView ();
@@ -365,12 +401,51 @@ void NextRendererGameInstance::DrawSettings()
365401
366402 if ( ImGui::CollapsingHeader (LOCTEXT (" Renderer" ), ImGuiTreeNodeFlags_DefaultOpen) )
367403 {
368- std::vector<const char *> renderers {" PathTracing" , " SoftTracing" , " SoftModern" , " VoxelTracing" };
404+ struct RendererOption
405+ {
406+ const char * label;
407+ Vulkan::ERendererType type;
408+ };
409+ const RendererOption kRendererOptions [] = {
410+ {" SoftTracing" , Vulkan::ERT_ModernDeferred},
411+ {" SoftModern" , Vulkan::ERT_LegacyDeferred},
412+ {" VoxelTracing" , Vulkan::ERT_VoxelTracing},
413+ {" PathTracing" , Vulkan::ERT_PathTracing},
414+ };
415+ const bool supportsRayTracing = GetEngine ().GetRenderer ().SupportsRayTracing ();
416+ const int rendererOptionCount = supportsRayTracing
417+ ? static_cast <int >(std::size (kRendererOptions ))
418+ : static_cast <int >(std::size (kRendererOptions )) - 1 ;
419+
420+ int currentRendererIndex = 0 ;
421+ bool rendererFound = false ;
422+ for (int index = 0 ; index < rendererOptionCount; ++index)
423+ {
424+ if (kRendererOptions [index].type == static_cast <Vulkan::ERendererType>(userSetting.RendererType ))
425+ {
426+ currentRendererIndex = index;
427+ rendererFound = true ;
428+ break ;
429+ }
430+ }
431+ if (!rendererFound)
432+ {
433+ userSetting.RendererType = static_cast <int32_t >(kRendererOptions [0 ].type );
434+ }
369435
370436 ImGui::Text (" %s" , LOCTEXT (" Renderer" ));
371437
372438 ImGui::PushItemWidth (-1 );
373- ImGui::Combo (" ##RendererList" , &userSetting.RendererType , renderers.data (), static_cast <int >(renderers.size ()));
439+ auto renderersGetter = [](void * data, int index, const char ** outText)
440+ {
441+ const auto * options = static_cast <const RendererOption*>(data);
442+ *outText = options[index].label ;
443+ return true ;
444+ };
445+ if (ImGui::Combo (" ##RendererList" , ¤tRendererIndex, renderersGetter, const_cast <RendererOption*>(kRendererOptions ), rendererOptionCount))
446+ {
447+ userSetting.RendererType = static_cast <int32_t >(kRendererOptions [currentRendererIndex].type );
448+ }
374449 ImGui::PopItemWidth ();
375450 ImGui::NewLine ();
376451 }
@@ -645,23 +720,7 @@ void NextRendererGameInstance::DrawTitleBar()
645720 ImGui::SameLine ();
646721 if (ImGui::Button (ICON_FA_CAMERA , ImVec2 (TitlebarSize, TitlebarSize)))
647722 {
648- std::string folderPath = Utilities::FileHelper::GetPlatformFilePath (" screenshots" );
649- Utilities::FileHelper::EnsureDirectoryExists (folderPath);
650-
651- auto now = std::chrono::system_clock::now ();
652- std::time_t in_time_t = std::chrono::system_clock::to_time_t (now);
653- std::tm* tm_ptr = std::localtime (&in_time_t );
654- std::string timestamp = fmt::format (" {:%Y-%m-%d_%H-%M-%S}" , *tm_ptr);
655- std::string filename = (std::filesystem::path (folderPath) / timestamp).string ();
656-
657- isTakingScreenshot_ = true ;
658-
659- GetEngine ().AddTimerTask (0.2 , [this , filename, folderPath]() {
660- ScreenShot::SaveSwapChainToFile (&GetEngine ().GetRenderer (), filename, 0 , 0 , 0 , 0 );
661- NextRenderer::OSCommand (folderPath.c_str ());
662- isTakingScreenshot_ = false ;
663- return true ;
664- });
723+ RequestScreenshot (true , " " );
665724 }
666725 BUTTON_TOOLTIP (LOCTEXT (" Take a Screenshot into the screenshots folder" ))
667726 ImGui::SameLine ();
0 commit comments