mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2025-02-08 23:20:12 +00:00
shaderside projection for DIM==3
This commit is contained in:
parent
56d628d4d8
commit
0ea37718f0
@ -212,19 +212,21 @@ void display_data::set_projection(int ed, bool apply_models) {
|
|||||||
shaderside_projection = false;
|
shaderside_projection = false;
|
||||||
glhr::new_shader_projection = glhr::shader_projection::standard;
|
glhr::new_shader_projection = glhr::shader_projection::standard;
|
||||||
if(vid.consider_shader_projection) {
|
if(vid.consider_shader_projection) {
|
||||||
if(pmodel == mdDisk && !spherespecial && !(hyperbolic && vid.alpha <= -1))
|
if(pmodel == mdDisk && !spherespecial && !(hyperbolic && vid.alpha <= -1) && DIM == 2)
|
||||||
shaderside_projection = true;
|
shaderside_projection = true;
|
||||||
if(pmodel == mdBand && hyperbolic && apply_models)
|
if(pmodel == mdBand && hyperbolic && apply_models)
|
||||||
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::band;
|
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::band;
|
||||||
if(pmodel == mdHalfplane && hyperbolic && apply_models)
|
if(pmodel == mdHalfplane && hyperbolic && apply_models)
|
||||||
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::halfplane;
|
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::halfplane;
|
||||||
|
if(DIM == 3)
|
||||||
|
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::standard3;
|
||||||
}
|
}
|
||||||
|
|
||||||
start_projection(ed, shaderside_projection);
|
start_projection(ed, shaderside_projection);
|
||||||
|
|
||||||
auto cd = current_display;
|
auto cd = current_display;
|
||||||
|
|
||||||
if(!shaderside_projection) {
|
if(!shaderside_projection && DIM != 3) {
|
||||||
glhr::projection_multiply(glhr::ortho(cd->xsize/2, -cd->ysize/2, abs(current_display->scrdist) + 30000));
|
glhr::projection_multiply(glhr::ortho(cd->xsize/2, -cd->ysize/2, abs(current_display->scrdist) + 30000));
|
||||||
if(ed) {
|
if(ed) {
|
||||||
glhr::glmatrix m = glhr::id;
|
glhr::glmatrix m = glhr::id;
|
||||||
@ -255,6 +257,10 @@ void display_data::set_projection(int ed, bool apply_models) {
|
|||||||
if(ed) glhr::projection_multiply(glhr::translate(vid.ipd * ed/2, 0, 0));
|
if(ed) glhr::projection_multiply(glhr::translate(vid.ipd * ed/2, 0, 0));
|
||||||
|
|
||||||
current_display->scrdist_text = cd->ysize * sc / 2;
|
current_display->scrdist_text = cd->ysize * sc / 2;
|
||||||
|
|
||||||
|
if(glhr::new_shader_projection == glhr::shader_projection::standard3) {
|
||||||
|
glhr::fog_max(1/binary::btrange);
|
||||||
|
}
|
||||||
|
|
||||||
if(glhr::new_shader_projection == glhr::shader_projection::band) {
|
if(glhr::new_shader_projection == glhr::shader_projection::band) {
|
||||||
glhr::projection_multiply(model_orientation_gl());
|
glhr::projection_multiply(model_orientation_gl());
|
||||||
|
2
hyper.h
2
hyper.h
@ -3797,7 +3797,7 @@ namespace glhr {
|
|||||||
const GLfloat* as_array() const { return a[0]; }
|
const GLfloat* as_array() const { return a[0]; }
|
||||||
};
|
};
|
||||||
|
|
||||||
enum class shader_projection { standard, band, halfplane, MAX };
|
enum class shader_projection { standard, band, halfplane, standard3, MAX };
|
||||||
|
|
||||||
extern shader_projection new_shader_projection;
|
extern shader_projection new_shader_projection;
|
||||||
|
|
||||||
|
11
polygons.cpp
11
polygons.cpp
@ -490,11 +490,15 @@ vector<glvertex> line_vertices;
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
void glapplymatrix(const transmatrix& V) {
|
void glapplymatrix(const transmatrix& V) {
|
||||||
#if DIM == 3
|
|
||||||
glhr::set_modelview(glhr::id);
|
|
||||||
#else
|
|
||||||
GLfloat mat[16];
|
GLfloat mat[16];
|
||||||
int id = 0;
|
int id = 0;
|
||||||
|
if(DIM == 3) {
|
||||||
|
for(int y=0; y<4; y++) {
|
||||||
|
for(int x=0; x<4; x++) mat[id++] = V[x][y];
|
||||||
|
}
|
||||||
|
glhr::set_modelview(glhr::as_glmatrix(mat));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
for(int y=0; y<3; y++) {
|
for(int y=0; y<3; y++) {
|
||||||
for(int x=0; x<3; x++) mat[id++] = V[x][y];
|
for(int x=0; x<3; x++) mat[id++] = V[x][y];
|
||||||
@ -512,7 +516,6 @@ void glapplymatrix(const transmatrix& V) {
|
|||||||
conformal::apply_orientation(mat[a*4], mat[a*4+1]);
|
conformal::apply_orientation(mat[a*4], mat[a*4+1]);
|
||||||
|
|
||||||
glhr::set_modelview(glhr::as_glmatrix(mat));
|
glhr::set_modelview(glhr::as_glmatrix(mat));
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void dqi_poly::gldraw() {
|
void dqi_poly::gldraw() {
|
||||||
|
13
shaders.cpp
13
shaders.cpp
@ -491,6 +491,7 @@ void init() {
|
|||||||
bool mps = j != 0;
|
bool mps = j != 0;
|
||||||
bool band = (sp == shader_projection::band);
|
bool band = (sp == shader_projection::band);
|
||||||
bool hp = (sp == shader_projection::halfplane);
|
bool hp = (sp == shader_projection::halfplane);
|
||||||
|
bool s3 = (sp == shader_projection::standard3);
|
||||||
|
|
||||||
programs[i][j] = new GLprogram(stringbuilder(
|
programs[i][j] = new GLprogram(stringbuilder(
|
||||||
|
|
||||||
@ -521,9 +522,13 @@ void init() {
|
|||||||
1, " }",
|
1, " }",
|
||||||
|
|
||||||
1, "float asinh(float x) {",
|
1, "float asinh(float x) {",
|
||||||
1, " return log(sqrt(1.0 + x*x) + x);",
|
1, " return log(sqrt(x*x + 1.0) + x);",
|
||||||
1, " }",
|
1, " }",
|
||||||
|
|
||||||
|
1, "float acosh(float x) {",
|
||||||
|
1, " return log(sqrt(x*x - 1.0) + x);",
|
||||||
|
1, " }",
|
||||||
|
|
||||||
1, "float zlevel(vec4 h) {",
|
1, "float zlevel(vec4 h) {",
|
||||||
1, " return (h[2] < 0.0 ? -1.0 : 1.0) * sqrt(h[2]*h[2] - h[0]*h[0] - h[1]*h[1]);",
|
1, " return (h[2] < 0.0 ? -1.0 : 1.0) * sqrt(h[2]*h[2] - h[0]*h[0] - h[1]*h[1]);",
|
||||||
1, " }",
|
1, " }",
|
||||||
@ -549,6 +554,10 @@ void init() {
|
|||||||
hp, "float rads = t.x * t.x + t.y * t.y; ",
|
hp, "float rads = t.x * t.x + t.y * t.y; ",
|
||||||
hp, "t.x /= -rads; t.y /= -rads; t.z = 1.0; t[3] = 1.0;",
|
hp, "t.x /= -rads; t.y /= -rads; t.z = 1.0; t[3] = 1.0;",
|
||||||
|
|
||||||
|
s3, "vec4 t = uMV * aPosition;",
|
||||||
|
s3, "vColor.xyz = vColor.xyz * (1.0 - acosh(t[3]) / uFog);",
|
||||||
|
s3, "t[3] = 1.0;",
|
||||||
|
|
||||||
band || hp,"gl_Position = uP * t;",
|
band || hp,"gl_Position = uP * t;",
|
||||||
1, "}"),
|
1, "}"),
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user