1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-27 14:37:16 +00:00

fixed ODS; non-isotropic ODS

This commit is contained in:
Zeno Rogue 2020-02-26 01:27:04 +01:00
parent 00e436f0e2
commit 5d9fdd83a8
2 changed files with 30 additions and 7 deletions

View File

@ -1170,9 +1170,14 @@ EX namespace ods {
ld phi = atan2(y, x) - atan2(y0, x0) + M_PI;
// ld delta = euclid ? hypot(y0,z) : atan2_auto(z / sin(theta), t / cos_auto(vid.ipd/2));
ld p = z / sin(theta) / t * cos_auto(vid.ipd / 2);
ld delta = (p > 1) ? 13 : (p < -1) ? -13 : atanh(p);
ld delta;
if(euclid) delta = hypot(y0, z);
else if(sphere) delta = atan2_auto(z / sin(theta), t / cos_auto(vid.ipd/2));
else {
// ld delta = euclid ? hypot(y0,z) : atan2_auto(z / sin(theta), t / cos_auto(vid.ipd/2));
ld p = z / sin(theta) / t * cos_auto(vid.ipd / 2);
delta = (p > 1) ? 13 : (p < -1) ? -13 : atanh(p);
}
if(euclid || hyperbolic) phi -= M_PI;
if(hyperbolic) delta = -delta;
@ -1221,7 +1226,14 @@ EX namespace ods {
for(int j=0; j<3; j++) {
hyperpoint o = p->V * glhr::gltopoint((*p->tab)[p->offset+i+j]);
if(!project(o, h[j], h[j+3], global_projection == -1))
if(nonisotropic || prod) {
o = lp_apply(inverse_exp(o, iTable, false));
o[3] = 1;
dynamicval<eGeometry> g(geometry, gEuclid);
if(!project(o, h[j], h[j+3], global_projection == -1))
goto next_i;
}
else if(!project(o, h[j], h[j+3], global_projection == -1))
goto next_i;
}

View File

@ -28,6 +28,7 @@ constexpr flagtype SF_HALFPLANE = 8192;
constexpr flagtype SF_ORIENT = 16384;
constexpr flagtype SF_BOX = 32768;
constexpr flagtype SF_ZFOG = 65536;
constexpr flagtype SF_ODSBOX = (1<<17);
#endif
#if HDR
@ -98,7 +99,12 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
bool skip_t = false;
if(pmodel == mdPixel) {
if(vid.stereo_mode == sODS) {
shader_flags |= SF_DIRECT | SF_ODSBOX;
vmain += "// this is ODS shader\n";
distfun = "aPosition.z";
}
else if(pmodel == mdPixel) {
vmain += "mediump vec4 pos = aPosition; pos[3] = 1.0;\n";
vmain += "pos = uMV * pos;\n";
if(shader_flags & GF_LEVELS) vmain += "vPos = pos;\n";
@ -355,7 +361,8 @@ void display_data::set_projection(int ed) {
if(vid.stretch != 1 && (shader_flags & SF_DIRECT)) glhr::projection_multiply(glhr::scale(vid.stretch, 1, 1));
eyewidth_translate(ed);
if(vid.stereo_mode != sODS)
eyewidth_translate(ed);
auto ortho = [&] (ld x, ld y) {
glhr::glmatrix M = glhr::ortho(x, y, 1);
@ -371,7 +378,7 @@ void display_data::set_projection(int ed) {
glhr::projection_multiply(M);
if(nisot::local_perspective_used() && (shader_flags & SF_BOX))
glhr::projection_multiply(glhr::tmtogl_transpose(NLP));
if(ed) {
if(ed && vid.stereo_mode != sODS) {
glhr::glmatrix m = glhr::id;
m[2][0] -= ed;
glhr::projection_multiply(m);
@ -381,6 +388,10 @@ void display_data::set_projection(int ed) {
if(shader_flags & SF_PIXELS) ortho(cd->xsize/2, -cd->ysize/2);
else if(shader_flags & SF_BOX) ortho(cd->xsize/current_display->radius/2, -cd->ysize/current_display->radius/2);
else if(shader_flags & SF_ODSBOX) {
ortho(M_PI, M_PI);
glhr::fog_max(1/sightranges[geometry], darkena(backcolor, 0, 0xFF));
}
else if(shader_flags & SF_PERS3) {
glhr::projection_multiply(glhr::frustum(current_display->tanfov, current_display->tanfov * cd->ysize / cd->xsize));
glhr::projection_multiply(glhr::scale(1, -1, -1));