Custom Shader Compiler Plugin

Custom Shader Compiler Plugin

SceneComposer SDK supplies basic means to create custom shader compilers plugins. A shader compiler plugin is a SceneComposer plugin which implements the IShaderCompiler interface. The IShaderCompiler interface is pretty simple and has only 3 methods to implement:

	string SupportedType { get; }

Specifies how this shader compiler can be referred by a platform. For example; if SupportedType is "DEVICEShaderCompiler" this shader compiler can be referred using the string "custom://DEVICEShaderCompiler". (DEVICE stands for your specific device)

	void AssetCompileShaderPair(string fragmentShaderFile,
								string vertexShaderFile,
								out byte[] compiledFragmentShader,
								out byte[] compiledVertexShader,
								out IEnumerable<ShaderCompilerMessage> compilerMessages);

This method is invoked by SceneComposer when the shaders are to be compiled at the time the asset file is generated for the target system. It supplies the full name of the shader frag and vert files and must return two buffers containing the compiled frag and vert shaders. Also, a list of compiler messages can be returned which are appended into the shader compiler output window to signal for example errors or other critical conditions.

The last method is CheckShaderPair which is called to verify the shaders under the following conditions:

  • when the user invokes the "Compile Shader" option during editing. The user can invoke this option for a fragment shader, a vertex shader or a shader pair (shader program) containing both a fragment and vertex shader.
  • when the asset file for the simulation environment is generated.
  • when SceneComposer render data is updated.

	void CheckShaderPair(string fragmentShaderFile,
							string vertexShaderFile,
							out IEnumerable<ShaderCompilerMessage> compilerMessages);

Once all three methods are implemented and placing the resulting assembly into SceneComposer's plugin folder, the custom shader compiler will be available next time SceneComposer is started.


Revision #6
Created 2023-02-15 07:26:36 UTC by Tsuyoshi.Kato
Updated 2026-07-17 08:21:22 UTC by Georg Stöbich