tgoop.com/madcsharp/38
Last Update:
Compiling Shaders on Device with Fully Dynamic Shader
The idea is that in Unity you can load a shader asset via an asset bundle. In this asset, there is either compiled bytecode (for Metal or Vulkan, as well as DX11 DXBC / DX12 DXIL) or text.
The binary format of the asset bundle is known — there are plenty of open-source rippers on GitHub.
The binary format of the shader is also known.
This leaves only compiling the shader. The simplest case is when you have an Android device, your code is in GLSL, and you only need OpenGL ES. In that case, simply write the text into the shader asset.
[At first you will need to add the available shader variants in the Shader asset as they are always stored, and this will need to be done anyway.]
It's more complicated when you have GLSL and Vulkan:
You then need to compile the SPIR-V Cross compiler for Android. It's written in C++, so there shouldn't be any issues.
If you prefer HLSL — feel free to port DXC to Android. That shouldn't be too hard either.
The resulting output is also written into the shader inside the asset bundle.
Then load the asset bundle into Unity.
??????
PROFIT!
BY MadSharp: Unsafe
Share with your friend now:
tgoop.com/madcsharp/38