From 58fecd4b9256bf5b3133fe9c9b4f0f94c353eae5 Mon Sep 17 00:00:00 2001 From: nashmuhandes Date: Mon, 9 Sep 2024 18:08:10 +0800 Subject: [PATCH] Move depth fade definition to GLDEFS --- src/common/rendering/hwrenderer/data/hw_renderstate.h | 5 ----- src/common/rendering/vulkan/vk_levelmesh.cpp | 2 ++ src/common/rendering/vulkan/vk_renderstate.cpp | 2 ++ src/common/textures/gametexture.h | 3 +++ src/playsim/actor.h | 1 - src/playsim/p_mobj.cpp | 1 - src/r_data/gldefs.cpp | 5 +++++ src/rendering/hwrenderer/scene/hw_sprites.cpp | 5 ----- src/scripting/vmthunks_actors.cpp | 1 - wadsrc/static/zscript/actors/actor.zs | 3 --- 10 files changed, 12 insertions(+), 16 deletions(-) diff --git a/src/common/rendering/hwrenderer/data/hw_renderstate.h b/src/common/rendering/hwrenderer/data/hw_renderstate.h index b407bd3e7..d5fddf554 100644 --- a/src/common/rendering/hwrenderer/data/hw_renderstate.h +++ b/src/common/rendering/hwrenderer/data/hw_renderstate.h @@ -264,11 +264,6 @@ public: mSurfaceUniforms.uDesaturationFactor = 0.0f; } - void SetDepthFadeThreshold(float falloff) - { - mSurfaceUniforms.uDepthFadeThreshold = falloff; - } - void SetTextureClamp(bool on) { if (on) mTextureClamp = TM_CLAMPY; diff --git a/src/common/rendering/vulkan/vk_levelmesh.cpp b/src/common/rendering/vulkan/vk_levelmesh.cpp index 5dd616a2e..0164cd9fc 100644 --- a/src/common/rendering/vulkan/vk_levelmesh.cpp +++ b/src/common/rendering/vulkan/vk_levelmesh.cpp @@ -865,10 +865,12 @@ void VkLevelMeshUploader::UploadUniforms() { auto source = material.mMaterial->Source(); surfaceUniforms.uSpecularMaterial = { source->GetGlossiness(), source->GetSpecularLevel() }; + surfaceUniforms.uDepthFadeThreshold = source->GetDepthFadeThreshold(); surfaceUniforms.uTextureIndex = Mesh->fb->GetBindlessTextureIndex(material.mMaterial, material.mClampMode, material.mTranslation); } else { + surfaceUniforms.uDepthFadeThreshold = 0.f; surfaceUniforms.uTextureIndex = 0; } } diff --git a/src/common/rendering/vulkan/vk_renderstate.cpp b/src/common/rendering/vulkan/vk_renderstate.cpp index fdfc8fe09..d64f5323c 100644 --- a/src/common/rendering/vulkan/vk_renderstate.cpp +++ b/src/common/rendering/vulkan/vk_renderstate.cpp @@ -413,9 +413,11 @@ void VkRenderState::ApplySurfaceUniforms() mSurfaceUniforms.uTextureIndex = static_cast(mMaterial.mMaterial)->GetBindlessIndex(mMaterial); mSurfaceUniforms.uSpecularMaterial = { source->GetGlossiness(), source->GetSpecularLevel() }; + mSurfaceUniforms.uDepthFadeThreshold = source->GetDepthFadeThreshold(); } else { + mSurfaceUniforms.uDepthFadeThreshold = 0.f; mSurfaceUniforms.uTextureIndex = 0; } mMaterial.mChanged = false; diff --git a/src/common/textures/gametexture.h b/src/common/textures/gametexture.h index a63dc1b37..e7b04afc2 100644 --- a/src/common/textures/gametexture.h +++ b/src/common/textures/gametexture.h @@ -118,6 +118,7 @@ class FGameTexture FVector2 detailScale = { 1.f, 1.f }; float Glossiness = 10.f; float SpecularLevel = 0.1f; + float DepthFadeThreshold = 0.0f; float shaderspeed = 1.f; int shaderindex = 0; @@ -258,6 +259,8 @@ public: float GetGlossiness() const { return Glossiness; } float GetSpecularLevel() const { return SpecularLevel; } + float GetDepthFadeThreshold() const { return DepthFadeThreshold; } + void CopySize(FGameTexture* BaseTexture, bool forfont = false) { Base->CopySize(BaseTexture->Base.get()); diff --git a/src/playsim/actor.h b/src/playsim/actor.h index b9321f43d..1adccf81c 100644 --- a/src/playsim/actor.h +++ b/src/playsim/actor.h @@ -1128,7 +1128,6 @@ public: DVector2 AutomapOffsets; // Offset the actors' sprite view on the automap by these coordinates. float isoscaleY; // Y-scale to compensate for Y-billboarding for isometric sprites float isotheta; // Rotation angle to compensate for Y-billboarding for isometric sprites - double DepthFadeThreshold; // [Nash] "soft particle" fade threshold in map units DRotator Angles; DRotator ViewAngles; // Angle offsets for cameras TObjPtr ViewPos; // Position offsets for cameras diff --git a/src/playsim/p_mobj.cpp b/src/playsim/p_mobj.cpp index 40b66192d..e84783c33 100644 --- a/src/playsim/p_mobj.cpp +++ b/src/playsim/p_mobj.cpp @@ -394,7 +394,6 @@ void AActor::Serialize(FSerializer &arc) A("WorldOffset", WorldOffset) ("modelData", modelData) A("LandingSpeed", LandingSpeed) - A("DepthFadeThreshold", DepthFadeThreshold) ("unmorphtime", UnmorphTime) ("morphflags", MorphFlags) diff --git a/src/r_data/gldefs.cpp b/src/r_data/gldefs.cpp index d4bc5d393..8b62885fc 100644 --- a/src/r_data/gldefs.cpp +++ b/src/r_data/gldefs.cpp @@ -1346,6 +1346,11 @@ class GLDefsParser sc.MustGetFloat(); mlay.SpecularLevel = (float)sc.Float; } + else if (sc.Compare("depthfadethreshold")) + { + sc.MustGetFloat(); + tex->DepthFadeThreshold = (float)sc.Float; + } else if (sc.Compare("speed")) { sc.MustGetFloat(); diff --git a/src/rendering/hwrenderer/scene/hw_sprites.cpp b/src/rendering/hwrenderer/scene/hw_sprites.cpp index c741e56ad..9304e09c3 100644 --- a/src/rendering/hwrenderer/scene/hw_sprites.cpp +++ b/src/rendering/hwrenderer/scene/hw_sprites.cpp @@ -130,9 +130,6 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent) state.SetRenderStyle(RenderStyle); state.SetTextureMode(RenderStyle); - if (actor) - state.SetDepthFadeThreshold(actor->DepthFadeThreshold); - if (hw_styleflags == STYLEHW_NoAlphaTest) { state.AlphaFunc(Alpha_GEqual, 0.f); @@ -328,8 +325,6 @@ void HWSprite::DrawSprite(HWDrawInfo *di, FRenderState &state, bool translucent) state.ClearDepthBias(); } - state.SetDepthFadeThreshold(0.0f); - // [Nash] hitbox debug if (actor && r_showhitbox) { diff --git a/src/scripting/vmthunks_actors.cpp b/src/scripting/vmthunks_actors.cpp index 225fd8f08..acf253807 100644 --- a/src/scripting/vmthunks_actors.cpp +++ b/src/scripting/vmthunks_actors.cpp @@ -2130,7 +2130,6 @@ DEFINE_FIELD(AActor, UnmorphTime) DEFINE_FIELD(AActor, MorphFlags) DEFINE_FIELD(AActor, PremorphProperties) DEFINE_FIELD(AActor, MorphExitFlash) -DEFINE_FIELD(AActor, DepthFadeThreshold) DEFINE_FIELD_X(FCheckPosition, FCheckPosition, thing); DEFINE_FIELD_X(FCheckPosition, FCheckPosition, pos); diff --git a/wadsrc/static/zscript/actors/actor.zs b/wadsrc/static/zscript/actors/actor.zs index 487d073e3..6984bcd20 100644 --- a/wadsrc/static/zscript/actors/actor.zs +++ b/wadsrc/static/zscript/actors/actor.zs @@ -262,7 +262,6 @@ class Actor : Thinker native native uint freezetics; native Vector2 AutomapOffsets; native double LandingSpeed; - native double DepthFadeThreshold; meta String Obituary; // Player was killed by this actor meta String HitObituary; // Player was killed by this actor in melee @@ -369,7 +368,6 @@ class Actor : Thinker native property ShadowPenaltyFactor: ShadowPenaltyFactor; property AutomapOffsets : AutomapOffsets; property LandingSpeed: LandingSpeed; - property DepthFadeThreshold: DepthFadeThreshold; // need some definition work first //FRenderStyle RenderStyle; @@ -459,7 +457,6 @@ class Actor : Thinker native RenderRequired 0; FriendlySeeBlocks 10; // 10 (blocks) * 128 (one map unit block) LandingSpeed -8; // landing speed from a jump with normal gravity (squats the player's view) - DepthFadeThreshold 0.0; // [Nash] "soft particle" fade factor in map units } // Functions