mirror of
https://github.com/zenorogue/hyperrogue.git
synced 2026-11-27 08:23:08 +00:00
3d:: shader acceleration for 3D ball and 3D halfspace
This commit is contained in:
1 parent
fbefc50775
commit
bc3e7f2e95
4 files changed
+68
-26
No files matched your search
+21
-7
@@ -205,8 +205,10 @@ void eyewidth_translate(int ed) {
|
||||
|
||||
glhr::glmatrix model_orientation_gl() {
|
||||
glhr::glmatrix s = glhr::id;
|
||||
for(int a=0; a<2; a++)
|
||||
for(int a=0; a<DIM; a++)
|
||||
conformal::apply_orientation(s[a][1], s[a][0]);
|
||||
if(DIM == 3) for(int a=0; a<DIM; a++)
|
||||
conformal::apply_orientation_yz(s[a][2], s[a][1]);
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -214,22 +216,27 @@ void display_data::set_projection(int ed, bool apply_models) {
|
||||
DEBB(DF_GRAPH, (debugfile,"current_display->set_projection\n"));
|
||||
|
||||
bool dim3 = false;
|
||||
bool pers3 = false;
|
||||
|
||||
shaderside_projection = false;
|
||||
glhr::new_shader_projection = glhr::shader_projection::standard;
|
||||
if(vid.consider_shader_projection) {
|
||||
if(pmodel == mdDisk && !spherespecial && !(hyperbolic && vid.alpha <= -1) && DIM == 2)
|
||||
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 == 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)
|
||||
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::halfplane3;
|
||||
if(DIM == 3 && hyperbolic && apply_models && pmodel == mdPerspective)
|
||||
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::standardH3;
|
||||
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::standardH3, pers3 = true;
|
||||
if(DIM == 3 && euclid && apply_models && pmodel == mdPerspective)
|
||||
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::standardR3;
|
||||
shaderside_projection = true, glhr::new_shader_projection = glhr::shader_projection::standardR3, pers3 = true;
|
||||
if(DIM == 3 && sphere && apply_models && pmodel == mdPerspective) {
|
||||
shaderside_projection = true;
|
||||
shaderside_projection = true; pers3 = true;
|
||||
if(spherephase == 0) glhr::new_shader_projection = glhr::shader_projection::standardS30;
|
||||
if(spherephase == 1) glhr::new_shader_projection = glhr::shader_projection::standardS31;
|
||||
if(spherephase == 2) glhr::new_shader_projection = glhr::shader_projection::standardS32;
|
||||
@@ -264,11 +271,15 @@ void display_data::set_projection(int ed, bool apply_models) {
|
||||
|
||||
eyewidth_translate(ed);
|
||||
|
||||
if(dim3) {
|
||||
if(pers3) {
|
||||
glhr::projection_multiply(glhr::frustum(current_display->tanfov, current_display->tanfov * cd->ysize / cd->xsize));
|
||||
glhr::projection_multiply(glhr::scale(1, -1, -1));
|
||||
current_display->scrdist_text = cd->ysize;
|
||||
}
|
||||
else if(DIM == 3) {
|
||||
glhr::projection_multiply(glhr::ortho(cd->xsize/current_display->radius/2, -cd->ysize/current_display->radius/2, 10));
|
||||
current_display->scrdist_text = 0;
|
||||
}
|
||||
else {
|
||||
glhr::projection_multiply(glhr::frustum(cd->xsize / cd->ysize, 1));
|
||||
GLfloat sc = current_display->radius / (cd->ysize/2.);
|
||||
@@ -280,16 +291,19 @@ void display_data::set_projection(int ed, bool apply_models) {
|
||||
if(ed) glhr::projection_multiply(glhr::translate(vid.ipd * ed/2, 0, 0));
|
||||
|
||||
|
||||
if(dim3) {
|
||||
if(pers3) {
|
||||
glhr::fog_max(1/sightranges[geometry]);
|
||||
}
|
||||
|
||||
if(glhr::new_shader_projection == glhr::shader_projection::ball)
|
||||
glhr::set_ualpha(vid.alpha);
|
||||
|
||||
if(glhr::new_shader_projection == glhr::shader_projection::band) {
|
||||
glhr::projection_multiply(model_orientation_gl());
|
||||
glhr::projection_multiply(glhr::scale(2 / M_PI, 2 / M_PI,1));
|
||||
}
|
||||
|
||||
if(glhr::new_shader_projection == glhr::shader_projection::halfplane) {
|
||||
if(among(glhr::new_shader_projection, glhr::shader_projection::halfplane, glhr::shader_projection::halfplane3)) {
|
||||
glhr::projection_multiply(model_orientation_gl());
|
||||
glhr::projection_multiply(glhr::translate(0, 1, 0));
|
||||
glhr::projection_multiply(glhr::scale(-1, 1, 1));
|
||||
|
||||
Reference in new issue
Block a user