1 #ifndef INLCUDE_AL_PERPROJECTION_HPP
2 #define INLCUDE_AL_PERPROJECTION_HPP
9 #include "al/graphics/al_FBO.hpp"
10 #include "al/graphics/al_Graphics.hpp"
11 #include "al/graphics/al_Shader.hpp"
12 #include "al/graphics/al_Shapes.hpp"
13 #include "al/graphics/al_Texture.hpp"
14 #include "al/graphics/al_VAOMesh.hpp"
15 #include "al/graphics/al_Viewpoint.hpp"
16 #include "al/math/al_Matrix4.hpp"
25 Mat4f get_cube_mat(
int face);
34 bhlw viewport_for_cubemap_face(
int idx);
38 static int const sampletex_binding_point = 10;
39 static int const textures_bidning_point = 11;
42 inline std::string perprojection_samplevert() {
45 uniform mat4 al_ModelViewMatrix;
46 uniform mat4 al_ProjectionMatrix;
48 layout (location = 0) in vec3 position;
49 layout (location = 2) in vec2 texcoord;
54 gl_Position = al_ProjectionMatrix * al_ModelViewMatrix * vec4(position, 1.0);
60 inline std::string perprojection_samplefrag() {
63 uniform sampler2D sample_tex;
64 uniform sampler2D color_tex;
66 uniform float tanFovDiv2;
70 vec4 sample = texture(sample_tex, texcoord_);
71 vec3 dir = sample.rgb;
72 vec3 p_coord = (R * vec4(dir, 0)).xyz;
73 p_coord.xy /= -p_coord.z;
74 p_coord.xy /= tanFovDiv2;
75 vec3 sampled_color = texture(color_tex, p_coord.xy / 2.0 + 0.5).rgb;
76 frag_color = vec4(sampled_color * sample.a, 1.0);
90 std::vector<Vec4f> warp_and_blend_data;
95 std::vector<ProjectionViewport> viewports;
96 void load_allosphere_calibration(
const char *path,
const char *hostname);
97 void load_desktop_mode_calibration();
103 std::shared_ptr<Texture> texture[2];
104 std::shared_ptr<Texture> warp_texture;
105 Mat4f pc_matrix, p_matrix, r_matrix;
114 std::vector<ProjectionInfo> projection_infos_;
122 bool calibration_loaded =
false;
123 bool did_begin =
false;
125 int current_projection = 0;
135 void update_resolution(
int resolution);
145 void load_calibration_data(
const char *path,
const char *hostname);
149 void load_and_init_as_desktop_config(
const al::Lens &lens);
155 void updateLens(
const Lens &lens);
163 int num_projections() {
return projection_infos_.size(); }
166 void set_projection(
int index);
168 Mat4f get_r_mat_for_current_projection() {
169 return projection_infos_[current_projection].r_matrix;
172 Mat4f get_p_mat_for_current_projection() {
173 return projection_infos_[current_projection].p_matrix;
182 void composite(Graphics &g,
int eye = 0);
184 void composite_desktop(Graphics &g,
int eye = 0);
Frame buffer object class.
Interface for loading fonts and rendering text.
A local coordinate frame.
Render buffer object class.
VAOMesh classStores gpu objects as shared pointer to that this class can be copied for moved this is ...
Viewpoint within a scene.
T angle(const Vec< N, T > &a, const Vec< N, T > &b)
Returns angle, in interval [0, pi], between two vectors.
Mat< 4, float > Mat4f
float 4x4 matrix