mirror of
				https://github.com/zenorogue/hyperrogue.git
				synced 2025-10-30 21:42:59 +00:00 
			
		
		
		
	fixed ODS; non-isotropic ODS
This commit is contained in:
		
							
								
								
									
										20
									
								
								drawing.cpp
									
									
									
									
									
								
							
							
						
						
									
										20
									
								
								drawing.cpp
									
									
									
									
									
								
							| @@ -1170,9 +1170,14 @@ EX namespace ods { | |||||||
|        |        | ||||||
|       ld phi = atan2(y, x) - atan2(y0, x0) + M_PI; |       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 delta; | ||||||
|       ld p = z / sin(theta) / t * cos_auto(vid.ipd / 2); |       if(euclid) delta = hypot(y0, z); | ||||||
|       ld delta = (p > 1) ? 13 : (p < -1) ? -13 : atanh(p); |       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(euclid || hyperbolic) phi -= M_PI; | ||||||
|       if(hyperbolic) delta = -delta; |       if(hyperbolic) delta = -delta; | ||||||
| @@ -1221,7 +1226,14 @@ EX namespace ods { | |||||||
|  |  | ||||||
|       for(int j=0; j<3; j++) { |       for(int j=0; j<3; j++) { | ||||||
|         hyperpoint o = p->V * glhr::gltopoint((*p->tab)[p->offset+i+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; |           goto next_i; | ||||||
|         } |         } | ||||||
|        |        | ||||||
|   | |||||||
							
								
								
									
										17
									
								
								shaders.cpp
									
									
									
									
									
								
							
							
						
						
									
										17
									
								
								shaders.cpp
									
									
									
									
									
								
							| @@ -28,6 +28,7 @@ constexpr flagtype SF_HALFPLANE    = 8192; | |||||||
| constexpr flagtype SF_ORIENT       = 16384; | constexpr flagtype SF_ORIENT       = 16384; | ||||||
| constexpr flagtype SF_BOX          = 32768; | constexpr flagtype SF_BOX          = 32768; | ||||||
| constexpr flagtype SF_ZFOG         = 65536; | constexpr flagtype SF_ZFOG         = 65536; | ||||||
|  | constexpr flagtype SF_ODSBOX       = (1<<17); | ||||||
| #endif | #endif | ||||||
|  |  | ||||||
| #if HDR | #if HDR | ||||||
| @@ -98,7 +99,12 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) { | |||||||
|    |    | ||||||
|   bool skip_t = false; |   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 += "mediump vec4 pos = aPosition; pos[3] = 1.0;\n"; | ||||||
|     vmain += "pos = uMV * pos;\n"; |     vmain += "pos = uMV * pos;\n"; | ||||||
|     if(shader_flags & GF_LEVELS) vmain += "vPos = 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)); |   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) { |   auto ortho = [&] (ld x, ld y) { | ||||||
|     glhr::glmatrix M = glhr::ortho(x, y, 1); |     glhr::glmatrix M = glhr::ortho(x, y, 1); | ||||||
| @@ -371,7 +378,7 @@ void display_data::set_projection(int ed) { | |||||||
|     glhr::projection_multiply(M); |     glhr::projection_multiply(M); | ||||||
|     if(nisot::local_perspective_used() && (shader_flags & SF_BOX)) |     if(nisot::local_perspective_used() && (shader_flags & SF_BOX)) | ||||||
|       glhr::projection_multiply(glhr::tmtogl_transpose(NLP)); |       glhr::projection_multiply(glhr::tmtogl_transpose(NLP)); | ||||||
|     if(ed) { |     if(ed && vid.stereo_mode != sODS) { | ||||||
|       glhr::glmatrix m = glhr::id; |       glhr::glmatrix m = glhr::id; | ||||||
|       m[2][0] -= ed; |       m[2][0] -= ed; | ||||||
|       glhr::projection_multiply(m); |       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); |   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_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) { |   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::frustum(current_display->tanfov, current_display->tanfov * cd->ysize / cd->xsize)); | ||||||
|     glhr::projection_multiply(glhr::scale(1, -1, -1)); |     glhr::projection_multiply(glhr::scale(1, -1, -1)); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Zeno Rogue
					Zeno Rogue