2011-10-25 05:03:10 +00:00
|
|
|
//
|
|
|
|
|
// KRSettings.h
|
2021-08-16 16:35:36 -07:00
|
|
|
// Kraken Engine
|
2011-10-25 05:03:10 +00:00
|
|
|
//
|
2025-08-31 14:11:20 -07:00
|
|
|
// Copyright 2025 Kearwood Gilbert. All rights reserved.
|
2011-10-25 06:16:47 +00:00
|
|
|
//
|
|
|
|
|
// Redistribution and use in source and binary forms, with or without modification, are
|
|
|
|
|
// permitted provided that the following conditions are met:
|
|
|
|
|
//
|
|
|
|
|
// 1. Redistributions of source code must retain the above copyright notice, this list of
|
|
|
|
|
// conditions and the following disclaimer.
|
|
|
|
|
//
|
|
|
|
|
// 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
|
|
|
|
// of conditions and the following disclaimer in the documentation and/or other materials
|
|
|
|
|
// provided with the distribution.
|
|
|
|
|
//
|
|
|
|
|
// THIS SOFTWARE IS PROVIDED BY KEARWOOD GILBERT ''AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
|
|
|
// WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
|
|
|
|
// FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL KEARWOOD GILBERT OR
|
|
|
|
|
// CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
|
|
|
|
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
|
|
|
|
// SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
|
|
|
|
// ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
|
|
|
// NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
|
|
|
// ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
|
//
|
|
|
|
|
// The views and conclusions contained in the software and documentation are those of the
|
|
|
|
|
// authors and should not be interpreted as representing official policies, either expressed
|
|
|
|
|
// or implied, of Kearwood Gilbert.
|
2011-10-25 05:03:10 +00:00
|
|
|
//
|
|
|
|
|
|
2022-07-07 22:51:16 -07:00
|
|
|
#pragma once
|
2011-10-25 05:03:10 +00:00
|
|
|
|
2013-01-11 03:21:19 +00:00
|
|
|
#include "KREngine-common.h"
|
2012-03-15 23:58:37 +00:00
|
|
|
|
2019-12-01 15:49:49 -08:00
|
|
|
#include "KRPipeline.h"
|
2013-01-11 03:21:19 +00:00
|
|
|
#include "KRContextObject.h"
|
2024-08-17 23:41:58 -07:00
|
|
|
#include "resources/texture/KRTexture.h"
|
2025-11-11 14:29:26 -08:00
|
|
|
#include "resources/texture/KRTextureBinding.h"
|
2013-01-11 03:21:19 +00:00
|
|
|
#include "KRContext.h"
|
|
|
|
|
#include "KRViewport.h"
|
|
|
|
|
#include "KRRenderSettings.h"
|
2024-08-17 23:12:20 -07:00
|
|
|
#include "resources/mesh/KRMeshManager.h"
|
2012-08-15 21:26:06 +00:00
|
|
|
|
2013-03-22 17:17:12 -07:00
|
|
|
#define KRAKEN_FPS_AVERAGE_FRAME_COUNT 30
|
|
|
|
|
|
2013-01-09 22:37:23 +00:00
|
|
|
class KRModel;
|
2012-08-15 21:26:06 +00:00
|
|
|
class KRScene;
|
2012-10-26 01:17:35 +00:00
|
|
|
class KRViewport;
|
2022-03-27 22:37:15 -07:00
|
|
|
class KRSurface;
|
2025-04-10 01:09:36 -07:00
|
|
|
class KRRenderGraph;
|
2012-08-15 21:26:06 +00:00
|
|
|
|
2022-08-08 01:07:26 -07:00
|
|
|
class KRCamera : public KRNode
|
|
|
|
|
{
|
2011-10-25 05:03:10 +00:00
|
|
|
public:
|
2022-08-08 01:07:26 -07:00
|
|
|
static void InitNodeInfo(KrNodeInfo* nodeInfo);
|
|
|
|
|
KRCamera(KRScene& scene, std::string name);
|
|
|
|
|
virtual ~KRCamera();
|
|
|
|
|
|
2022-09-23 23:43:06 -07:00
|
|
|
KrResult update(const KrNodeInfo* nodeInfo) override;
|
|
|
|
|
|
2025-04-10 01:09:36 -07:00
|
|
|
void renderFrame(VkCommandBuffer& commandBuffer, KRSurface& compositeSurface, KRRenderGraph& renderGraph);
|
2022-08-08 01:07:26 -07:00
|
|
|
|
2025-11-13 22:52:43 -08:00
|
|
|
void preStream(const KRViewport& viewport) final;
|
|
|
|
|
void render(KRNode::RenderInfo& ri) final;
|
2025-04-10 00:35:39 -07:00
|
|
|
|
2022-08-08 01:07:26 -07:00
|
|
|
KRRenderSettings settings;
|
|
|
|
|
|
2025-04-10 00:35:39 -07:00
|
|
|
KRViewport* getViewport();
|
2022-08-08 01:07:26 -07:00
|
|
|
|
|
|
|
|
|
2023-11-23 21:46:12 -08:00
|
|
|
virtual std::string getElementName() override;
|
|
|
|
|
virtual tinyxml2::XMLElement* saveXML(tinyxml2::XMLNode* parent) override;
|
|
|
|
|
virtual void loadXML(tinyxml2::XMLElement* e) override;
|
2022-08-08 01:07:26 -07:00
|
|
|
|
|
|
|
|
std::string getDebugText();
|
|
|
|
|
|
|
|
|
|
void flushSkybox(); // this will delete the skybox and cause the camera to reload a new skybox based on the settings
|
|
|
|
|
|
2023-08-05 21:14:53 -07:00
|
|
|
void setFadeColor(const hydra::Vector4& fade_color);
|
|
|
|
|
hydra::Vector4 getFadeColor();
|
2022-08-08 01:07:26 -07:00
|
|
|
|
|
|
|
|
void setSkyBox(const std::string& skyBox);
|
|
|
|
|
const std::string getSkyBox() const;
|
2013-06-15 09:56:19 -07:00
|
|
|
|
2025-11-11 13:05:23 -08:00
|
|
|
protected:
|
|
|
|
|
bool getShaderValue(ShaderValue value, hydra::Vector4* output) const override;
|
|
|
|
|
|
2013-06-15 09:56:19 -07:00
|
|
|
private:
|
2022-09-21 17:59:23 -07:00
|
|
|
void createBuffers(int renderBufferWidth, int renderBufferHeight);
|
2022-08-08 01:07:26 -07:00
|
|
|
|
2022-09-21 17:59:23 -07:00
|
|
|
int volumetricBufferWidth, volumetricBufferHeight;
|
2022-08-08 01:07:26 -07:00
|
|
|
|
2022-09-21 17:59:23 -07:00
|
|
|
int compositeFramebuffer, compositeDepthTexture, compositeColorTexture;
|
|
|
|
|
int lightAccumulationBuffer, lightAccumulationTexture;
|
2022-08-08 01:07:26 -07:00
|
|
|
|
|
|
|
|
|
2022-09-21 17:59:23 -07:00
|
|
|
int volumetricLightAccumulationBuffer, volumetricLightAccumulationTexture;
|
2022-08-08 01:07:26 -07:00
|
|
|
|
2025-04-10 00:35:39 -07:00
|
|
|
void renderPost(RenderInfo& ri);
|
|
|
|
|
void renderDebug(RenderInfo& ri);
|
2022-08-08 01:07:26 -07:00
|
|
|
|
|
|
|
|
void destroyBuffers();
|
|
|
|
|
|
2022-09-26 22:06:09 -07:00
|
|
|
KrSurfaceHandle m_surfaceHandle;
|
2025-11-11 14:29:26 -08:00
|
|
|
|
|
|
|
|
KRTextureBinding m_skyBox;
|
2022-08-08 01:07:26 -07:00
|
|
|
KRViewport m_viewport;
|
|
|
|
|
|
|
|
|
|
float m_particlesAbsoluteTime;
|
|
|
|
|
|
2023-08-05 21:14:53 -07:00
|
|
|
hydra::Vector4 m_fade_color;
|
2022-08-08 01:07:26 -07:00
|
|
|
|
|
|
|
|
typedef struct
|
|
|
|
|
{
|
|
|
|
|
float x;
|
|
|
|
|
float y;
|
|
|
|
|
float z;
|
|
|
|
|
float u;
|
|
|
|
|
float v;
|
|
|
|
|
} DebugTextVertexData;
|
|
|
|
|
|
2023-08-05 16:37:16 -07:00
|
|
|
mimir::Block m_debug_text_vertices;
|
2022-08-08 01:07:26 -07:00
|
|
|
KRMeshManager::KRVBOData m_debug_text_vbo_data;
|
|
|
|
|
|
|
|
|
|
uint64_t m_last_frame_start;
|
|
|
|
|
int m_frame_times[KRAKEN_FPS_AVERAGE_FRAME_COUNT];
|
|
|
|
|
int m_frame_times_filled;
|
2011-10-25 05:03:10 +00:00
|
|
|
};
|