1
0
mirror of https://github.com/zenorogue/hyperrogue.git synced 2024-11-30 15:39:54 +00:00

2d3d:: shadows

This commit is contained in:
Zeno Rogue 2019-05-13 09:34:22 +02:00
parent b63f8a3c4d
commit 175c061ab4
3 changed files with 29 additions and 1 deletions

View File

@ -828,6 +828,12 @@ void queueball(const transmatrix& V, ld rad, color_t col, eItem what) {
} }
} }
void make_shadow(hpcshape& sh) {
sh.shs = isize(hpc);
for(int i=sh.s; i < sh.e; i++) hpcpush(orthogonal_move(hpc[i], geom3::FLOOR - geom3::human_height / 100));
sh.she = isize(hpc);
}
void make_3d_models() { void make_3d_models() {
if(DIM == 2) return; if(DIM == 2) return;
DEBBI(DF_POLY, ("make_3d_models")); DEBBI(DF_POLY, ("make_3d_models"));
@ -839,6 +845,17 @@ void make_3d_models() {
utt.texture_id = floor_textures->renderedTexture; utt.texture_id = floor_textures->renderedTexture;
} }
if(WDIM == 2) {
DEBB(DF_POLY, ("shadows"));
for(hpcshape* sh: {&shBatWings, &shBugBody, &shBullBody, &shButterflyWing, &shCatBody, &shDogBody, &shDogTorso,
&shEagle, &shFemaleBody, &shFlailMissile, &shGadflyWing, &shGargoyleWings, &shHawk, &shJiangShi, &shKnife,
&shPBody, &shPHead, &shRaiderBody, &shReptileBody, &shSkeletonBody, &shTongue, &shTrapArrow, &shTrylobite,
&shWaterElemental, &shWolfBody, &shYeti})
make_shadow(*sh);
for(int i=0; i<8; i++) make_shadow(shAsteroid[i]);
}
DEBB(DF_POLY, ("humanoids")); DEBB(DF_POLY, ("humanoids"));
make_humanoid_3d(shPBody); make_humanoid_3d(shPBody);
make_humanoid_3d(shYeti); make_humanoid_3d(shYeti);

View File

@ -563,6 +563,16 @@ bool noshadow;
#if CAP_SHAPES #if CAP_SHAPES
void ShadowV(const transmatrix& V, const hpcshape& bp, PPR prio) { void ShadowV(const transmatrix& V, const hpcshape& bp, PPR prio) {
if(WDIM == 2 && GDIM == 3 && bp.shs != bp.she) {
auto& p = queuepolyat(V, bp, 0x18, PPR::TRANSPARENT);
p.outline = 0;
p.subprio = -100;
p.offset = bp.shs;
p.cnt = bp.she - bp.shs;
p.flags &=~ POLY_TRIANGLES;
p.tinf = NULL;
return;
}
if(mmspatial) { if(mmspatial) {
if(model_needs_depth() || noshadow) if(model_needs_depth() || noshadow)
return; // shadows break the depth testing return; // shadows break the depth testing
@ -5177,7 +5187,7 @@ void drawcell(cell *c, transmatrix V, int spinv, bool mirrored) {
int fd0 = fd ? fd-1 : 0; int fd0 = fd ? fd-1 : 0;
if(WDIM == 2 && GDIM == 3 && qfi.fshape) if(WDIM == 2 && GDIM == 3 && qfi.fshape)
draw_shapevec(c, V, qfi.fshape->levels[SIDE_LAKE], darkena3(fcol, fd0, 0x80), PPR::TRANSPARENT), ptds.back()->subprio = c->cpdist * 4; draw_shapevec(c, V, qfi.fshape->levels[SIDE_LAKE], darkena3(fcol, fd0, 0x80), PPR::TRANSPARENT), ptds.back()->subprio = -200;
else else
draw_qfi(c, (*Vdp), darkena(fcol, fd0, 0x80), PPR::LAKELEV); draw_qfi(c, (*Vdp), darkena(fcol, fd0, 0x80), PPR::LAKELEV);
} }

View File

@ -4045,6 +4045,7 @@ struct hpcshape {
hyperpoint intester; hyperpoint intester;
basic_textureinfo *tinf; basic_textureinfo *tinf;
int texture_offset; int texture_offset;
int shs, she;
}; };
extern hpcshape shFullCross[2]; extern hpcshape shFullCross[2];