diff --git a/basegraph.cpp b/basegraph.cpp index 4ee3ed22..56343fa9 100644 --- a/basegraph.cpp +++ b/basegraph.cpp @@ -204,10 +204,12 @@ void display_data::set_projection(int ed, bool apply_models) { shaderside_projection = false; glhr::new_shader_projection = glhr::shader_projection::standard; - if(pmodel == mdDisk && !spherespecial && !(hyperbolic && vid.alpha <= -1)) - shaderside_projection = true; - if(pmodel == mdBand && hyperbolic && apply_models && !inHighQual) - shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::band; + if(vid.consider_shader_projection) { + if(pmodel == mdDisk && !spherespecial && !(hyperbolic && vid.alpha <= -1)) + shaderside_projection = true; + if(pmodel == mdBand && hyperbolic && apply_models && !inHighQual) + shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::band; + } start_projection(ed, shaderside_projection); diff --git a/config.cpp b/config.cpp index cffc19d5..2452fe37 100644 --- a/config.cpp +++ b/config.cpp @@ -325,6 +325,8 @@ void initConfig() { addsaver(conformal::formula, "formula"); addsaverenum(conformal::basic_model, "basic model"); + addsaver(vid.consider_shader_projection, "shader-projection", true); + #if CAP_SHMUP shmup::initConfig(); #endif diff --git a/conformal.cpp b/conformal.cpp index 56805637..d284c707 100644 --- a/conformal.cpp +++ b/conformal.cpp @@ -836,6 +836,11 @@ namespace conformal { dialog::addSelItem(XLAT("vertical stretch"), fts3(vid.stretch), 's'); + dialog::addBoolItem(XLAT("use GPU to compute projections"), vid.consider_shader_projection, 'G'); + if(vid.consider_shader_projection && !shaderside_projection) + dialog::lastItem().value = XLAT("N/A"); + dialog::add_action([] { vid.consider_shader_projection = !vid.consider_shader_projection; }); + menuitem_sightrange('R'); dialog::addBreak(100); diff --git a/hyper.h b/hyper.h index 19140255..1da74171 100644 --- a/hyper.h +++ b/hyper.h @@ -1056,6 +1056,7 @@ struct videopar { ld ipd; ld lr_eyewidth, anaglyph_eyewidth; ld fov; + bool consider_shader_projection; }; extern videopar vid; diff --git a/polygons.cpp b/polygons.cpp index 146c8655..82f4c3f6 100644 --- a/polygons.cpp +++ b/polygons.cpp @@ -475,7 +475,7 @@ void glapplymatrix(const transmatrix& V) { } mat[12] = 0; mat[13] = 0; - mat[14] = GLfloat(vid.alpha); + mat[14] = (glhr::current_shader_projection == glhr::shader_projection::standard) ? GLfloat(vid.alpha) : 0; mat[15] = 1; if(vid.stretch != 1) mat[1] *= vid.stretch, mat[5] *= vid.stretch, mat[9] *= vid.stretch, mat[13] *= vid.stretch; diff --git a/shaders.cpp b/shaders.cpp index 2568eaf0..03cc4cdb 100644 --- a/shaders.cpp +++ b/shaders.cpp @@ -521,6 +521,10 @@ void init() { 1, " return log(sqrt(1.0 + x*x) + x);", 1, " }", + 1, "float zlevel(vec4 h) {", + 1, " return (h[2] < 0.0 ? -1.0 : 1.0) * sqrt(h[2]*h[2] - h[0]*h[0] - h[1]*h[1]);", + 1, " }", + 1, "void main() {", texture, "vTexCoord = aTexture;", varcol, "vColor = aColor;", @@ -529,6 +533,10 @@ void init() { !mps, "gl_Position = uMVP * aPosition;", mps&&!band,"gl_Position = uP * (uMV * aPosition);", band, "vec4 t = uMV * aPosition;", + + band, "float zlev = zlevel(t);", + band, "t /= zlev;", + band, "float ty = asinh(t.y);", band, "float tx = asinh(t.x / cosh(ty));", band, "ty = 2.0 * atan(tanh(ty/2.0));",