This is a post I wrote a little while ago internally for the team I was on all about reverse z (it took me longer than I'd like to admit to wrap my head around it 😅🙈). Hopefully, someone finds it helpful! https://tomhultonharrop.com/mathematics/graphics/2023/08/06/reverse-z.html

Heavily inspired by the work of @reedbeta and @benjamin

Reverse Z (and why it’s so awesome)

Topic

Tom Hulton-Harrop

@tom_h_h @reedbeta @benjamin
" (using C++20’s bitcast"

TIL about bitcast. This also works just fine despite what the language lawyers bleat:

uint32_t fromi = *(uint32_t*)(&from);

@TomF @tom_h_h @reedbeta @benjamin it does stop working if you have strict aliasing on in gcc/clang (but yeah, if you value your sanity you’d have strict aliasing off)
@aras @TomF @tom_h_h @reedbeta @benjamin
yeah, but it is on by default, so it sure is a footgun