From 0c34e9fd34a9f20aa795dbc6c266ef9762666214 Mon Sep 17 00:00:00 2001 From: Zeno Rogue Date: Sun, 7 Jan 2024 09:13:31 +0100 Subject: [PATCH] 'cylidrical' stereo mode --- config.cpp | 3 ++- graph.cpp | 2 +- hyper.h | 2 +- shaders.cpp | 11 +++++++++++ 4 files changed, 15 insertions(+), 3 deletions(-) diff --git a/config.cpp b/config.cpp index e546d085..c3b2b1b8 100644 --- a/config.cpp +++ b/config.cpp @@ -1385,7 +1385,8 @@ EX void initConfig() { {"ODS", "for rendering 360° VR videos (implemented only in raycaster and some other parts)"}, {"Panini", "Projection believed to be used by Italian painters. Allows very high FOV angles while rendering more straight lines as straight than the stereographic projection."}, {"stereographic", "Stereographic projection allows very high FOV angles."}, - {"equirectangular", "for rendering 360° videos (implemented only in raycaster)"} + {"equirectangular", "for rendering 360° videos (implemented only in raycaster)"}, + {"cylindrical", "full vertical (not implemented in raycaster)"} }, "stereo/high-FOV mode", 'm') ->set_reaction(reset_all_shaders); diff --git a/graph.cpp b/graph.cpp index 2d7609e2..ab6aff13 100644 --- a/graph.cpp +++ b/graph.cpp @@ -4119,7 +4119,7 @@ EX ld threshold, xyz_threshold; EX bool clip_checked = false; EX bool other_stereo_mode() { - return among(vid.stereo_mode, sODS, sPanini, sStereographic, sEquirectangular); + return vid.stereo_mode != sOFF; } void make_clipping_planes() { diff --git a/hyper.h b/hyper.h index 8fbbea2f..c04163c3 100644 --- a/hyper.h +++ b/hyper.h @@ -250,7 +250,7 @@ struct charstyle { bool lefthanded; }; -enum eStereo { sOFF, sAnaglyph, sLR, sODS, sPanini, sStereographic, sEquirectangular }; +enum eStereo { sOFF, sAnaglyph, sLR, sODS, sPanini, sStereographic, sEquirectangular, sCylindrical }; enum eModel : int; diff --git a/shaders.cpp b/shaders.cpp index 31f73db7..f4d705b7 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -82,6 +82,12 @@ EX string panini_shader() { "t.w = 1.;\n"; } +EX string cylindrical_shader() { + return + "t /= t.w;\n" + "t.y = atan2(t.y, length(t.xz)) * length(t.xz) * 2. / PI;\n"; + } + EX string stereo_shader() { return "t.w += 1.; t *= 2. / t.w; t.w -= 1.;\n" @@ -521,6 +527,11 @@ shared_ptr write_shader(flagtype shader_flags) { vmain += panini_shader(); shader_flags |= SF_ORIENT; } + else if((shader_flags & SF_PERS3) && vid.stereo_mode == sCylindrical && !vrhr::rendering_eye()) { + vmain += "t = uPP * t;", vsh += "uniform mediump mat4 uPP;"; + vmain += cylindrical_shader(); + shader_flags |= SF_ORIENT; + } else if((shader_flags & SF_PERS3) && vid.stereo_mode == sStereographic && !vrhr::rendering_eye()) { vmain += "t = uPP * t;", vsh += "uniform mediump mat4 uPP;"; vmain += stereo_shader();