diff --git a/src/polyrenderer/scene/poly_decal.cpp b/src/polyrenderer/scene/poly_decal.cpp index c36b67f4a..03e33c015 100644 --- a/src/polyrenderer/scene/poly_decal.cpp +++ b/src/polyrenderer/scene/poly_decal.cpp @@ -137,6 +137,7 @@ void RenderPolyDecal::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan args.uniforms.flags = 0; args.SetColormap(front->ColorMap); args.SetTexture(tex, decal->Translation, true); + args.uniforms.globvis = (float)swrenderer::r_WallVisibility; if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) { args.uniforms.light = 256; diff --git a/src/polyrenderer/scene/poly_particle.cpp b/src/polyrenderer/scene/poly_particle.cpp index e4380dae9..b5d7220c0 100644 --- a/src/polyrenderer/scene/poly_particle.cpp +++ b/src/polyrenderer/scene/poly_particle.cpp @@ -73,6 +73,8 @@ void RenderPolyParticle::Render(const TriMatrix &worldToClip, const Vec4f &clipP PolyDrawArgs args; + args.uniforms.globvis = (float)swrenderer::r_SpriteVisibility; + if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) { args.uniforms.light = 256; diff --git a/src/polyrenderer/scene/poly_plane.cpp b/src/polyrenderer/scene/poly_plane.cpp index 275310c31..86dd89fd1 100644 --- a/src/polyrenderer/scene/poly_plane.cpp +++ b/src/polyrenderer/scene/poly_plane.cpp @@ -107,6 +107,7 @@ void RenderPolyPlane::Render3DFloor(const TriMatrix &worldToClip, const Vec4f &c UVTransform xform(ceiling ? fakeFloor->top.model->planes[sector_t::ceiling].xform : fakeFloor->top.model->planes[sector_t::floor].xform, tex); PolyDrawArgs args; + args.uniforms.globvis = (float)swrenderer::r_TiltVisibility * 48.0f; args.uniforms.light = (uint32_t)(lightlevel / 255.0f * 256.0f); if (swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) args.uniforms.light = 256; @@ -300,6 +301,7 @@ void RenderPolyPlane::Render(const TriMatrix &worldToClip, const Vec4f &clipPlan UVTransform transform(ceiling ? frontsector->planes[sector_t::ceiling].xform : frontsector->planes[sector_t::floor].xform, tex); PolyDrawArgs args; + args.uniforms.globvis = (float)swrenderer::r_TiltVisibility * 48.0f; args.uniforms.light = (uint32_t)(frontsector->lightlevel / 255.0f * 256.0f); if (swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) args.uniforms.light = 256; diff --git a/src/polyrenderer/scene/poly_scene.cpp b/src/polyrenderer/scene/poly_scene.cpp index 51ce53a26..8744940b3 100644 --- a/src/polyrenderer/scene/poly_scene.cpp +++ b/src/polyrenderer/scene/poly_scene.cpp @@ -29,6 +29,7 @@ #include "polyrenderer/scene/poly_scene.h" #include "polyrenderer/poly_renderer.h" #include "gl/data/gl_data.h" +#include "swrenderer/scene/r_light.h" CVAR(Bool, r_debug_cull, 0, 0) EXTERN_CVAR(Int, r_portal_recursions) @@ -240,6 +241,7 @@ void RenderPolyScene::RenderPortals(int portalDepth) PolyDrawArgs args; args.objectToClip = &WorldToClip; args.mode = TriangleDrawMode::Fan; + args.uniforms.globvis = (float)swrenderer::r_WallVisibility; args.uniforms.color = 0; args.uniforms.light = 256; args.uniforms.flags = TriUniforms::fixed_light; diff --git a/src/polyrenderer/scene/poly_sky.cpp b/src/polyrenderer/scene/poly_sky.cpp index 41bca43ff..e102cde50 100644 --- a/src/polyrenderer/scene/poly_sky.cpp +++ b/src/polyrenderer/scene/poly_sky.cpp @@ -55,6 +55,7 @@ void PolySkyDome::Render(const TriMatrix &worldToClip) int rc = mRows + 1; PolyDrawArgs args; + args.uniforms.globvis = (float)swrenderer::r_WallVisibility; args.uniforms.light = 256; args.uniforms.flags = 0; args.uniforms.subsectorDepth = RenderPolyScene::SkySubsectorDepth; diff --git a/src/polyrenderer/scene/poly_sprite.cpp b/src/polyrenderer/scene/poly_sprite.cpp index ce0547f62..c6cf88ee1 100644 --- a/src/polyrenderer/scene/poly_sprite.cpp +++ b/src/polyrenderer/scene/poly_sprite.cpp @@ -138,6 +138,7 @@ void RenderPolySprite::Render(const TriMatrix &worldToClip, const Vec4f &clipPla bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); PolyDrawArgs args; + args.uniforms.globvis = (float)swrenderer::r_SpriteVisibility; args.uniforms.flags = 0; if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) { diff --git a/src/polyrenderer/scene/poly_wall.cpp b/src/polyrenderer/scene/poly_wall.cpp index 1bf7cf24b..009c5fca7 100644 --- a/src/polyrenderer/scene/poly_wall.cpp +++ b/src/polyrenderer/scene/poly_wall.cpp @@ -247,6 +247,7 @@ void RenderPolyWall::Render(const TriMatrix &worldToClip, const Vec4f &clipPlane } PolyDrawArgs args; + args.uniforms.globvis = (float)swrenderer::r_WallVisibility; args.uniforms.light = (uint32_t)(GetLightLevel() / 255.0f * 256.0f); args.uniforms.flags = 0; args.uniforms.subsectorDepth = SubsectorDepth; diff --git a/src/polyrenderer/scene/poly_wallsprite.cpp b/src/polyrenderer/scene/poly_wallsprite.cpp index ba09c77c1..4fc9e4994 100644 --- a/src/polyrenderer/scene/poly_wallsprite.cpp +++ b/src/polyrenderer/scene/poly_wallsprite.cpp @@ -100,6 +100,7 @@ void RenderPolyWallSprite::Render(const TriMatrix &worldToClip, const Vec4f &cli bool fullbrightSprite = ((thing->renderflags & RF_FULLBRIGHT) || (thing->flags5 & MF5_BRIGHT)); PolyDrawArgs args; + args.uniforms.globvis = (float)swrenderer::r_WallVisibility; if (fullbrightSprite || swrenderer::fixedlightlev >= 0 || swrenderer::fixedcolormap) { args.uniforms.light = 256; diff --git a/src/swrenderer/drawers/r_drawers.h b/src/swrenderer/drawers/r_drawers.h index 0a79f26d5..0492930d9 100644 --- a/src/swrenderer/drawers/r_drawers.h +++ b/src/swrenderer/drawers/r_drawers.h @@ -230,6 +230,7 @@ struct TriUniforms uint16_t fade_green; uint16_t fade_blue; uint16_t desaturate; + float globvis; uint32_t flags; enum Flags { diff --git a/src/swrenderer/scene/r_light.cpp b/src/swrenderer/scene/r_light.cpp index 7ef86ca25..4059a73bf 100644 --- a/src/swrenderer/scene/r_light.cpp +++ b/src/swrenderer/scene/r_light.cpp @@ -43,7 +43,6 @@ namespace swrenderer double r_FloorVisibility; float r_TiltVisibility; double r_SpriteVisibility; - double r_ParticleVisibility; int fixedlightlev; FSWColormap *fixedcolormap; diff --git a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp index c5f7405f5..6f3a725fa 100644 --- a/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp +++ b/tools/drawergen/fixedfunction/drawtrianglecodegen.cpp @@ -613,7 +613,6 @@ void DrawTriangleCodegen::CalculateGradients() } shade = (64.0f - (SSAFloat(light * 255 / 256) + 12.0f) * 32.0f / 128.0f) / 32.0f; - globVis = SSAFloat(1706.0f / 32.0f); } void DrawTriangleCodegen::LoadArgs(SSAValue args, SSAValue thread_data) @@ -671,7 +670,9 @@ void DrawTriangleCodegen::LoadUniforms(SSAValue uniforms) SSAShort fade_green = uniforms[0][11].load(true); SSAShort fade_blue = uniforms[0][12].load(true); SSAShort desaturate = uniforms[0][13].load(true); - SSAInt flags = uniforms[0][14].load(true); + globVis = uniforms[0][14].load(true); + globVis = globVis * SSAFloat(1.0f / 32.0f); + SSAInt flags = uniforms[0][15].load(true); shade_constants.light = SSAVec4i(light_blue.zext_int(), light_green.zext_int(), light_red.zext_int(), light_alpha.zext_int()); shade_constants.fade = SSAVec4i(fade_blue.zext_int(), fade_green.zext_int(), fade_red.zext_int(), fade_alpha.zext_int()); shade_constants.desaturate = desaturate.zext_int(); diff --git a/tools/drawergen/llvmdrawers.cpp b/tools/drawergen/llvmdrawers.cpp index 0ce8ee830..995b5b849 100644 --- a/tools/drawergen/llvmdrawers.cpp +++ b/tools/drawergen/llvmdrawers.cpp @@ -360,6 +360,7 @@ llvm::Type *LLVMDrawers::GetTriUniformsStruct(llvm::LLVMContext &context) elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_green; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t fade_blue; elements.push_back(llvm::Type::getInt16Ty(context)); // uint16_t desaturate; + elements.push_back(llvm::Type::getFloatTy(context)); // float globvis; elements.push_back(llvm::Type::getInt32Ty(context)); // uint32_t flags; elements.push_back(GetTriMatrixStruct(context)); // TriMatrix objectToClip TriUniformsStruct = llvm::StructType::create(context, elements, "TriUniforms", false)->getPointerTo();