SGCT master (487fac4)
Simple Graphics Cluster Toolkit
Loading...
Searching...
No Matches
fisheye.h
Go to the documentation of this file.
1/*****************************************************************************************
2 * SGCT *
3 * Simple Graphics Cluster Toolkit *
4 * *
5 * Copyright (c) 2012-2026 *
6 * For conditions of distribution and use, see copyright notice in LICENSE.md *
7 ****************************************************************************************/
8
9#ifndef __SGCT__FISHEYE__H__
10#define __SGCT__FISHEYE__H__
11
12#include <sgct/sgctexports.h>
14
15#include <sgct/shaderprogram.h>
16#include <sgct/math.h>
17
18namespace sgct {
19
20namespace config { struct FisheyeProjection; }
21class BaseViewport;
22class User;
23class Window;
24
28class SGCT_EXPORT FisheyeProjection final : public NonLinearProjection {
29public:
30 enum class FisheyeMethod { FourFaceCube = 0, FiveFaceCube, SixFaceCube };
31
33 User& user);
35
39 void update(const vec2& size) const override;
40
44 void render(const BaseViewport& viewport, FrustumMode frustumMode) const override;
45
49 void renderCubemap(FrustumMode frustumMode) const override;
50
57 void setDomeDiameter(float diameter);
58
65 void setTilt(float angle);
66
72 void setFOV(float angle);
73
79 void setCropFactors(float left, float right, float bottom, float top);
80
86 void setOffset(vec3 offset) const;
87
93 void setBaseOffset(vec3 offset);
94
99 void setIgnoreAspectRatio(bool state);
100
101 void setKeepAspectRatio(bool state);
102
103private:
104 void initVBO() override;
105 void initViewports() override;
106 void initShaders() override;
107
108 float _fov;
109 float _tilt;
110 float _diameter;
111 float _cropLeft;
112 float _cropRight;
113 float _cropBottom;
114 float _cropTop;
115
116 bool _ignoreAspectRatio = false;
117 bool _keepAspectRatio;
118
119 mutable bool _isOffAxis = false;
120 mutable vec3 _offset = vec3{ 0.f, 0.f, 0.f };
121 vec3 _baseOffset = vec3{ 0.f, 0.f, 0.f };
122 mutable vec3 _totalOffset = vec3{ 0.f, 0.f, 0.f };
123
124 FisheyeMethod _method = FisheyeMethod::FourFaceCube;
125
126 // shader locations
127 struct {
128 int cubemap = -1;
129 int depthCubemap = -1;
130 int normalCubemap = -1;
131 int positionCubemap = -1;
132 int halfFov = -1;
133 int offset = -1;
134 int swapColor = -1;
135 int swapDepth = -1;
136 int swapNear = -1;
137 int swapFar = -1;
138 } _shaderLoc;
139 unsigned int _vao = 0;
140 unsigned int _vbo = 0;
141 ShaderProgram _shader;
142 ShaderProgram _depthCorrectionShader;
143};
144
145} // namespace sgct
146
147#endif // __SGCT__FISHEYE__H__
This class holds and manages viewportdata and calculates frustums.
Definition baseviewport.h:27
void setKeepAspectRatio(bool state)
void render(const BaseViewport &viewport, FrustumMode frustumMode) const override
Render the non-linear projection to currently bounded FBO.
void setCropFactors(float left, float right, float bottom, float top)
Set the fisheye crop values.
void renderCubemap(FrustumMode frustumMode) const override
Render the enabled faces of the cubemap.
FisheyeProjection(const config::FisheyeProjection &config, const Window &parent, User &user)
void setFOV(float angle)
Set the fisheye/dome field-of-view angle used in the fisheye renderer.
void update(const vec2 &size) const override
Update projection when aspect ratio changes for the viewport.
void setDomeDiameter(float diameter)
Set the dome diameter used in the fisheye renderer (used for the viewplane distance calculations).
void setOffset(vec3 offset) const
Set fisheye offset to render offaxis.
void setIgnoreAspectRatio(bool state)
Ignore the framebuffer aspect ratio to allow non-circular fisheye.
void setTilt(float angle)
Set the fisheye/dome tilt angle used in the fisheye renderer.
FisheyeMethod
Definition fisheye.h:30
void setBaseOffset(vec3 offset)
Set fisheye base offset to render offaxis.
NonLinearProjection(const Window &parent)
Helper class for setting user variables.
Definition user.h:24
Definition window.h:46
Definition clustermanager.h:22
Definition actions.h:16
FrustumMode
Definition definitions.h:23
Definition config.h:204
Definition math.h:47
Definition math.h:56