We got a skybox
This commit is contained in:
@@ -47,3 +47,5 @@ add_custom_target(_internal_cook_game_assets ALL
|
||||
DEPENDS TheChef
|
||||
)
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -4,6 +4,8 @@
|
||||
#include <destrum/App.h>
|
||||
#include <destrum/Scene/SceneManager.h>
|
||||
|
||||
#include "destrum/Graphics/Resources/Cubemap.h"
|
||||
|
||||
class LightKeeper final : public App {
|
||||
public:
|
||||
LightKeeper();
|
||||
@@ -24,6 +26,8 @@ private:
|
||||
CPUMesh testMesh{};
|
||||
MeshID testMeshID;
|
||||
MaterialID testMaterialID;
|
||||
|
||||
std::unique_ptr<CubeMap> skyboxCubemap;
|
||||
};
|
||||
|
||||
#endif //LIGHTKEEPER_H
|
||||
|
||||
@@ -46,6 +46,8 @@ 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");
|
||||
@@ -63,31 +65,46 @@ 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);
|
||||
}
|
||||
// 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 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) {
|
||||
|
||||
Reference in New Issue
Block a user