1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-20 12:20:01 +00:00

glhr:: shader-side band now ignores depth

This commit is contained in:
Zeno Rogue 2018-11-18 17:27:27 +01:00
parent 8e2727882e
commit 50a86d1e88
6 changed files with 23 additions and 5 deletions

View File

@ -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);

View File

@ -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

View File

@ -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);

View File

@ -1056,6 +1056,7 @@ struct videopar {
ld ipd;
ld lr_eyewidth, anaglyph_eyewidth;
ld fov;
bool consider_shader_projection;
};
extern videopar vid;

View File

@ -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;

View File

@ -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));",