alpha testing improvements

This commit is contained in:
Turánszki János
2025-01-27 08:47:44 +01:00
parent 2e51d612e7
commit 0dc0ede9ea
4 changed files with 19 additions and 18 deletions
+15 -16
View File
@@ -7,9 +7,9 @@
#define SHADOW_MASK_ENABLED
#endif // TRANSPARENT
#if !defined(TRANSPARENT) && !defined(PREPASS)
#if !defined(TRANSPARENT) && !defined(PREPASS) && !defined(ENVMAPRENDERING)
#define DISABLE_ALPHATEST
#endif // !defined(TRANSPARENT) && !defined(PREPASS)
#endif // !defined(TRANSPARENT) && !defined(PREPASS) && !defined(ENVMAPRENDERING)
#ifdef PLANARREFLECTION
#define DISABLE_ENVMAPS
@@ -475,6 +475,12 @@ PixelInput main(VertexInput input)
#pragma PSSL_target_output_format (target 0 FMT_32_R)
#endif // __PSSL__ && PREPASS
#ifdef DISABLE_ALPHATEST
#define APPEND_COVERAGE_OUTPUT
#else
#define APPEND_COVERAGE_OUTPUT , out uint coverage : SV_Coverage
#endif // DISABLE_ALPHATEST
#ifdef EARLY_DEPTH_STENCIL
[earlydepthstencil]
#endif // EARLY_DEPTH_STENCIL
@@ -482,12 +488,12 @@ PixelInput main(VertexInput input)
// entry point:
#ifdef PREPASS
#ifdef DEPTHONLY
void main(PixelInput input, in uint primitiveID : SV_PrimitiveID, out uint coverage : SV_Coverage)
void main(PixelInput input, in uint primitiveID : SV_PrimitiveID APPEND_COVERAGE_OUTPUT)
#else
uint main(PixelInput input, in uint primitiveID : SV_PrimitiveID, out uint coverage : SV_Coverage) : SV_Target
uint main(PixelInput input, in uint primitiveID : SV_PrimitiveID APPEND_COVERAGE_OUTPUT) : SV_Target
#endif // DEPTHONLY
#else
float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target
float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace APPEND_COVERAGE_OUTPUT) : SV_Target
#endif // PREPASS
@@ -607,16 +613,6 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target
#endif // OBJECTSHADER_USE_COLOR
#ifndef DISABLE_ALPHATEST
#ifdef TRANSPARENT
// Alpha test only for transparents
// - Prepass will write alpha coverage mask
// - Opaque will use [earlydepthstencil] and COMPARISON_EQUAL depth test on top of depth prepass
clip(surface.baseColor.a - material.GetAlphaTest() - meshinstance.GetAlphaTest());
#endif // TRANSPARENT
#endif // DISABLE_ALPHATEST
#ifndef WATER
#ifdef OBJECTSHADER_USE_TANGENT
[branch]
@@ -1086,9 +1082,12 @@ float4 main(PixelInput input, in bool is_frontface : SV_IsFrontFace) : SV_Target
color = saturateMediump(color);
#ifndef DISABLE_ALPHATEST
coverage = AlphaToCoverage(color.a, material.GetAlphaTest() + meshinstance.GetAlphaTest(), input.pos); // opaque soft alpha test (MSAA, temporal AA support)
#endif // DISABLE_ALPHATEST
// end point:
#ifdef PREPASS
coverage = AlphaToCoverage(color.a, material.GetAlphaTest() + meshinstance.GetAlphaTest(), input.pos); // opaque soft alpha test (temporal AA, etc)
#ifndef DEPTHONLY
PrimitiveID prim;
prim.primitiveIndex = primitiveID;
+2 -1
View File
@@ -8310,6 +8310,7 @@ void RefreshEnvProbes(const Visibility& vis, CommandList cmd)
cb.cameras[i].internal_resolution = uint2(probe.texture.desc.width, probe.texture.desc.height);
cb.cameras[i].internal_resolution_rcp.x = 1.0f / cb.cameras[i].internal_resolution.x;
cb.cameras[i].internal_resolution_rcp.y = 1.0f / cb.cameras[i].internal_resolution.y;
cb.cameras[i].sample_count = probe.GetSampleCount();
XMStoreFloat4(&cb.cameras[i].frustum_corners.cornersNEAR[0], XMVector3TransformCoord(XMVectorSet(-1, 1, 1, 1), invVP));
XMStoreFloat4(&cb.cameras[i].frustum_corners.cornersNEAR[1], XMVector3TransformCoord(XMVectorSet(1, 1, 1, 1), invVP));
@@ -8349,7 +8350,7 @@ void RefreshEnvProbes(const Visibility& vis, CommandList cmd)
static wi::unordered_map<uint32_t, Texture> render_textures;
static std::mutex locker;
{
const uint32_t required_sample_count = probe.IsMSAA() ? EnvironmentProbeComponent::envmapMSAASampleCount : 1;
const uint32_t required_sample_count = probe.GetSampleCount();
std::scoped_lock lck(locker);
RenderTextureID id_depth = {};
+1
View File
@@ -1307,6 +1307,7 @@ namespace wi::scene
inline bool IsDirty() const { return _flags & DIRTY; }
inline bool IsRealTime() const { return _flags & REALTIME; }
inline bool IsMSAA() const { return _flags & MSAA; }
inline uint32_t GetSampleCount() const { return IsMSAA() ? envmapMSAASampleCount : 1; }
size_t GetMemorySizeInBytes() const;
+1 -1
View File
@@ -9,7 +9,7 @@ namespace wi::version
// minor features, major updates, breaking compatibility changes
const int minor = 71;
// minor bug fixes, alterations, refactors, updates
const int revision = 665;
const int revision = 666;
const std::string version_string = std::to_string(major) + "." + std::to_string(minor) + "." + std::to_string(revision);