Aisha Brown's Avatar

Aisha Brown

@aishization

Graphics programming at Supermassive Games. Previously Unity and Feral Interactive

680
Followers
426
Following
5
Posts
12.09.2023
Joined
Posts Following

Latest posts by Aisha Brown @aishization

Arbitrary depth write (SV_Depth) might be fine in any case as long as you're aware of the potential performance impact

15.02.2026 15:03 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 0 ๐Ÿ“Œ 0

Yes, as long as you can ensure fragments are writing depth as being further away from the camera and never closer. It should be a viable approach.

15.02.2026 15:00 ๐Ÿ‘ 1 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

You can mitigate some of the impact by using SV_DepthGreaterEqual (hlsl system semantic) where the fragment shader will write a depth value greater or equal, which allows the early depth testing to still occur, but restricts the the valid depth values you can write

15.02.2026 14:07 ๐Ÿ‘ 4 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0

You can, but you should be careful about doing so, as it will disable some hardware optimizations like early z testing (testing that gets run before the fragment shader is dispatched). So it will have a performance impact.

15.02.2026 14:06 ๐Ÿ‘ 3 ๐Ÿ” 0 ๐Ÿ’ฌ 2 ๐Ÿ“Œ 0

be aware, if you are targetting cross platform and not just directx/hlsl then some shader compilers may act counterintuitively with NaN/Inf. Specifically, in Metal with fastmath enabled the shader compiler can treat NaN or INF as undefined behaviour. It may delete whole chunks of code

26.05.2025 10:16 ๐Ÿ‘ 16 ๐Ÿ” 0 ๐Ÿ’ฌ 1 ๐Ÿ“Œ 0