From 1fcf58e17a2271e940f69e0152912e8c5948039c Mon Sep 17 00:00:00 2001 From: ? Date: Mon, 25 Feb 2019 04:04:26 +0100 Subject: [PATCH] 3D:: shader variants for R3 and S3 --- basegraph.cpp | 10 +++++++--- hyper.h | 2 +- hypgraph.cpp | 2 +- shaders.cpp | 14 ++++++++++---- 4 files changed, 19 insertions(+), 9 deletions(-) diff --git a/basegraph.cpp b/basegraph.cpp index e629999e..bea99ccc 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -218,8 +218,12 @@ void display_data::set_projection(int ed, bool apply_models) { shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::band; if(pmodel == mdHalfplane && hyperbolic && apply_models) shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::halfplane; - if(DIM == 3) - shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::standard3; + if(DIM == 3 && hyperbolic) + shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::standardH3; + if(DIM == 3 && euclid) + shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::standardR3; + if(DIM == 3 && sphere) + shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::standardS3; } start_projection(ed, shaderside_projection); @@ -258,7 +262,7 @@ void display_data::set_projection(int ed, bool apply_models) { current_display->scrdist_text = cd->ysize * sc / 2; - if(glhr::new_shader_projection == glhr::shader_projection::standard3) { + if(glhr::new_shader_projection == glhr::shader_projection::standardH3) { glhr::fog_max(1/binary::btrange); } diff --git a/hyper.h b/hyper.h index 7fbb1110..ef32b753 100644 --- a/hyper.h +++ b/hyper.h @@ -3801,7 +3801,7 @@ namespace glhr { const GLfloat* as_array() const { return a[0]; } }; - enum class shader_projection { standard, band, halfplane, standard3, MAX }; + enum class shader_projection { standard, band, halfplane, standardH3, standardR3, standardS3, MAX }; extern shader_projection new_shader_projection; diff --git a/hypgraph.cpp b/hypgraph.cpp index ce1d5405..e13b5caf 100644 --- a/hypgraph.cpp +++ b/hypgraph.cpp @@ -1594,7 +1594,7 @@ bool do_draw(cell *c) { bool do_draw(cell *c, const transmatrix& T) { if(DIM == 3) { if(hyperbolic && T[DIM][DIM] > binary::btrange_cosh) return false; - if(euclid && hypot_d(tC0(T), 3) > 10) return false; + if(euclid && hypot_d(tC0(T), 3) > 7) return false; setdist(c, 7, c); return true; } diff --git a/shaders.cpp b/shaders.cpp index f25babcf..d8a5ce0f 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -491,7 +491,11 @@ void init() { bool mps = j != 0; bool band = (sp == shader_projection::band); bool hp = (sp == shader_projection::halfplane); - bool s3 = (sp == shader_projection::standard3); + bool sh3 = (sp == shader_projection::standardH3); + bool sr3 = (sp == shader_projection::standardR3); + bool ss3 = (sp == shader_projection::standardS3); + + bool s3 = (sh3 || sr3 || ss3); programs[i][j] = new GLprogram(stringbuilder( @@ -555,10 +559,12 @@ void init() { hp, "t.x /= -rads; t.y /= -rads; t.z = 1.0; t[3] = 1.0;", s3, "vec4 t = uMV * aPosition;", - s3, "vColor.xyz = vColor.xyz * (1.0 - acosh(t[3]) / uFog);", - s3, "t[3] = 1.0;", + sh3, "vColor.xyz = vColor.xyz * (1.0 - acosh(t[3]) / uFog);", + sr3, "vColor.xyz = vColor.xyz * (1.0 - sqrt(t[0]*t[0] + t[1]*t[1] + t[2]*t[2]) / 7.);", + ss3, "vColor.xyz = vColor.xyz * (1.0 - acos(t[3]) / 1.6);", + sh3 || sr3,"t[3] = 1.0;", - band || hp,"gl_Position = uP * t;", + band || hp || s3,"gl_Position = uP * t;", 1, "}"), stringbuilder(