mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-03-29 14:57:03 +00:00
3d:: shader acceleration in the band model
This commit is contained in:
parent
ad4ecbde0e
commit
f399a8c980
@ -224,8 +224,8 @@ void display_data::set_projection(int ed, bool apply_models) {
|
||||
shaderside_projection = true;
|
||||
if(pmodel == mdDisk && !spherespecial && !(hyperbolic && vid.alpha <= -1) && DIM == 3 && apply_models)
|
||||
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::ball;
|
||||
if(pmodel == mdBand && hyperbolic && apply_models && DIM == 2)
|
||||
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::band;
|
||||
if(pmodel == mdBand && hyperbolic && apply_models)
|
||||
shaderside_projection = true, glhr::new_shader_projection = (DIM == 2 ? glhr::shader_projection::band : glhr::shader_projection::band3);
|
||||
if(pmodel == mdHalfplane && hyperbolic && apply_models && DIM == 2)
|
||||
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::halfplane;
|
||||
if(pmodel == mdHalfplane && hyperbolic && apply_models && DIM == 3 && vid.alpha == 1)
|
||||
@ -296,9 +296,9 @@ void display_data::set_projection(int ed, bool apply_models) {
|
||||
if(glhr::new_shader_projection == glhr::shader_projection::ball)
|
||||
glhr::set_ualpha(vid.alpha);
|
||||
|
||||
if(glhr::new_shader_projection == glhr::shader_projection::band) {
|
||||
if(among(glhr::new_shader_projection, glhr::shader_projection::band, glhr::shader_projection::band3)) {
|
||||
glhr::projection_multiply(model_orientation_gl());
|
||||
glhr::projection_multiply(glhr::scale(2 / M_PI, 2 / M_PI,1));
|
||||
glhr::projection_multiply(glhr::scale(2 / M_PI, 2 / M_PI, DIM == 3 ? 2/M_PI : 1));
|
||||
}
|
||||
|
||||
if(among(glhr::new_shader_projection, glhr::shader_projection::halfplane, glhr::shader_projection::halfplane3)) {
|
||||
|
2
hyper.h
2
hyper.h
@ -3886,7 +3886,7 @@ namespace glhr {
|
||||
|
||||
enum class shader_projection { standard, band, halfplane, standardH3, standardR3,
|
||||
standardS30, standardS31, standardS32, standardS33,
|
||||
ball, halfplane3,
|
||||
ball, halfplane3, band3,
|
||||
MAX
|
||||
};
|
||||
|
||||
|
11
shaders.cpp
11
shaders.cpp
@ -494,7 +494,7 @@ void init() {
|
||||
shader_projection sp = shader_projection(j);
|
||||
|
||||
bool mps = j != 0;
|
||||
bool band = (sp == shader_projection::band);
|
||||
bool band = among(sp, shader_projection::band, shader_projection::band3);
|
||||
bool hp = among(sp, shader_projection::halfplane, shader_projection::halfplane3);
|
||||
bool sh3 = (sp == shader_projection::standardH3);
|
||||
bool sr3 = (sp == shader_projection::standardR3);
|
||||
@ -505,7 +505,7 @@ void init() {
|
||||
bool ss3 = ss30 || ss31 || ss32 || ss33;
|
||||
|
||||
bool s3 = (sh3 || sr3 || ss3);
|
||||
bool dim3 = s3 || among(sp, shader_projection::ball, shader_projection::halfplane3);
|
||||
bool dim3 = s3 || among(sp, shader_projection::ball, shader_projection::halfplane3, shader_projection::band3);
|
||||
bool dim2 = !dim3;
|
||||
bool ball = (sp == shader_projection::ball);
|
||||
|
||||
@ -563,10 +563,13 @@ void init() {
|
||||
(band||hp) && dim2, "float zlev = zlevel(t);",
|
||||
(band||hp) && dim2, "t /= zlev;",
|
||||
|
||||
band, "float ty = asinh(t.y);",
|
||||
band&&dim3,"float r = sqrt(t.y*t.y+t.z*t.z); float ty = asinh(r);",
|
||||
band&&dim2,"float ty = asinh(t.y);",
|
||||
band, "float tx = asinh(t.x / cosh(ty));",
|
||||
band, "ty = 2.0 * atan(tanh(ty/2.0));",
|
||||
band, "t[0] = tx; t[1] = ty; t[2] = 1.0; t[3] = 1.0;",
|
||||
band&&dim2,"t[0] = tx; t[1] = ty; t[2] = 1.0; t[3] = 1.0;",
|
||||
band&&dim3,"t[0] = tx; t[1] = ty*t.y/r; t[2] = ty*t.z/r; t[3] = 1.0;",
|
||||
|
||||
|
||||
hp && dim2, "t.x /= t.z; t.y /= t.z; t.y = t.y + 1.0; ",
|
||||
hp && dim2, "float rads = t.x * t.x + t.y * t.y; ",
|
||||
|
Loading…
x
Reference in New Issue
Block a user