From 47f8da71925d48dd74d3c33314a38e05d55f2f9a Mon Sep 17 00:00:00 2001 From: David Allemang Date: Sat, 23 May 2020 11:03:36 -0400 Subject: [PATCH 1/2] fix issue where some projected 5d wires cross over w=4 --- vis/shaders/solid.fs.glsl | 2 +- vis/src/main.cpp | 108 ++++++++++++-------------------------- 2 files changed, 35 insertions(+), 75 deletions(-) diff --git a/vis/shaders/solid.fs.glsl b/vis/shaders/solid.fs.glsl index 232d04a..11b9312 100644 --- a/vis/shaders/solid.fs.glsl +++ b/vis/shaders/solid.fs.glsl @@ -2,7 +2,7 @@ layout(location=2) uniform vec3 col; -layout(location=0) in vec3 pos; +layout(location=0) in vec4 pos; layout(location=2) in vec3 normal; out vec4 color; diff --git a/vis/src/main.cpp b/vis/src/main.cpp index 246b4c9..aed550a 100644 --- a/vis/src/main.cpp +++ b/vis/src/main.cpp @@ -30,7 +30,7 @@ struct Matrices { glm::mat4 view; Matrices(const glm::mat4 &proj, const glm::mat4 &view) - : proj(proj), view(view) { + : proj(proj), view(view) { } }; @@ -130,11 +130,11 @@ struct SliceProp : public Prop { template static SliceProp build( - const tc::Group &g, - const C &coords, - vec3 color, - T all_sg_gens, - const std::vector> &exclude + const tc::Group &g, + const C &coords, + vec3 color, + T all_sg_gens, + const std::vector> &exclude ) { SliceProp res(color); @@ -149,11 +149,11 @@ struct SliceProp : public Prop { template struct SliceRenderer : public Renderer { cgl::pgm::vert defer = cgl::pgm::vert::file( - "shaders/slice/deferred.vs.glsl"); + "shaders/slice/deferred.vs.glsl"); cgl::pgm::geom slice = cgl::pgm::geom::file( - "shaders/slice/slice.gm.glsl"); + "shaders/slice/slice.gm.glsl"); cgl::pgm::frag solid = cgl::pgm::frag::file( - "shaders/solid.fs.glsl"); + "shaders/solid.fs.glsl"); cgl::pipeline pipe; @@ -207,52 +207,6 @@ struct DirectRenderer : public Renderer { } }; -//struct WireframeRenderer : public DirectRenderer<2> { -// WireframeRenderer() : DirectRenderer<2>() { -// cgl::pgm::vert direct_stereo = cgl::pgm::vert::file( -// "shaders/direct-ortho.vs.glsl"); -// cgl::pgm::frag solid = cgl::pgm::frag::file( -// "shaders/solid.fs.glsl"); -// -// glProgramUniform3f(solid, 2, .3f, .3f, .3f); -// -// this->pipe.stage(direct_stereo); -// this->pipe.stage(solid); -// } -//}; -// -//struct WireframeStereoRenderer : public WireframeRenderer { -// WireframeStereoRenderer() : WireframeRenderer() { -// cgl::pgm::vert direct_stereo = cgl::pgm::vert::file( -// "shaders/direct-stereo.vs.glsl"); -// cgl::pgm::frag solid = cgl::pgm::frag::file( -// "shaders/solid.fs.glsl"); -// -// glProgramUniform3f(solid, 2, .3f, .3f, .4f); -// -// this->pipe.stage(direct_stereo); -// this->pipe.stage(solid); -// } -//}; -// -//struct WireframeStereoCurveRenderer : public WireframeStereoRenderer { -// WireframeStereoCurveRenderer() : WireframeStereoRenderer() { -// cgl::pgm::vert direct_stereo = cgl::pgm::vert::file( -// "shaders/direct-stereo.vs.glsl"); -// cgl::pgm::geom curve = cgl::pgm::geom::file( -// "shaders/curve-stereo.gm.glsl" -// ); -// cgl::pgm::frag solid = cgl::pgm::frag::file( -// "shaders/solid.fs.glsl"); -// -// glProgramUniform3f(solid, 2, .4f, .3f, .3f); -// -// this->pipe.stage(direct_stereo); -// this->pipe.stage(curve); -// this->pipe.stage(solid); -// } -//}; - struct WireframeProp : public Prop<2> { vec3 color; @@ -264,12 +218,12 @@ struct WireframeProp : public Prop<2> { template static WireframeProp build(const tc::Group &g, - const C &coords, - bool curve, - bool ortho, - vec3 color, - T all_sg_gens, - const std::vector> &exclude + const C &coords, + bool curve, + bool ortho, + vec3 color, + T all_sg_gens, + const std::vector> &exclude ) { WireframeProp res(color); @@ -320,6 +274,8 @@ void run(const std::string &config_file, GLFWwindow *window) { state.dimension = scene["dimension"].as(); + const float NORM_SCALE = 0.8; // to keep things from crossing above w=1 after being projected down from 5d -> 4d. + for (const auto &group_info : scene["groups"]) { auto symbol = group_info["symbol"].as>(); auto group = tc::schlafli(symbol); @@ -335,15 +291,17 @@ void run(const std::string &config_file, GLFWwindow *window) { exclude = slice_info["exclude"].as>>(); } + root = root * NORM_SCALE; + if (slice_info["subgroups"].IsDefined()) { auto subgroups = slice_info["subgroups"].as>>(); sRen.props.push_back(SliceProp<4>::build( - group, root, color, subgroups, exclude + group, root, color, subgroups, exclude )); } else { auto combos = Combos(gens, 3); sRen.props.push_back(SliceProp<4>::build( - group, root, color, combos, exclude + group, root, color, combos, exclude )); } } @@ -361,24 +319,26 @@ void run(const std::string &config_file, GLFWwindow *window) { exclude = wire_info["exclude"].as>>(); } + root = root * NORM_SCALE; + if (wire_info["subgroups"].IsDefined()) { auto subgroups = wire_info["subgroups"].as>>(); if (ortho && curve) { wocRen.props.push_back(WireframeProp::build( - group, root, curve, ortho, color, subgroups, exclude + group, root, curve, ortho, color, subgroups, exclude )); } else if (ortho) { woRen.props.push_back(WireframeProp::build( - group, root, curve, ortho, color, subgroups, exclude + group, root, curve, ortho, color, subgroups, exclude )); } else if (curve) { wscRen.props.push_back(WireframeProp::build( - group, root, curve, ortho, color, subgroups, exclude + group, root, curve, ortho, color, subgroups, exclude )); } else { wsRen.props.push_back(WireframeProp::build( - group, root, curve, ortho, color, subgroups, exclude + group, root, curve, ortho, color, subgroups, exclude )); } } else { @@ -386,19 +346,19 @@ void run(const std::string &config_file, GLFWwindow *window) { if (ortho && curve) { wocRen.props.push_back(WireframeProp::build( - group, root, curve, ortho, color, combos, exclude + group, root, curve, ortho, color, combos, exclude )); } else if (ortho) { woRen.props.push_back(WireframeProp::build( - group, root, curve, ortho, color, combos, exclude + group, root, curve, ortho, color, combos, exclude )); } else if (curve) { wscRen.props.push_back(WireframeProp::build( - group, root, curve, ortho, color, combos, exclude + group, root, curve, ortho, color, combos, exclude )); } else { wsRen.props.push_back(WireframeProp::build( - group, root, curve, ortho, color, combos, exclude + group, root, curve, ortho, color, combos, exclude )); } } @@ -450,9 +410,9 @@ int main(int argc, char *argv[]) { // glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); auto window = glfwCreateWindow( - 1920, 1080, - "Coset Visualization", - nullptr, nullptr); + 1920, 1080, + "Coset Visualization", + nullptr, nullptr); if (!window) { std::cerr << "Failed to create window" << std::endl; From d16693189e36e8a454f1dbe57e827f326ffeefeb Mon Sep 17 00:00:00 2001 From: David Allemang Date: Sat, 23 May 2020 11:04:23 -0400 Subject: [PATCH 2/2] tweak presets to be larger, add f4 and h4 examples with wireframes. --- vis/presets/b_3_ortho.yaml | 4 ++-- vis/presets/b_3_stereo.yaml | 4 ++-- vis/presets/b_4_ortho.yaml | 4 ++-- vis/presets/b_4_stereo.yaml | 4 ++-- vis/presets/b_4_stereo_exclude.yaml | 4 ++-- vis/presets/b_4_stereo_exclude_nowire.yaml | 2 +- vis/presets/b_4_stereo_exclude_thick.yaml | 2 +- vis/presets/default.yaml | 4 ++-- vis/presets/f_4_stereo.yaml | 12 ++++++++++++ vis/presets/h_4_stereo.yaml | 10 ++++++++++ vis/presets/h_4_stereo_exclude_thick.yaml | 2 +- 11 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 vis/presets/f_4_stereo.yaml create mode 100644 vis/presets/h_4_stereo.yaml diff --git a/vis/presets/b_3_ortho.yaml b/vis/presets/b_3_ortho.yaml index 4cb3ef8..ebc1e9e 100644 --- a/vis/presets/b_3_ortho.yaml +++ b/vis/presets/b_3_ortho.yaml @@ -2,9 +2,9 @@ dimension: 3 groups: - symbol: [4, 3] slices: - - root: [0.85, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.9, 0.9, 0.9] wires: - - root: [0.85, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.3, 0.3, 0.3] ortho: true diff --git a/vis/presets/b_3_stereo.yaml b/vis/presets/b_3_stereo.yaml index bacee32..83e674f 100644 --- a/vis/presets/b_3_stereo.yaml +++ b/vis/presets/b_3_stereo.yaml @@ -2,9 +2,9 @@ dimension: 3 groups: - symbol: [4, 3] slices: - - root: [0.85, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.9, 0.9, 0.9] wires: - - root: [0.85, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.3, 0.3, 0.3] ortho: false diff --git a/vis/presets/b_4_ortho.yaml b/vis/presets/b_4_ortho.yaml index 5308a40..cf39667 100644 --- a/vis/presets/b_4_ortho.yaml +++ b/vis/presets/b_4_ortho.yaml @@ -2,9 +2,9 @@ dimension: 4 groups: - symbol: [4, 3, 3] slices: - - root: [0.80, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.9, 0.9, 0.9] wires: - - root: [0.80, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.3, 0.3, 0.3] ortho: true diff --git a/vis/presets/b_4_stereo.yaml b/vis/presets/b_4_stereo.yaml index cce76af..df92302 100644 --- a/vis/presets/b_4_stereo.yaml +++ b/vis/presets/b_4_stereo.yaml @@ -2,9 +2,9 @@ dimension: 4 groups: - symbol: [4, 3, 3] slices: - - root: [0.80, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.9, 0.9, 0.9] wires: - - root: [0.80, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.3, 0.3, 0.3] ortho: false diff --git a/vis/presets/b_4_stereo_exclude.yaml b/vis/presets/b_4_stereo_exclude.yaml index 45b858e..7273ed0 100644 --- a/vis/presets/b_4_stereo_exclude.yaml +++ b/vis/presets/b_4_stereo_exclude.yaml @@ -2,11 +2,11 @@ dimension: 4 groups: - symbol: [4, 3, 3] slices: - - root: [0.80, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.9, 0.9, 0.9] exclude: - [0, 1, 2] wires: - - root: [0.80, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.3, 0.3, 0.3] ortho: false diff --git a/vis/presets/b_4_stereo_exclude_nowire.yaml b/vis/presets/b_4_stereo_exclude_nowire.yaml index 8eecff0..7dc9cab 100644 --- a/vis/presets/b_4_stereo_exclude_nowire.yaml +++ b/vis/presets/b_4_stereo_exclude_nowire.yaml @@ -2,7 +2,7 @@ dimension: 4 groups: - symbol: [4, 3, 3] slices: - - root: [0.80, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.9, 0.9, 0.9] exclude: - [0, 1, 2] diff --git a/vis/presets/b_4_stereo_exclude_thick.yaml b/vis/presets/b_4_stereo_exclude_thick.yaml index a4f85e4..bbab448 100644 --- a/vis/presets/b_4_stereo_exclude_thick.yaml +++ b/vis/presets/b_4_stereo_exclude_thick.yaml @@ -2,7 +2,7 @@ dimension: 5 groups: - symbol: [4, 3, 3, 2] slices: - - root: [0.80, 0.09, 0.09, 0.09, 0.09] + - root: [0.90, 0.09, 0.09, 0.09, 0.09] color: [0.9, 0.9, 0.9] exclude: - [0, 1, 2] diff --git a/vis/presets/default.yaml b/vis/presets/default.yaml index 283a401..df92302 100644 --- a/vis/presets/default.yaml +++ b/vis/presets/default.yaml @@ -2,9 +2,9 @@ dimension: 4 groups: - symbol: [4, 3, 3] slices: - - root: [0.85, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.9, 0.9, 0.9] wires: - - root: [0.85, 0.09, 0.09, 0.09, 0.01] + - root: [0.90, 0.09, 0.09, 0.09, 0.01] color: [0.3, 0.3, 0.3] ortho: false diff --git a/vis/presets/f_4_stereo.yaml b/vis/presets/f_4_stereo.yaml new file mode 100644 index 0000000..4e4421e --- /dev/null +++ b/vis/presets/f_4_stereo.yaml @@ -0,0 +1,12 @@ +dimension: 4 +groups: + - symbol: [3, 4, 3, 2] + slices: + - root: [1.00, 0.10, 0.10, 0.10, 0.05] + color: [1.0, 1.0, 1.0] + exclude: + - [0, 1, 2] + wires: + - root: [1.00, 0.10, 0.10, 0.10, 0.05] + color: [1.0, 1.0, 1.0] + ortho: false diff --git a/vis/presets/h_4_stereo.yaml b/vis/presets/h_4_stereo.yaml new file mode 100644 index 0000000..274a2ee --- /dev/null +++ b/vis/presets/h_4_stereo.yaml @@ -0,0 +1,10 @@ +dimension: 4 +groups: + - symbol: [5, 3, 3] + slices: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.9, 0.9, 0.9] + wires: + - root: [0.90, 0.09, 0.09, 0.09, 0.01] + color: [0.3, 0.3, 0.3] + ortho: false diff --git a/vis/presets/h_4_stereo_exclude_thick.yaml b/vis/presets/h_4_stereo_exclude_thick.yaml index 0f689fb..817745f 100644 --- a/vis/presets/h_4_stereo_exclude_thick.yaml +++ b/vis/presets/h_4_stereo_exclude_thick.yaml @@ -2,7 +2,7 @@ dimension: 5 groups: - symbol: [5, 3, 3, 2] slices: - - root: [0.80, 0.09, 0.09, 0.09, 0.09] + - root: [0.90, 0.09, 0.09, 0.09, 0.09] color: [0.9, 0.9, 0.9] exclude: - [0, 1, 2]