1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-06-18 11:19:59 +00:00

2D3D:: wall shadows

This commit is contained in:
Zeno Rogue 2019-05-13 13:39:43 +02:00
parent 8858b137b5
commit 740cc5fbb6
4 changed files with 31 additions and 1 deletions

View File

@ -470,6 +470,9 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
finishshape(); finishshape();
for(auto pfsh: all_plain_floorshapes) { for(auto pfsh: all_plain_floorshapes) {
auto& fsh = *pfsh; auto& fsh = *pfsh;
for(int i=fsh.shadow[id].s; i<fsh.shadow[id].e; i++)
hpc[i] = orthogonal_move(hpc[i], geom3::FLOOR - geom3::human_height / 100);
for(int k=0; k<SIDEPARS; k++) { for(int k=0; k<SIDEPARS; k++) {
sizeto(fsh.levels[k], id); sizeto(fsh.levels[k], id);
@ -545,6 +548,7 @@ void generate_floorshapes_for(int id, cell *c, int siid, int sidir) {
for(int l=0; l<SIDEPARS; l++) { for(int l=0; l<SIDEPARS; l++) {
fsh.levels[l] = shFullFloor.levels[l]; fsh.levels[l] = shFullFloor.levels[l];
fsh.shadow = shFullFloor.shadow;
for(auto& li: fsh.levels[l]) li.tinf = &fsh.tinf3; for(auto& li: fsh.levels[l]) li.tinf = &fsh.tinf3;
fsh.side[l] = shFullFloor.side[l]; fsh.side[l] = shFullFloor.side[l];
for(auto& li: fsh.side[l]) li.tinf = &fsh.tinf3; for(auto& li: fsh.side[l]) li.tinf = &fsh.tinf3;

View File

@ -4006,6 +4006,8 @@ void draw_wall(cell *c, const transmatrix& V, color_t wcol, color_t& zcol, int c
if(!qfi.fshape) qfi.fshape = &shFullFloor; if(!qfi.fshape) qfi.fshape = &shFullFloor;
if(conegraph(c)) { if(conegraph(c)) {
draw_shapevec(c, V, qfi.fshape->cone[0], darkena(wcol, 0, 0xFF), PPR::WALL); draw_shapevec(c, V, qfi.fshape->cone[0], darkena(wcol, 0, 0xFF), PPR::WALL);
dynamicval<color_t> p(poly_outline, OUTLINE_TRANS);
draw_shapevec(c, V, qfi.fshape->shadow, SHADOW_WALL, PPR::WALLSHADOW);
return; return;
} }
color_t wcol0 = wcol; color_t wcol0 = wcol;
@ -4014,6 +4016,9 @@ void draw_wall(cell *c, const transmatrix& V, color_t wcol, color_t& zcol, int c
forCellIdEx(c2, i, c) forCellIdEx(c2, i, c)
if(!highwall(c2) || conegraph(c2)) if(!highwall(c2) || conegraph(c2))
placeSidewall(c, i, SIDE_WALL, V, darkena(wcol2, fd, 255)); placeSidewall(c, i, SIDE_WALL, V, darkena(wcol2, fd, 255));
dynamicval<color_t> p(poly_outline, OUTLINE_TRANS);
draw_shapevec(c, V, qfi.fshape->shadow, SHADOW_WALL, PPR::WALLSHADOW);
return; return;
} }
@ -5555,6 +5560,8 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
if(c->land == laOceanWall && wmescher && wmspatial) { if(c->land == laOceanWall && wmescher && wmspatial) {
if(GDIM == 3 && qfi.fshape) { if(GDIM == 3 && qfi.fshape) {
draw_shapevec(c, V, qfi.fshape->cone[1], darkena(wcol, 0, 0xFF), PPR::WALL); draw_shapevec(c, V, qfi.fshape->cone[1], darkena(wcol, 0, 0xFF), PPR::WALL);
dynamicval<color_t> p(poly_outline, OUTLINE_TRANS);
draw_shapevec(c, V, qfi.fshape->shadow, SHADOW_WALL, PPR::WALLSHADOW);
break; break;
} }
const int layers = 2 << detaillevel; const int layers = 2 << detaillevel;
@ -5629,6 +5636,8 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
else if(c->wall == waExplosiveBarrel) { else if(c->wall == waExplosiveBarrel) {
if(DIM == 3 && qfi.fshape) { if(DIM == 3 && qfi.fshape) {
draw_shapevec(c, V, qfi.fshape->cone[1], 0xD00000FF, PPR::REDWALL); draw_shapevec(c, V, qfi.fshape->cone[1], 0xD00000FF, PPR::REDWALL);
dynamicval<color_t> p(poly_outline, OUTLINE_TRANS);
draw_shapevec(c, V, qfi.fshape->shadow, SHADOW_WALL, PPR::WALLSHADOW);
break; break;
} }
const int layers = 2 << detaillevel; const int layers = 2 << detaillevel;
@ -5641,8 +5650,11 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
else if(isFire(c) || isThumper(c) || c->wall == waBonfireOff) { else if(isFire(c) || isThumper(c) || c->wall == waBonfireOff) {
auto V2 = V; auto V2 = V;
if(hasTimeout(c)) V2 = V2 * spintick(c->land == laPower ? 5000 : 500); if(hasTimeout(c)) V2 = V2 * spintick(c->land == laPower ? 5000 : 500);
if(GDIM == 3 && qfi.fshape) if(GDIM == 3 && qfi.fshape) {
draw_shapevec(c, V2, qfi.fshape->cone[1], darkena(wcol, 0, 0xF0), PPR::WALL); draw_shapevec(c, V2, qfi.fshape->cone[1], darkena(wcol, 0, 0xF0), PPR::WALL);
dynamicval<color_t> p(poly_outline, OUTLINE_TRANS);
draw_shapevec(c, V, qfi.fshape->shadow, SHADOW_WALL, PPR::WALLSHADOW);
}
else queuepoly(V2, shStar, darkena(wcol, 0, 0xF0)); else queuepoly(V2, shStar, darkena(wcol, 0, 0xF0));
if(isFire(c) && rand() % 300 < ticks - lastt) if(isFire(c) && rand() % 300 < ticks - lastt)
drawParticle(c, wcol, 75); drawParticle(c, wcol, 75);

View File

@ -672,6 +672,7 @@ void dqi_poly::gldraw() {
if(flags & POLY_TRIANGLES) { if(flags & POLY_TRIANGLES) {
glhr::color2(color); glhr::color2(color);
glhr::set_depthtest(model_needs_depth() && prio < PPR::SUPERLINE); glhr::set_depthtest(model_needs_depth() && prio < PPR::SUPERLINE);
glhr::set_depthwrite(model_needs_depth() && prio != PPR::TRANSPARENT_SHADOW);
glDrawArrays(GL_TRIANGLES, ioffset, cnt); glDrawArrays(GL_TRIANGLES, ioffset, cnt);
} }
else { else {
@ -687,6 +688,7 @@ void dqi_poly::gldraw() {
current_display->set_mask(ed); current_display->set_mask(ed);
glhr::color2(color); glhr::color2(color);
glhr::set_depthtest(model_needs_depth() && prio < PPR::SUPERLINE); glhr::set_depthtest(model_needs_depth() && prio < PPR::SUPERLINE);
glhr::set_depthwrite(model_needs_depth() && prio != PPR::TRANSPARENT_SHADOW);
if(flags & (POLY_INVERSE | POLY_FORCE_INVERTED)) { if(flags & (POLY_INVERSE | POLY_FORCE_INVERTED)) {
glStencilOp( GL_ZERO, GL_ZERO, GL_ZERO); glStencilOp( GL_ZERO, GL_ZERO, GL_ZERO);

View File

@ -781,5 +781,17 @@ void set_depthtest(bool b) {
else glDisable(GL_DEPTH_TEST); else glDisable(GL_DEPTH_TEST);
} }
} }
bool current_depthwrite;
void set_depthwrite(bool b) {
if(b != current_depthwrite) {
current_depthwrite = b;
if(b) glDepthMask(GL_TRUE);
else glDisable(GL_FALSE);
}
}
} }
} }