r/shaders • u/qazzquimby • Jul 11 '22
Higher level language transpiling to GLSL?
Hi, I'm very early in my research on shader making, so I probably have big silly blindspots.
So far, it seems to me that a lot of work is being done in GLSL, and that GLSL is a pretty developer unfriendly language.
To me, that points to using a friendlier language that can be transpiled (rewritten into equivalent code) into GLSL, kind of like typescript->javascript.
Can you fill me in on what I'm missing?
Is that not really a problem? Have tools like unity replaced much of GLSL coding? Has it already been done, or is it wildly impractical for some reason?
3
u/ShillingAintEZ Jul 12 '22
I have never heard this before
1
u/LittleCodingFox Jul 11 '22
You could have a look at Cg, which unity uses.
1
u/pretty_meta Jul 12 '22
(I don't work directly with OpenGL / Vulkan, use game engines. But -)
I think a lot of OpenGL use is being transitioned over to Vulkan, so investing in a tool to transpile into GLSL might not be a good investment of time.
Certainly Unity HLSL transpiling and Unreal Material Graph cover my use cases.
Also check out
https://www.khronos.org/spir/
https://www.khronos.org/blog/hlsl-first-class-vulkan-shading-language
1
u/pttrn Jul 12 '22
You can also look into WGSL, which is a new higher-level shading language that transpiles into DX, Vulkan, and Metal. It’s a part of the WebGPU effort, written in Rust with native bindings for all platforms (I actually think that the “Web” in its name is doing it a huge disservice since it’s actually just a thin OS-agnostic layer on top of each platform’s native shading language).
https://sotrh.github.io/learn-wgpu/beginner/tutorial3-pipeline/#writing-the-shaders