Skip to content

Commit

Permalink
Added some PBR texture packs for Terrain rendering.
Browse files Browse the repository at this point in the history
Licensed under the Creative Commons CC0 1.0 Universal License:
Source: https://ambientcg.com/
  • Loading branch information
MStachowicz committed Oct 12, 2024
1 parent 2a0b8cb commit c6c4d9d
Show file tree
Hide file tree
Showing 38 changed files with 54 additions and 4 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Grass/Color.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Grass/Normal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Gravel/Color.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Gravel/Normal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Ground/Color.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Ground/Norma.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Rock/Color.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Rock/Normal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Rock/Roughness.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Sand/Color.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Sand/Normal.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Sand/Roughness.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added source/Resources/Textures/PBR/Snow/Color.jpg
Binary file added source/Resources/Textures/PBR/Snow/Normal.jpg
Binary file added source/Resources/Textures/PBR/Snow/Roughness.jpg
52 changes: 50 additions & 2 deletions source/System/AssetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ namespace System
: m_texture_manager{}
, m_mesh_manager{}
, m_available_textures{}
, m_available_PBR_textures{}
, m_available_models{}
, m_cone{m_mesh_manager.insert(make_mesh(ShapeType::Cone))}
, m_cube{m_mesh_manager.insert(make_mesh(ShapeType::Cuboid))}
Expand All @@ -70,6 +71,22 @@ namespace System
m_available_textures.emplace_back(AvailableTexture{entry.path(), Data::Texture(entry.path())});
}
});
Utility::File::foreach_file(Config::Texture_PBR_Directory, [&](auto& entry)
{
// In this directory, parse each folder as a new PBR texture, using the name of the directory as the name of the texture.
if (entry.is_directory())
{
std::optional<std::filesystem::path> colour_path;
if (std::filesystem::exists(entry.path() / "colour.jpg")) colour_path = entry.path() / "colour.jpg";
else if (std::filesystem::exists(entry.path() / "color.jpg")) colour_path = entry.path() / "color.jpg";
else if (std::filesystem::exists(entry.path() / "colour.png")) colour_path = entry.path() / "colour.png";
else if (std::filesystem::exists(entry.path() / "color.png")) colour_path = entry.path() / "color.png";

if (colour_path)
m_available_PBR_textures.emplace_back(AvailableTexture{entry.path(), Data::Texture(*colour_path)});
}
});

Utility::File::foreach_file_recursive(Config::Model_Directory, [&](auto& entry)
{
if (entry.is_regular_file() && entry.path().has_extension() && entry.path().extension() == ".obj")
Expand Down Expand Up @@ -106,7 +123,9 @@ namespace System
ImGui::SetNextWindowSizeConstraints(min_window_size, display_size);

ImGui::Begin("Asset Browser", p_open);
{ImGui::SeparatorText("Textures");
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
if (ImGui::CollapsingHeader("Textures"))
{
// Calculate how many textures can fit into the window.
const ImVec2 window_size = ImGui::GetContentRegionAvail();
const int columns = std::max(1, (int)(window_size.x / (button_size.x + ImGui::GetStyle().ItemSpacing.x)));
Expand All @@ -123,7 +142,7 @@ namespace System

ImTextureID texture_id = (void*)(intptr_t)m_available_textures[i].thumbnail.m_GL_texture.handle();
if (ImGui::ImageButton(m_available_textures[i].path.filename().stem().string().c_str(),
texture_id, button_size))
texture_id, button_size))
{
LOG("Selected texture: {}", m_available_textures[i].path.string());
}
Expand All @@ -133,6 +152,35 @@ namespace System
ImGui::EndGroup();
}
}
ImGui::SetNextItemOpen(true, ImGuiCond_Once);
if (ImGui::CollapsingHeader("PBR Textures"))
{
// Calculate how many textures can fit into the window.
const ImVec2 window_size = ImGui::GetContentRegionAvail();
const int columns = std::max(1, (int)(window_size.x / (button_size.x + ImGui::GetStyle().ItemSpacing.x)));
const int rows = std::max(1, (int)(window_size.y / (button_size.y + ImGui::GetStyle().ItemSpacing.y)));
unsigned int i = 0;

for (int row = 0; row < rows; row++)
{
ImGui::BeginGroup();
for (int col = 0; col < columns; col++)
{
if (i >= m_available_PBR_textures.size())
break;

ImTextureID texture_id = (void*)(intptr_t)m_available_PBR_textures[i].thumbnail.m_GL_texture.handle();
if (ImGui::ImageButton(m_available_PBR_textures[i].path.filename().stem().string().c_str(),
texture_id, button_size))
{
LOG("Selected PBR texture: {}", m_available_PBR_textures[i].path.string());
}
ImGui::SameLine();
i++;
}
ImGui::EndGroup();
}
}
ImGui::End();
}
} // namespace System
5 changes: 3 additions & 2 deletions source/System/AssetManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ namespace System
MeshManager m_mesh_manager;

public:
std::vector<AvailableTexture> m_available_textures; // All the available texture files.
std::vector<std::filesystem::path> m_available_models; // All the available model files.
std::vector<AvailableTexture> m_available_textures; // All the available texture files.
std::vector<AvailableTexture> m_available_PBR_textures; // All the available PBR texture files.
std::vector<std::filesystem::path> m_available_models; // All the available model files.

AssetManager();

Expand Down
1 change: 1 addition & 0 deletions source/Utility/Config.hpp.in
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ namespace Config
inline const auto Scene_Save_Directory = std::filesystem::path(Source_Directory / "Scenes");
inline const auto GLSL_Shader_Directory = std::filesystem::path(Source_Directory / "source" / "OpenGL" / "GLSL");
inline const auto Texture_Directory = std::filesystem::path(Source_Directory / "source" / "Resources" / "Textures");
inline const auto Texture_PBR_Directory = std::filesystem::path(Source_Directory / "source" / "Resources" / "Textures" / "PBR");
inline const auto Model_Directory = std::filesystem::path(Source_Directory / "source" / "Resources" / "Models");

inline const char* OpenGL_Version_String = "${OPENGL_VERSION_STRING}";
Expand Down

0 comments on commit c6c4d9d

Please sign in to comment.