Cogs.Core
CameraComponent.h
1#pragma once
2
3#include "Components/Core/RenderComponent.h"
4#include "Components/Core/LightComponent.h"
5
6#include "Resources/Resources.h"
7
8namespace Cogs
9{
10 namespace Core
11 {
13 enum class ProjectionMode
14 {
16 Perspective = 0,
19 };
20
21 enum class CameraFlags : uint32_t
22 {
24 None = 0,
26 EnableRender = 1 << 0,
28 EnablePicking = 1 << 1,
30 FlipY = 1 << 2,
32 OverrideClearColor = 1 << 3,
33 };
34
35 ENABLE_ENUM_FLAGS(CameraFlags);
36
43 {
44 public:
46 static void registerType();
47
49 bool supportsPicking() const { return (flags & CameraFlags::EnablePicking) != 0; }
50
54 CameraComponent() = default;
55
63 RenderLayers layerMask = RenderLayers::AllStandard;
64
71 LightingLayers lightingMask = LightingLayers::All;
72
76 int32_t stackOrder = 0;
77
81 float focalDistance = 1.0f;
82
86 float fieldOfView = glm::pi<float>() / 4.0f;
87
92 float orthoHeight = 100.0f;
93
97 float discardThreshold = 0.f;
98
99 /*
100 Keep objects with world bounds greater than threshold.
101 */
102 float keepThreshold = 1.0f;
103
107 glm::vec2 viewportOrigin = glm::vec2(0, 0);
108
112 glm::vec2 viewportSize = glm::vec2(100, 100);
113
115 glm::vec2 subsetMin = glm::vec2(0.f, 0.f);
116
118 glm::vec2 subsetMax = glm::vec2(1.f, 1.f);
119
121 glm::vec4 clearColor = glm::vec4(0.0f);
122
125 float nearDistance = 1.0f;
126
129 float farDistance = 1000.0f;
130
132 float nearPlaneLimit = 1.0f;
133
135 float farPlaneLimit = 10000000.0f;
136
138 float exposure = 1.f;
139
142
145
148
151
153 std::string renderPipeline;
154
156 std::vector<std::string> renderPipelineOptions;
157
160
163
165 uint32_t clientFlags = 0;
166 };
167 }
168}
169
170template<> inline Cogs::StringView getName<Cogs::Core::ProjectionMode>() { return "ProjectionMode"; }
171template<> inline Cogs::StringView getName<Cogs::Core::CameraFlags>() { return "CameraFlags"; }
172template<> inline Cogs::StringView getName<Cogs::Core::CameraComponent>() { return "CameraComponent"; }
Base class for Component instances.
Definition: Component.h:143
CameraFlags flags
Camera behavior flags.
float fieldOfView
Vertical field of view, given in radians.
uint32_t clientFlags
Application defined, camera specific flags passed to shaders.
float farPlaneLimit
Largest value allowed to adjust far plane to.
LightingLayers lightingMask
Lighting mask used to determine which lights are active for the current viewport.
glm::vec4 clearColor
Use the following colour to clear the render target before rendering.
bool enableClippingPlaneAdjustment
If automatic adjustment of the clipping planes should be performed to fit as much of the scene as pos...
glm::vec2 subsetMin
Subset of the frustum to view (for only rendering a subset of the view covered by the viewport),...
glm::vec2 viewportSize
Size of the viewport covered by this instance, given in pixels.
std::string renderPipeline
Render pipeline to apply when rendering to texture. Defaults to the built-in forward rendering pipeli...
TextureHandle resolveTarget
The texture to which the rendered output will be resolved. (Needs an offscreen renderTexture for this...
ProjectionMode projectionMode
The projection mode to use for the camera.
float focalDistance
Focal distance of the camera, given in scene units.
RenderLayers layerMask
Layer mask used to determine which RenderComponent instances should be visible in this cameras viewpo...
float nearPlaneLimit
Smallest value allowed to adjust near plane to.
TextureHandle renderTexture
The render texture to output the rendered scene from the camera to.
CameraComponent()=default
Constructs a camera with defaults set.
glm::vec2 subsetMax
Subset of the frustum to view (for only rendering a subset of the view covered by the viewport),...
std::vector< std::string > renderPipelineOptions
Extra options passed when creating the render pipeline,.
glm::vec2 viewportOrigin
Origin of the viewport covered by this instance, given in screen units from the lower left.
EntityPtr environment
Environment to use for rendering.
float exposure
Exposure factor for HDR rendering.
float orthoHeight
Height of the viewport in scene units when using orthographic projection.
int32_t stackOrder
Specifies the ordering of cameras when rendering to the same render target, lower numbers render befo...
static void registerType()
Register the type in the type system.
bool supportsPicking() const
Check if the camera supports use for ray picking.
float discardThreshold
Discard objects occupying less pixels than threshold.
Provides a weakly referenced view over the contents of a string.
Definition: StringView.h:24
std::shared_ptr< ComponentModel::Entity > EntityPtr
Smart pointer for Entity access.
Definition: EntityPtr.h:12
@ EnableRender
Renderable.
@ OverrideClearColor
Provide a clear colour for this camera to use.
@ FlipY
Flip the y-axis.
@ EnablePicking
Supports picking.
ProjectionMode
Defines projection modes for the camera.
@ Orthographic
Orthographic projection.
@ Perspective
Perspective projection.
RenderLayers
Contains common render layers.
Contains all Cogs related functionality.
Definition: FieldSetter.h:23
static const ResourceHandle_t NoHandle
Handle representing a default (or none if default not present) resource.