feat: add spot light shadows with a tilled buffer

This commit is contained in:
2026-10-18 12:56:52 +02:00
parent 4bd99b25d1
commit 65a7310b56
19 changed files with 519 additions and 122 deletions
-1
View File
@@ -32,7 +32,6 @@ public:
private:
void setupSkybox();
void drawCrosshair();
void drawViewModeHint();
void updateViewMode();
[[nodiscard]] CameraComponent* getSceneCamera() const;
[[nodiscard]] Camera& getViewCamera();
-20
View File
@@ -103,25 +103,6 @@ void LightKeeper::updateViewMode()
}
}
void LightKeeper::drawViewModeHint()
{
if (isPlayerViewActive() || mainScene.playerController == nullptr) {
return;
}
constexpr std::string_view hint = "Free camera RMB look WASD / Q E move F5 play";
constexpr float hintSize = 18.0f;
const VkExtent3D extent = renderer.getDrawImage().extent;
const glm::vec2 hintExtent = hudFont.MeasureText(hint, hintSize);
Renderer2D::GetInstance().DrawText(
hudFont,
hint,
{16.0f, static_cast<float>(extent.height) - hintExtent.y - 12.0f},
hintSize,
TextStyle{.color = {1.0f, 1.0f, 1.0f, 0.85f}, .outline = 2.0f, .outlineColor = {0.0f, 0.0f, 0.0f, 0.6f}});
}
void LightKeeper::drawCrosshair()
{
if (!isPlayerViewActive()) {
@@ -185,7 +166,6 @@ void LightKeeper::customDraw()
renderer.beginDrawing(gfxDevice);
submitDebugDraws();
drawCrosshair();
drawViewModeHint();
if (isPlayerViewActive())
{
+18
View File
@@ -60,6 +60,23 @@ namespace {
sun->SetCastShadows(true);
}
void CreateHelmetSpotlight(Scene& scene)
{
const glm::vec3 position{2.0f, 3.5f, -2.5f};
const glm::vec3 target{2.0f, GroundHeight, 0.0f};
GameObject* spotObj = scene.CreateGameObject("HelmetSpotlight");
spotObj->GetTransform().SetWorldPosition(position);
spotObj->GetTransform().SetWorldRotation(glm::quatLookAt(glm::normalize(target - position), glm::vec3{0.0f, 1.0f, 0.0f}));
auto* spot = spotObj->AddComponent<LightComponent>(LightType::Spot);
spot->SetColor(glm::vec3{1.0f, 0.85f, 0.7f});
spot->SetIntensity(25.0f);
spot->SetRange(12.0f);
spot->SetConeAngles(glm::radians(20.0f), glm::radians(30.0f));
spot->SetCastShadows(true);
}
void CreateGround(Scene& scene, GfxDevice& gfxDevice, RenderResources& resources)
{
const auto planeModel = AssetManager::GetInstance().LoadModel("game://plane.glb", StaticModelOptions());
@@ -443,6 +460,7 @@ MainSceneObjects BuildMainScene(Scene& scene, GfxDevice& gfxDevice, RenderResour
CreateGround(scene, gfxDevice, resources);
CreateParkourCourse(scene, gfxDevice, resources);
CreateFlightHelmet(scene, gfxDevice, resources);
CreateHelmetSpotlight(scene);
CreateTree(scene, gfxDevice, resources);
// CreateCapybara(scene, gfxDevice, resources);
CreateTriggerZone(scene);