From 1c3e0f1a755677f480b21ee1cd8c2c80343f9202 Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Thu, 21 Oct 2021 15:55:57 +0800 Subject: [PATCH] Added 'NoPerPixelLighting' flag to models to force it to not use per-pixel lighting. Main use case is for voxels that have been converted to models. --- src/r_data/models.cpp | 4 ++++ src/r_data/models.h | 1 + src/rendering/hwrenderer/scene/hw_sprites.cpp | 2 +- 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/r_data/models.cpp b/src/r_data/models.cpp index 43d846a4de..c626a13eb2 100644 --- a/src/r_data/models.cpp +++ b/src/r_data/models.cpp @@ -524,6 +524,10 @@ static void ParseModelDefLump(int Lump) { smf.flags |= MDL_USEACTORROLL; } + else if (sc.Compare("noperpixellighting")) + { + smf.flags |= MDL_NOPERPIXELLIGHTING; + } else if (sc.Compare("rotating")) { smf.flags |= MDL_ROTATING; diff --git a/src/r_data/models.h b/src/r_data/models.h index 715ca73be1..2ce9744cab 100644 --- a/src/r_data/models.h +++ b/src/r_data/models.h @@ -55,6 +55,7 @@ enum MDL_BADROTATION = 128, MDL_DONTCULLBACKFACES = 256, MDL_USEROTATIONCENTER = 512, + MDL_NOPERPIXELLIGHTING = 1024, // forces a model to not use per-pixel lighting. useful for voxel-converted-to-model objects. }; FSpriteModelFrame * FindModelFrame(const PClass * ti, int sprite, int frame, bool dropped); diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index d53e9ee1e4..d66074f6de 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -482,7 +482,7 @@ bool HWSprite::CalculateVertices(HWDrawInfo *di, FVector3 *v, DVector3 *vp) inline void HWSprite::PutSprite(HWDrawInfo *di, bool translucent) { // That's a lot of checks... - if (modelframe && !modelframe->isVoxel && RenderStyle.BlendOp != STYLEOP_Shadow && gl_light_sprites && di->Level->HasDynamicLights && !di->isFullbrightScene() && !fullbright) + if (modelframe && !modelframe->isVoxel && !(modelframe->flags & MDL_NOPERPIXELLIGHTING) && RenderStyle.BlendOp != STYLEOP_Shadow && gl_light_sprites && di->Level->HasDynamicLights && !di->isFullbrightScene() && !fullbright) { hw_GetDynModelLight(actor, lightdata); dynlightindex = screen->mLights->UploadLights(lightdata);