mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2024-12-24 17:10:36 +00:00
ray:: set depth to match primitive-based shader
This commit is contained in:
parent
852c45e429
commit
3c4fe13fac
7
glhr.cpp
7
glhr.cpp
@ -180,7 +180,12 @@ EX glmatrix& as_glmatrix(GLfloat o[16]) {
|
|||||||
return tmp;
|
return tmp;
|
||||||
}
|
}
|
||||||
|
|
||||||
EX glmatrix frustum(ld x, ld y, ld vnear IS(1e-3), ld vfar IS(1e9)) {
|
#if HDR
|
||||||
|
constexpr ld vnear_default = 1e-3;
|
||||||
|
constexpr ld vfar_default = 1e9;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
EX glmatrix frustum(ld x, ld y, ld vnear IS(vnear_default), ld vfar IS(vfar_default)) {
|
||||||
GLfloat frustum[16] = {
|
GLfloat frustum[16] = {
|
||||||
GLfloat(1 / x), 0, 0, 0,
|
GLfloat(1 / x), 0, 0, 0,
|
||||||
0, GLfloat(1 / y), 0, 0,
|
0, GLfloat(1 / y), 0, 0,
|
||||||
|
@ -418,9 +418,28 @@ void enable_raycaster() {
|
|||||||
" reflect = true;\n"
|
" reflect = true;\n"
|
||||||
" }\n";
|
" }\n";
|
||||||
|
|
||||||
|
ld vnear = glhr::vnear_default;
|
||||||
|
ld vfar = glhr::vfar_default;
|
||||||
|
|
||||||
fmain +=
|
fmain +=
|
||||||
" gl_FragColor.xyz += left * col.xyz * col.w;\n"
|
" gl_FragColor.xyz += left * col.xyz * col.w;\n"
|
||||||
" if(col.w == 1.) return;\n"
|
" if(col.w == 1.) {\n";
|
||||||
|
|
||||||
|
if(hyperbolic) fmain +=
|
||||||
|
" float z = at0.z * sinh(go);\n"
|
||||||
|
" float w = 1.;\n";
|
||||||
|
else fmain +=
|
||||||
|
" float z = at0.z * go;\n"
|
||||||
|
" float w = 1.;\n";
|
||||||
|
|
||||||
|
fmain +=
|
||||||
|
" gl_FragDepth = (-float("+fts(vnear+vfar)+")+w*float("+fts(2*vnear*vfar)+")/z)/float("+fts(vnear-vfar)+");\n"
|
||||||
|
" gl_FragDepth = (gl_FragDepth + 1.) / 2.;\n"
|
||||||
|
// " gl_FragColor.r = gl_FragDepth * gl_FragDepth;\n"
|
||||||
|
// " gl_FragColor.g = gl_FragDepth * gl_FragDepth;\n"
|
||||||
|
// " gl_FragColor.b = gl_FragDepth * gl_FragDepth;\n"
|
||||||
|
" return;\n"
|
||||||
|
" }\n"
|
||||||
" left *= (1. - col.w);\n"
|
" left *= (1. - col.w);\n"
|
||||||
" }\n";
|
" }\n";
|
||||||
|
|
||||||
@ -440,7 +459,8 @@ void enable_raycaster() {
|
|||||||
" }\n";
|
" }\n";
|
||||||
|
|
||||||
fmain +=
|
fmain +=
|
||||||
" }"
|
" }\n"
|
||||||
|
" gl_FragDepth = 1.;\n"
|
||||||
" }";
|
" }";
|
||||||
|
|
||||||
fsh += fmain;
|
fsh += fmain;
|
||||||
@ -629,7 +649,12 @@ EX void cast() {
|
|||||||
bind_array(texturemap, o->tTextureMap, txTextureMap, 5);
|
bind_array(texturemap, o->tTextureMap, txTextureMap, 5);
|
||||||
|
|
||||||
glVertexAttribPointer(hr::aPosition, 4, GL_FLOAT, GL_FALSE, sizeof(glvertex), &screen[0]);
|
glVertexAttribPointer(hr::aPosition, 4, GL_FLOAT, GL_FALSE, sizeof(glvertex), &screen[0]);
|
||||||
glhr::set_depthtest(false);
|
if(ray::comparison_mode)
|
||||||
|
glhr::set_depthtest(false);
|
||||||
|
else {
|
||||||
|
glhr::set_depthtest(true);
|
||||||
|
glhr::set_depthwrite(true);
|
||||||
|
}
|
||||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
|
|
||||||
glActiveTexture(GL_TEXTURE0 + 0);
|
glActiveTexture(GL_TEXTURE0 + 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user