Any of you #graphicsdev folk out there have any good recommendations for a "write once, use anywhere" shader setup? I'd love something that I could drop into a build pipeline to have a single shader file that I could then build for (minimally) D3D11 and GL, although D3D12 and Vulkan would be nice to support as well.
I've seen a lot of HLSL -> GLSL converters, but there seem to be a bunch of options with a bunch of trade-offs and I am not clear on which is best (or if there's a secret third thing where you write in some OTHER shader language that can cross-compile to the others)
@JoshJers You can do 95% of this with a header file per API and a bunch of #defines. The last 5% is always tricky of course - you always seem to end up with some #ifdef HLSL sections - honestly that's probably the sweet spot anyway. To "fix" those, you start basically writing your own shader compiler for your own custom language, and that's a lot of work.

@TomF honestly, that's a path that hadn't occurred to me and, yeah, that sounds like probably the right one - I'm not doing anything wild with any of these shaders so I don't even think I'd need that many #defines

Thanks!

@JoshJers Try compiling HLSL to SpirV with dxc.
GitHub - shader-slang/slang: Making it easier to work with shaders

Making it easier to work with shaders. Contribute to shader-slang/slang development by creating an account on GitHub.

GitHub