Add RenderState.SetDepthFadeFalloff

This commit is contained in:
Magnus Norddahl 2024-09-08 20:32:30 +02:00
commit c62bb7a0f0
8 changed files with 20 additions and 3 deletions

View file

@ -193,6 +193,7 @@ public:
mSurfaceUniforms.uLightFactor = 0.0f;
mSurfaceUniforms.uFogDensity = 0.0f;
mSurfaceUniforms.uLightLevel = -1.0f;
mSurfaceUniforms.uDepthFadeFalloff = 0.0f;
mSpecialEffect = EFF_NONE;
mLightIndex = -1;
mBoneIndexBase = -1;
@ -263,6 +264,11 @@ public:
mSurfaceUniforms.uDesaturationFactor = 0.0f;
}
void SetDepthFadeFalloff(float falloff)
{
mSurfaceUniforms.uDepthFadeFalloff = falloff;
}
void SetTextureClamp(bool on)
{
if (on) mTextureClamp = TM_CLAMPY;

View file

@ -44,6 +44,6 @@ struct SurfaceUniforms
float uAlphaThreshold;
int uTextureIndex;
float padding2;
float uDepthFadeFalloff;
float padding3;
};

View file

@ -185,6 +185,8 @@ std::unique_ptr<VulkanShader> VkShaderManager::LoadFragShader(FString shadername
if (!key.AlphaTest) definesBlock << "#define NO_ALPHATEST\n";
if (key.GBufferPass) definesBlock << "#define GBUFFER_PASS\n";
if (key.DepthFadeFalloff) definesBlock << "#define USE_DEPTHFADEFALLOFF\n";
if (key.Simple2D) definesBlock << "#define SIMPLE2D\n";
if (key.ClampY) definesBlock << "#define TEXF_ClampY\n";
if (key.Brightmap) definesBlock << "#define TEXF_Brightmap\n";

View file

@ -79,7 +79,8 @@ public:
uint64_t UseLevelMesh : 1; // USE_LEVELMESH
uint64_t FogBalls : 1; // FOGBALLS
uint64_t NoFragmentShader : 1;
uint64_t Unused : 42;
uint64_t DepthFadeFalloff : 1;
uint64_t Unused : 41;
};
uint64_t AsQWORD = 0;
};

View file

@ -258,6 +258,8 @@ void VkRenderState::ApplyRenderPass(int dt)
pipelineKey.ShaderKey.Detailmap = (uTextureMode & TEXF_Detailmap) != 0;
pipelineKey.ShaderKey.Glowmap = (uTextureMode & TEXF_Glowmap) != 0;
pipelineKey.ShaderKey.DepthFadeFalloff = mSurfaceUniforms.uDepthFadeFalloff > 0.0f;
// The way GZDoom handles state is just plain insanity!
int fogset = 0;
if (mFogEnabled)

View file

@ -68,7 +68,7 @@ struct SurfaceUniforms
float uAlphaThreshold;
int uTextureIndex;
float padding2;
float uDepthFadeFalloff;
float padding3;
};

View file

@ -27,6 +27,11 @@ void main()
if (material.Base.a <= uAlphaThreshold) discard;
#endif
#ifdef USE_DEPTHFADEFALLOFF
// To do: add linear depth sampling here
// material.Base.a *= clamp((depth.r - pixelpos.w) / uDepthFadeFalloff, 0.0, 1.0);
#endif
FragColor = ProcessLightMode(material);
#ifdef DITHERTRANS

View file

@ -69,6 +69,7 @@ layout(push_constant) uniform PushConstants
#define uLightDist data[uDataIndex].uLightDist
#define uAlphaThreshold data[uDataIndex].uAlphaThreshold
#define uTextureIndex data[uDataIndex].uTextureIndex
#define uDepthFadeFalloff data[uDataIndex].uDepthFadeFalloff
#define VULKAN_COORDINATE_SYSTEM
#define HAS_UNIFORM_VERTEX_DATA