diff --git a/source/src/model.h b/source/src/model.h index e7de04fd..bc09fb4a 100644 --- a/source/src/model.h +++ b/source/src/model.h @@ -37,12 +37,12 @@ struct dynent; struct model { - bool cullface, alphatexture; + bool cullface, alphablend; float alphatest, translucency, scale; vec translate; int batch; - model() : cullface(true), alphatexture(false), alphatest(0.9f), translucency(0.25f), scale(1), translate(0, 0, 0), batch(-1) {} + model() : cullface(true), alphablend(false), alphatest(0.9f), translucency(0.25f), scale(1), translate(0, 0, 0), batch(-1) {} virtual ~model() {} virtual bool load() = 0; diff --git a/source/src/rendermodel.cpp b/source/src/rendermodel.cpp index a344e07e..6e6726ce 100644 --- a/source/src/rendermodel.cpp +++ b/source/src/rendermodel.cpp @@ -36,13 +36,13 @@ void mdlalphatest(int alphatest) COMMAND(mdlalphatest, ARG_1INT); -void mdlalphatexture(int enable) +void mdlalphablend(int alphablend) { checkmdl; - loadingmodel->alphatexture = enable>0; + loadingmodel->alphablend = alphablend!=0; } -COMMAND(mdlalphatexture, ARG_1INT); +COMMAND(mdlalphablend, ARG_1INT); void mdlscale(int percent) { @@ -185,7 +185,7 @@ void renderbatchedmodel(model *m, batchedmodel &b) modelattach *a = NULL; if(b.attached>=0) a = &modelattached[b.attached]; - if(b.anim&ANIM_TRANSLUCENT || m->alphatexture) + if(b.anim&ANIM_TRANSLUCENT) { glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); m->render(b.anim|ANIM_NOSKIN, b.varseed, b.speed, b.basetime, b.o, b.yaw, b.pitch, b.d, a, b.scale); @@ -202,7 +202,7 @@ void renderbatchedmodel(model *m, batchedmodel &b) m->render(b.anim, b.varseed, b.speed, b.basetime, b.o, b.yaw, b.pitch, b.d, a, b.scale); - if(b.anim&ANIM_TRANSLUCENT || m->alphatexture) + if(b.anim&ANIM_TRANSLUCENT) { glDepthFunc(GL_LESS); glDisable(GL_BLEND); @@ -256,7 +256,7 @@ void endmodelbatches() loopvj(b.batched) { batchedmodel &bm = b.batched[j]; - if(bm.anim&ANIM_TRANSLUCENT) + if(bm.anim&ANIM_TRANSLUCENT || b.m->alphablend) { translucentmodel &tm = translucent.add(); tm.m = b.m; diff --git a/source/src/vertmodel.h b/source/src/vertmodel.h index 07dc06db..cc852138 100644 --- a/source/src/vertmodel.h +++ b/source/src/vertmodel.h @@ -146,7 +146,16 @@ struct vertmodel : model glBindTexture(GL_TEXTURE_2D, id); lasttex = id; } - if(enablealphablend) { glDisable(GL_BLEND); enablealphablend = false; } + if(skin->bpp == 32 && owner->model->alphablend) + { + if(!enablealphablend) + { + glEnable(GL_BLEND); + glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); + enablealphablend = true; + } + } + else if(enablealphablend) { glDisable(GL_BLEND); enablealphablend = false; } if(skin->bpp == 32 && owner->model->alphatest > 0) { if(!enablealphatest) { glEnable(GL_ALPHA_TEST); enablealphatest = true; }