I’m trying to develop a service that loads a user-uploaded AssetBundle into a server application (Unity standalone build) to capture video.
The user build the AssetBundle for Windows target, but when I load it on a server running on a non-Windows platform (Linux, MacOS), the shaders don’t work properly and appear purple.
I understand that this is a shader compatibility issue due to differences in graphics APIs, but I want to fix it (as I don’t want to run the server on Windows).
I’ve considered the following options
- include the shaders in the server runtime
(I don’t think this is possible due to too many shader variants). - include the shader source in an asset bundle and build it on load.
- translate the compiled shader (hlsl bytecode) into the shader language of the server’s graphics APIs.
In this case, I found documentation that Unity compiles all shaders with an HLSL compiler and then translates them to the shader language of the target platform using HLSLcc (Unity - Manual: Shader compilation).
I would like to work around 2 and 3, but I understand that in both cases Unity does not provide an API to build the shaders at runtime or load the built binaries.
Is there a way to implement this?