Install a copy of glslc
you can get this from https://github.com/google/shaderc google's shaderc repository.
Clone a copy of your preferred leaked NMS shaders, for this gist I'm using the ones at https://github.com/EthanRDoesMC/NMS-ShaderCode
The repository contains the build targets (the .BIN files in the top level) and the actual shaders (the glsl header files in the code
directory)
When compiling a shader you'll need to know what target you're building. For example if you were to edit the Binoculars, the target in UI.SHADER.BIN
for binoculars is:
[[FS_BINOCS]]
// =================================================================================================
#define D_BINOCS
#include "Fullscreen/UIFragment.shader.h"
Which includes the header file to use and relevant defines. The easiest way to compile this I've found is to create a text file in the code
directory of the shader repository and add the following lines
a.txt
//required for all shaders, note the extensions probably aren't needed
#version 450 core
#extension GL_ARB_gpu_shader5 : enable
#extension GL_ARB_shader_ballot : enable
#extension GL_GOOGLE_include_directive : require
#extension GL_GOOGLE_cpp_style_line_directive : require
#define D_PLATFORM_VULKAN
#define D_PLATFORM_GLSL
//important for specific shader, for example D_VERTEX, or D_FRAGMENT. You should check defines.shader.h for other types
#define D_FRAGMENT
//define from the build target
#define D_BINOCS
//include the header
#include "Fullscreen/UIFragment.shader.h"
You can then compile this with
glslc -c -fauto-map-locations -fauto-bind-uniforms -fshader-stage=fragment -std="450core" -x glsl .\a.txt --target-env=vulkan -I.
Note that -fshader-stage
should be relevant to the type of shader being compiled, Hello Games only targets the following shaders:
shaderc_vertex_shader
shaderc_fragment_shader
shaderc_compute_shader
shaderc_geometry_shader
shaderc_tess_control_shader
shaderc_tess_evaluation_shader
If you're unsure, shaderc_vertex_shader
is usually the default