3#include "Systems/ComponentSystem.h"
5#include "Components/Core/CameraComponent.h"
7#include "Services/TaskManager.h"
9#include "Utilities/FrustumClassification.h"
11#include "CullingData.h"
13#include "Rendering/Common.h"
15#include "Foundation/Collections/Pool.h"
16#include "Foundation/Geometry/BoundingBox.hpp"
17#include "Foundation/Geometry/Frustum.hpp"
24 struct EnvironmentComponent;
39 enum struct Flags : uint32_t {
44 Flags flags = Flags::None;
45 float depthBias = 0.f;
46 float depthSlopedBias = 0.f;
47 float depthBiasClamp = 0.f;
48 uint32_t multiViews = 0;
49 glm::ivec4 scissorRectangle{};
51 void setFlag(Flags flag) { flags = Flags(uint32_t(flags) | uint32_t(flag)); }
52 void unsetFlag(Flags flag) { flags = Flags(uint32_t(flags) & ~uint32_t(flag)); }
53 bool getFlag(Flags flag)
const {
return (uint32_t(flags) & uint32_t(flag)) != 0; }
77 void (*bindRenderTargetCallback)(
void* clientData) =
nullptr;
78 void* bindRenderTargetCallbackData =
nullptr;
81 LightingLayers lightingMask = LightingLayers::Default;
83 bool reflection =
false;
84 bool flipWindingOrder =
false;
85 bool useClearColor =
false;
88 glm::mat4 projectionMatrix;
90 glm::mat4 viewProjection;
91 glm::mat4 inverseViewMatrix;
92 glm::mat4 inverseViewProjectionMatrix;
93 glm::mat4 inverseProjectionMatrix;
94 glm::mat4 viewFromViewportMatrix;
96 glm::mat4 prevViewProjection;
98 glm::vec2 viewportSize;
99 glm::vec2 viewportOrigin;
100 glm::vec4 clearColor;
102 glm::uvec2 blueNoiseOffset;
104 Geometry::Frustum frustum;
105 Geometry::BoundingBox sceneBounds;
109 float nearDepthBounds = 0.f;
110 float farDepthBounds = 0.f;
111 float nearClipPlanes = 0.f;
112 float farClipPlanes = 0.f;
114 float nearDistance = 0.f;
115 float farDistance = 0.f;
116 float fieldOfView = 0.f;
117 float depthClamp = 0.f;
118 float discardThreshold = 0.f;
119 float keepThreshold = 0.f;
120 float exposure = 2.f;
122 uint32_t clientFlags = 0;
130 glm::mat4 rawViewProjection;
131 glm::mat4 rawViewCullMatrix;
133 std::shared_ptr<CullingData> cullingData;
135 RenderPass::ERenderPass renderPass = RenderPass::Main;
148 cullingData(MemBlockType::CullingData)
182 int nextRayPickId = 1;
The camera system computes CameraData for every CameraDataComponent in the engine.
void postRender(const Context *context)
Called by the renderer after all rendering is complete.
void setMainCamera(ComponentModel::ComponentHandle mainCamera)
const CameraData & getMainCameraData() const
Get the calculated CameraData of the main camera.
CameraComponent * getMainCamera() const
Get the main camera component.
ComponentHandle createComponent() override
bool updateClippingPlanes(Context *context, const CameraComponent &cameraComponent, bool secondPass)
Update near/far clipping plane calculations.
void updateProjection(Context *context, const CameraComponent &cameraComponent)
Update the projection matrix and derived matrices of a camera.
ComponentModel::ComponentHandle mainCamera
Main camera handle.
Context * context
Pointer to the Context instance the system lives in.
void postUpdate()
Perform post update logic in the system.
void update()
Updates the system state to that of the current frame.
Component system with parallel data per component stored in a pool similar to how the components them...
A Context instance contains all the services, systems and runtime components needed to use Cogs.
Base allocator implementation.
RenderLayers
Contains common render layers.
Contains all Cogs related functionality.
ComponentIndex SizeType
Type used to track the size of pools.
Pool used to store elements of ElementType.
Handle to a Component instance.
static ComponentHandle Empty()
Returns an empty, invalid handle. Will evaluate to false if tested against using operator bool().
ComponentType * resolveComponent() const
Contains data describing a Camera instance and its derived data structured such as matrix data and vi...
CameraData(const CameraData &other)=delete
Disabled copy constructor operator to avoid accidental copying when referencing.
CameraData()=default
Default constructs camera data.
glm::mat4 rawProjectionMatrix
Projection matrix that has not been adjusted by the renderer, and is thus appropriate for direct scre...
CameraData & operator=(const CameraData &other)=default
Assign operator must be enabled as Copying is done in FilterListTask.cpp & friends.
COGSCORE_DLL_API void updateHash()