360{
361 namespace fs = std::filesystem;
362
363 fs::path path(filepath);
364
365 if (path.is_absolute() || fs::exists(filepath)) {
366 return path;
367 }
368
369 std::vector<std::string> search_paths = {
370 Core::SHADER_BUILD_OUTPUT_DIR,
371 Core::SHADER_INSTALL_DIR,
372 Core::SHADER_SOURCE_DIR,
373 "./shaders",
374 "../shaders",
375 "data/shaders",
376 "./data/shaders",
377 "../data/shaders"
378 };
379
380 if (std::string_view(Core::SHADER_EXAMPLE_DIR).length() > 0) {
381 search_paths.emplace_back(Core::SHADER_EXAMPLE_DIR);
382 }
383
384#ifdef MAYAFLUX_PROJECT_SHADER_DIR
385 search_paths.emplace_back(MAYAFLUX_PROJECT_SHADER_DIR);
386#endif
387
388 for (const auto& search_path : search_paths) {
389 fs::path full_path = fs::path(search_path) / filepath;
390 if (fs::exists(full_path)) {
391 return full_path;
392 }
393 }
394
395 return std::nullopt;
396}