mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-01-11 18:00:34 +00:00
panini: frustum_culling disabling done nicely
This commit is contained in:
parent
3288eb0c5a
commit
fd9fb83540
@ -3705,7 +3705,7 @@ EX bool frustum_culling = true;
|
||||
void make_clipping_planes() {
|
||||
#if MAXMDIM >= 4
|
||||
clipping_planes.clear();
|
||||
if(!frustum_culling || PIU(sphere) || experimental || vid.stereo_mode == sODS) return;
|
||||
if(!frustum_culling || PIU(sphere) || experimental || vid.stereo_mode == sODS || panini_alpha) return;
|
||||
auto add_clipping_plane = [] (ld x1, ld y1, ld x2, ld y2) {
|
||||
ld z1 = 1, z2 = 1;
|
||||
hyperpoint sx = point3(y1 * z2 - y2 * z1, z1 * x2 - z2 * x1, x1 * y2 - x2 * y1);
|
||||
|
20
shaders.cpp
20
shaders.cpp
@ -66,6 +66,17 @@ EX void reset_all_shaders() {
|
||||
matched_programs.clear();
|
||||
}
|
||||
|
||||
EX string panini_shader() {
|
||||
return
|
||||
"t.w += 1.; t *= 2. / t.w; t.w -= 1.;\n"
|
||||
"float s = t.z;\n"
|
||||
"float l = length(t.xyz);\n"
|
||||
"t /= max(length(t.xz), 1e-2);\n"
|
||||
"t.z += " + glhr::to_glsl(panini_alpha) + ";\n"
|
||||
"t *= l;\n"
|
||||
"t.w = 1.;\n";
|
||||
}
|
||||
|
||||
shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
|
||||
string varying, vsh, fsh, vmain = "void main() {\n", fmain = "void main() {\n";
|
||||
|
||||
@ -342,14 +353,7 @@ shared_ptr<glhr::GLprogram> write_shader(flagtype shader_flags) {
|
||||
if(WDIM == 3 && panini_alpha) {
|
||||
vmain += "t = uPP * t;", vsh += "uniform mediump mat4 uPP;";
|
||||
/* panini */
|
||||
vmain += "t.w += 1.; t *= 2. / t.w; t.w -= 1.;\n";
|
||||
vmain += "float s = t.z;";
|
||||
vmain += "float l = length(t.xyz);";
|
||||
vmain += "t /= max(length(t.xz), 1e-2);\n";
|
||||
vmain += "t.z += " + glhr::to_glsl(panini_alpha) + ";\n";
|
||||
vmain += "t *= l;\n";
|
||||
vmain += "t.w = 1.;\n";
|
||||
frustum_culling = false;
|
||||
vmain += panini_shader();
|
||||
shader_flags |= SF_ORIENT;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user