A cross-platform headless app that validates the ShaderTool → ShaderCache → NativeEngine pipeline by rendering a scene using pre-compiled shaders and saving the result as a PNG screenshot.
The app has two parts: a JavaScript scene that describes what to render, and a C++ host that loads pre-compiled shaders, creates a graphics device, executes the scene script, and saves the rendered frame as a PNG.
npm run buildinJavaScript/bundles the scene script and extracts preprocessed shader source files.- At CMake build time, ShaderTool compiles the shader source files into a binary cache (
shaders.bin). - At run time, the app loads
shaders.bininto ShaderCache, renders the scene to an offscreen texture, and writesoutput.png.
cd JavaScript npm install npm run buildThis produces:
JavaScript/dist/index.js— bundled scene scriptJavaScript/dist/shaders/<name>/vertex.fx— preprocessed vertex shadersJavaScript/dist/shaders/<name>/fragment.fx— preprocessed fragment shaders
Configure and build the PrecompiledShaderTest target as part of the normal BabylonNative CMake build. The CMakeLists.txt invokes ShaderTool to compile the shader files into shaders.bin and copies all assets next to the executable.