ray:: stereo modes
This commit is contained in:
parent
838d6a583a
commit
928e369977
12
drawing.cpp
12
drawing.cpp
|
@ -1882,6 +1882,11 @@ EX void draw_main() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
if(ray::in_use && !ray::comparison_mode) {
|
||||||
|
ray::cast();
|
||||||
|
reset_projection();
|
||||||
|
}
|
||||||
|
|
||||||
for(auto& ptd: ptds) if(ptd->prio == PPR::OUTCIRCLE)
|
for(auto& ptd: ptds) if(ptd->prio == PPR::OUTCIRCLE)
|
||||||
ptd->draw();
|
ptd->draw();
|
||||||
|
|
||||||
|
@ -1892,6 +1897,13 @@ EX void draw_main() {
|
||||||
ptd->draw();
|
ptd->draw();
|
||||||
}
|
}
|
||||||
glflush();
|
glflush();
|
||||||
|
|
||||||
|
if(ray::in_use && ray::comparison_mode) {
|
||||||
|
glDepthFunc(GL_LEQUAL);
|
||||||
|
glClearDepth(1.0f);
|
||||||
|
glClear(GL_DEPTH_BUFFER_BIT);
|
||||||
|
ray::cast();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1027,6 +1027,8 @@ void geometry_information::make_floor_textures_here() {
|
||||||
gv.emplace_back(+1, +1, 1, 1, 1);
|
gv.emplace_back(+1, +1, 1, 1, 1);
|
||||||
gv.emplace_back(-1, +1, 1, 1, 1);
|
gv.emplace_back(-1, +1, 1, 1, 1);
|
||||||
|
|
||||||
|
dynamicval<bool> riu(ray::in_use, false);
|
||||||
|
|
||||||
if(1) {
|
if(1) {
|
||||||
current_display->next_shader_flags = GF_VARCOLOR;
|
current_display->next_shader_flags = GF_VARCOLOR;
|
||||||
dynamicval<eModel> m(pmodel, mdPixel);
|
dynamicval<eModel> m(pmodel, mdPixel);
|
||||||
|
|
|
@ -4437,7 +4437,6 @@ EX void drawthemap() {
|
||||||
profile_start(1);
|
profile_start(1);
|
||||||
make_actual_view();
|
make_actual_view();
|
||||||
currentmap->draw();
|
currentmap->draw();
|
||||||
if(ray::in_use && !ray::comparison_mode) ray::cast();
|
|
||||||
drawWormSegments();
|
drawWormSegments();
|
||||||
drawBlizzards();
|
drawBlizzards();
|
||||||
drawArrowTraps();
|
drawArrowTraps();
|
||||||
|
@ -4703,13 +4702,6 @@ EX void drawfullmap() {
|
||||||
drawqueue();
|
drawqueue();
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if(ray::in_use && ray::comparison_mode) {
|
|
||||||
glDepthFunc(GL_LEQUAL);
|
|
||||||
glClearDepth(1.0f);
|
|
||||||
glClear(GL_DEPTH_BUFFER_BIT);
|
|
||||||
ray::cast();
|
|
||||||
}
|
|
||||||
|
|
||||||
profile_stop(2);
|
profile_stop(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -85,7 +85,7 @@ EX bool requested() {
|
||||||
}
|
}
|
||||||
|
|
||||||
struct raycaster : glhr::GLprogram {
|
struct raycaster : glhr::GLprogram {
|
||||||
GLint uStart, uStartid, uM, uLength, uFovX, uFovY, uIPD;
|
GLint uStart, uStartid, uM, uLength, uFovX, uFovY, uIPD, uShift;
|
||||||
GLint uWallstart, uWallX, uWallY;
|
GLint uWallstart, uWallX, uWallY;
|
||||||
GLint tConnections, tWallcolor, tTextureMap;
|
GLint tConnections, tWallcolor, tTextureMap;
|
||||||
GLint uBinaryWidth, uPLevel, uLP, uStraighten, uReflectX, uReflectY;
|
GLint uBinaryWidth, uPLevel, uLP, uStraighten, uReflectX, uReflectY;
|
||||||
|
@ -100,6 +100,7 @@ struct raycaster : glhr::GLprogram {
|
||||||
uLength = glGetUniformLocation(_program, "uLength");
|
uLength = glGetUniformLocation(_program, "uLength");
|
||||||
uFovX = glGetUniformLocation(_program, "uFovX");
|
uFovX = glGetUniformLocation(_program, "uFovX");
|
||||||
uFovY = glGetUniformLocation(_program, "uFovY");
|
uFovY = glGetUniformLocation(_program, "uFovY");
|
||||||
|
uShift = glGetUniformLocation(_program, "uShift");
|
||||||
uIPD = glGetUniformLocation(_program, "uIPD");
|
uIPD = glGetUniformLocation(_program, "uIPD");
|
||||||
|
|
||||||
uWallstart = glGetUniformLocation(_program, "uWallstart");
|
uWallstart = glGetUniformLocation(_program, "uWallstart");
|
||||||
|
@ -117,6 +118,8 @@ struct raycaster : glhr::GLprogram {
|
||||||
uExpDecay = glGetUniformLocation(_program, "uExpDecay");
|
uExpDecay = glGetUniformLocation(_program, "uExpDecay");
|
||||||
uExpStart = glGetUniformLocation(_program, "uExpStart");
|
uExpStart = glGetUniformLocation(_program, "uExpStart");
|
||||||
|
|
||||||
|
uShift = glGetUniformLocation(_program, "uShift");
|
||||||
|
|
||||||
uBLevel = glGetUniformLocation(_program, "uBLevel");
|
uBLevel = glGetUniformLocation(_program, "uBLevel");
|
||||||
|
|
||||||
tConnections = glGetUniformLocation(_program, "tConnections");
|
tConnections = glGetUniformLocation(_program, "tConnections");
|
||||||
|
@ -141,10 +144,10 @@ void enable_raycaster() {
|
||||||
|
|
||||||
string vsh =
|
string vsh =
|
||||||
"attribute mediump vec4 aPosition;\n"
|
"attribute mediump vec4 aPosition;\n"
|
||||||
"uniform mediump float uFovX, uFovY;\n"
|
"uniform mediump float uFovX, uFovY, uShift;\n"
|
||||||
"varying mediump vec4 at;\n"
|
"varying mediump vec4 at;\n"
|
||||||
"void main() { \n"
|
"void main() { \n"
|
||||||
" gl_Position = aPosition; at = aPosition;\n"
|
" gl_Position = aPosition; at = aPosition; at.x += uShift;\n"
|
||||||
#if IN_ODS
|
#if IN_ODS
|
||||||
" at[0] *= PI; at[1] *= PI; \n"
|
" at[0] *= PI; at[1] *= PI; \n"
|
||||||
#else
|
#else
|
||||||
|
@ -801,9 +804,17 @@ EX void cast() {
|
||||||
glhr::makevertex(+1, -1, 1),
|
glhr::makevertex(+1, -1, 1),
|
||||||
glhr::makevertex(+1, +1, 1)
|
glhr::makevertex(+1, +1, 1)
|
||||||
};
|
};
|
||||||
|
|
||||||
|
ld d = current_display->eyewidth();
|
||||||
|
if(vid.stereo_mode == sLR) d = 2 * d - 1;
|
||||||
|
else d = -d;
|
||||||
|
|
||||||
|
glUniform1f(o->uShift, -global_projection * d);
|
||||||
|
|
||||||
auto& cd = current_display;
|
auto& cd = current_display;
|
||||||
glUniform1f(o->uFovX, cd->tanfov);
|
cd->set_viewport(global_projection);
|
||||||
|
cd->set_mask(global_projection);
|
||||||
|
glUniform1f(o->uFovX, cd->tanfov / (vid.stereo_mode == sLR ? 2 : 1));
|
||||||
glUniform1f(o->uFovY, cd->tanfov * cd->ysize / cd->xsize);
|
glUniform1f(o->uFovY, cd->tanfov * cd->ysize / cd->xsize);
|
||||||
|
|
||||||
deg = S7;
|
deg = S7;
|
||||||
|
@ -817,6 +828,10 @@ EX void cast() {
|
||||||
cell *cs = centerover;
|
cell *cs = centerover;
|
||||||
|
|
||||||
transmatrix T = cview();
|
transmatrix T = cview();
|
||||||
|
|
||||||
|
if(global_projection)
|
||||||
|
T = xpush(vid.ipd * global_projection/2) * T;
|
||||||
|
|
||||||
if(nonisotropic) T = NLP * T;
|
if(nonisotropic) T = NLP * T;
|
||||||
T = inverse(T);
|
T = inverse(T);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue