We got exr loading

This commit is contained in:
2026-01-22 02:04:11 +01:00
parent a5b26f3bdd
commit 41ed926409
23 changed files with 529 additions and 283 deletions

Binary file not shown.

Binary file not shown.

View File

@@ -25,20 +25,13 @@ void LightKeeper::customInit() {
const float aspectRatio = static_cast<float>(m_params.renderSize.x) / static_cast<float>(m_params.renderSize.y);
camera.setAspectRatio(aspectRatio);
auto file = AssetFS::GetInstance().ReadBytes("engine://assetfstest.txt");
std::string fileStr(file.begin(), file.end());
spdlog::info("Read from assetfstest.txt: {}", fileStr);
testMesh.name = "Test Mesh";
// testMesh.vertices = vertices;
// testMesh.indices = indices;
auto list_of_models = ModelLoader::LoadGLTF_CPUMeshes_MergedPerMesh(AssetFS::GetInstance().GetFullPath("game://kitty.glb").generic_string());
testMesh = list_of_models[0];
testMeshID = meshCache.addMesh(gfxDevice, testMesh);
spdlog::info("TestMesh uploaded with id: {}", testMeshID);
const auto testimgpath = AssetFS::GetInstance().GetFullPath("game://kitty.png");
auto testimgID = gfxDevice.loadImageFromFile(testimgpath);
auto testimgID = gfxDevice.loadImageFromFile(AssetFS::GetInstance().GetFullPath("game://kitty.png"));
spdlog::info("Test image loaded with id: {}", testimgID);
testMaterialID = materialCache.addMaterial(gfxDevice, {
.baseColor = glm::vec3(1.f),
@@ -46,8 +39,6 @@ void LightKeeper::customInit() {
});
spdlog::info("Test material created with id: {}", testMaterialID);
renderer.setSkyboxTexture(testimgID);
camera.SetRotation(glm::radians(glm::vec2(90.f, 0.f)));
auto& scene = SceneManager::GetInstance().CreateScene("Main");
@@ -55,7 +46,26 @@ void LightKeeper::customInit() {
auto testCube = std::make_shared<GameObject>("TestCube");
auto meshComp = testCube->AddComponent<MeshRendererComponent>();
meshComp->SetMeshID(testMeshID);
meshComp->SetMaterialID(testMaterialID);
meshComp->SetMaterialID(testMaterialID);const int count = 100;
const float radius = 5.0f;
const float orbitRadius = 5.0f;
for (int i = 0; i < count; ++i) {
auto childCube = std::make_shared<GameObject>(fmt::format("ChildCube{}", i));
auto childMeshComp = childCube->AddComponent<MeshRendererComponent>();
childMeshComp->SetMeshID(testMeshID);
childMeshComp->SetMaterialID(testMaterialID);
childCube->GetTransform().SetWorldScale(glm::vec3(0.1f));
// Add orbit + self spin
auto orbit = childCube->AddComponent<OrbitAndSpin>(orbitRadius, glm::vec3(0.0f));
orbit->Randomize(1337u + (uint32_t)i); // stable random per index
scene.Add(childCube);
}
testCube->AddComponent<Spinner>(glm::vec3(0, 1, 0), glm::radians(10.0f)); // spin around Y, rad/sec
//rotate 180 around X axis
testCube->GetTransform().SetLocalRotation(glm::quat(glm::vec3(glm::radians(180.0f), 0.0f, 0.0f)));
@@ -65,46 +75,25 @@ void LightKeeper::customInit() {
globeRoot->AddComponent<Spinner>(glm::vec3(0, 1, 0), 1.0f); // spin around Y, rad/sec
scene.Add(globeRoot);
// const int count = 100;
// const float radius = 5.0f;
//
// const float orbitRadius = 5.0f;
//
// for (int i = 0; i < count; ++i) {
// auto childCube = std::make_shared<GameObject>(fmt::format("ChildCube{}", i));
//
// auto childMeshComp = childCube->AddComponent<MeshRendererComponent>();
// childMeshComp->SetMeshID(testMeshID);
// childMeshComp->SetMaterialID(testMaterialID);
//
// childCube->GetTransform().SetWorldScale(glm::vec3(0.1f));
//
// // Add orbit + self spin
// auto orbit = childCube->AddComponent<OrbitAndSpin>(orbitRadius, glm::vec3(0.0f));
// orbit->Randomize(1337u + (uint32_t)i); // stable random per index
//
// scene.Add(childCube);
// }
// testCube->AddComponent<Rotator>(10, 5);
scene.Add(testCube);
// const auto skyboxID = AssetFS::GetInstance().GetFullPath("engine://textures/skybox.jpg");
const auto skyboxID = AssetFS::GetInstance().GetFullPath("engine://textures/test-skybox.png");
auto skyboxIDs = gfxDevice.loadImageFromFile(testimgpath);
// const auto skyboxID = AssetFS::GetInstance().GetFullPath("engine://textures/mars.jpg");
const auto skyboxID = AssetFS::GetInstance().GetCookedPathForFile("game://starmap_2020_4k.exr");
//
// const auto skyboxID = AssetFS::GetInstance().GetFullPath("engine://textures/test-skybox.png");
//
const auto vertShaderPath = AssetFS::GetInstance().GetCookedPathForFile("engine://shaders/cubemap.vert");
const auto fragShaderPath = AssetFS::GetInstance().GetCookedPathForFile("engine://shaders/cubemap.frag");
//
skyboxCubemap = std::make_unique<CubeMap>();
skyboxCubemap->LoadCubeMap(skyboxID.generic_string());
skyboxCubemap->InitCubemapPipeline(vertShaderPath.generic_string(), fragShaderPath.generic_string());
skyboxCubemap->CreateCubeMap();
renderer.setSkyboxTexture(skyboxCubemap->GetCubeMapImageID());
// skyboxCubemap->CreateCubeMap();
}
void LightKeeper::customUpdate(float dt) {