mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-11-17 10:44:48 +00:00
ray:: projection is now set via matrix, instead of via five values
This commit is contained in:
parent
9c9afceb41
commit
f41414a705
@ -119,16 +119,16 @@ EX bool requested() {
|
|||||||
|
|
||||||
#if HDR
|
#if HDR
|
||||||
struct raycaster : glhr::GLprogram {
|
struct raycaster : glhr::GLprogram {
|
||||||
GLint uStart, uStartid, uM, uLength, uFovX, uFovY, uIPD, uShift;
|
GLint uStart, uStartid, uM, uLength, uIPD;
|
||||||
GLint uWallstart, uWallX, uWallY;
|
GLint uWallstart, uWallX, uWallY;
|
||||||
GLint tConnections, tWallcolor, tTextureMap, tVolumetric;
|
GLint tConnections, tWallcolor, tTextureMap, tVolumetric;
|
||||||
GLint uBinaryWidth, uPLevel, uLP, uStraighten, uReflectX, uReflectY;
|
GLint uBinaryWidth, uPLevel, uLP, uStraighten, uReflectX, uReflectY;
|
||||||
GLint uLinearSightRange, uExpStart, uExpDecay;
|
GLint uLinearSightRange, uExpStart, uExpDecay;
|
||||||
GLint uBLevel;
|
GLint uBLevel;
|
||||||
GLint uPosX, uPosY;
|
|
||||||
GLint uWallOffset, uSides;
|
GLint uWallOffset, uSides;
|
||||||
GLint uITOA, uATOI;
|
GLint uITOA, uATOI;
|
||||||
GLint uToOrig, uFromOrig;
|
GLint uToOrig, uFromOrig;
|
||||||
|
GLint uProjection;
|
||||||
|
|
||||||
raycaster(string vsh, string fsh);
|
raycaster(string vsh, string fsh);
|
||||||
};
|
};
|
||||||
@ -140,9 +140,7 @@ raycaster::raycaster(string vsh, string fsh) : GLprogram(vsh, fsh) {
|
|||||||
uStartid = glGetUniformLocation(_program, "uStartid");
|
uStartid = glGetUniformLocation(_program, "uStartid");
|
||||||
uM = glGetUniformLocation(_program, "uM");
|
uM = glGetUniformLocation(_program, "uM");
|
||||||
uLength = glGetUniformLocation(_program, "uLength");
|
uLength = glGetUniformLocation(_program, "uLength");
|
||||||
uFovX = glGetUniformLocation(_program, "uFovX");
|
uProjection = glGetUniformLocation(_program, "uProjection");
|
||||||
uFovY = glGetUniformLocation(_program, "uFovY");
|
|
||||||
uShift = glGetUniformLocation(_program, "uShift");
|
|
||||||
uIPD = glGetUniformLocation(_program, "uIPD");
|
uIPD = glGetUniformLocation(_program, "uIPD");
|
||||||
|
|
||||||
uWallstart = glGetUniformLocation(_program, "uWallstart");
|
uWallstart = glGetUniformLocation(_program, "uWallstart");
|
||||||
@ -170,9 +168,6 @@ raycaster::raycaster(string vsh, string fsh) : GLprogram(vsh, fsh) {
|
|||||||
uWallOffset = glGetUniformLocation(_program, "uWallOffset");
|
uWallOffset = glGetUniformLocation(_program, "uWallOffset");
|
||||||
uSides = glGetUniformLocation(_program, "uSides");
|
uSides = glGetUniformLocation(_program, "uSides");
|
||||||
|
|
||||||
uPosX = glGetUniformLocation(_program, "uPosX");
|
|
||||||
uPosY = glGetUniformLocation(_program, "uPosY");
|
|
||||||
|
|
||||||
uITOA = glGetUniformLocation(_program, "uITOA");
|
uITOA = glGetUniformLocation(_program, "uITOA");
|
||||||
uATOI = glGetUniformLocation(_program, "uATOI");
|
uATOI = glGetUniformLocation(_program, "uATOI");
|
||||||
uToOrig = glGetUniformLocation(_program, "uToOrig");
|
uToOrig = glGetUniformLocation(_program, "uToOrig");
|
||||||
@ -243,16 +238,10 @@ void enable_raycaster() {
|
|||||||
|
|
||||||
string vsh =
|
string vsh =
|
||||||
"attribute mediump vec4 aPosition;\n"
|
"attribute mediump vec4 aPosition;\n"
|
||||||
"uniform mediump float uFovX, uFovY, uPosX, uPosY, uShift;\n"
|
"uniform mediump mat4 uProjection;\n"
|
||||||
"varying mediump vec4 at;\n"
|
"varying mediump vec4 at;\n"
|
||||||
"void main() { \n"
|
"void main() { \n"
|
||||||
" gl_Position = aPosition; at = aPosition; at.x += uShift;\n"
|
" gl_Position = aPosition; at = uProjection * aPosition; \n"
|
||||||
" at[0] += uPosX; at[1] += uPosY;\n"
|
|
||||||
#if IN_ODS
|
|
||||||
" at[0] *= PI; at[1] *= PI; \n"
|
|
||||||
#else
|
|
||||||
" at[0] *= uFovX; at[1] *= uFovY; \n"
|
|
||||||
#endif
|
|
||||||
" }\n";
|
" }\n";
|
||||||
|
|
||||||
irays = isize(cgi.raywall);
|
irays = isize(cgi.raywall);
|
||||||
@ -1345,16 +1334,15 @@ EX void cast() {
|
|||||||
if(vid.stereo_mode == sLR) d = 2 * d - 1;
|
if(vid.stereo_mode == sLR) d = 2 * d - 1;
|
||||||
else d = -d;
|
else d = -d;
|
||||||
|
|
||||||
glUniform1f(o->uShift, -global_projection * d);
|
|
||||||
|
|
||||||
auto& cd = current_display;
|
auto& cd = current_display;
|
||||||
cd->set_viewport(global_projection);
|
cd->set_viewport(global_projection);
|
||||||
cd->set_mask(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->uPosX, -((cd->xcenter-cd->xtop)*2./cd->xsize - 1));
|
transmatrix proj = Id;
|
||||||
glUniform1f(o->uPosY, -((cd->ycenter-cd->ytop)*2./cd->ysize - 1));
|
proj = eupush(-global_projection * d, 0) * proj;
|
||||||
|
proj = euscale(cd->tanfov / (vid.stereo_mode == sLR ? 2 : 1), cd->tanfov * cd->ysize / cd->xsize) * proj;
|
||||||
|
proj = eupush(-((cd->xcenter-cd->xtop)*2./cd->xsize - 1), -((cd->ycenter-cd->ytop)*2./cd->ysize - 1)) * proj;
|
||||||
|
glUniformMatrix4fv(o->uProjection, 1, 0, glhr::tmtogl_transpose3(proj).as_array());
|
||||||
|
|
||||||
if(!callhandlers(false, hooks_rayset, o)) {
|
if(!callhandlers(false, hooks_rayset, o)) {
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user