NoMansSky:Tutorials/Vulkan Shaders: Difference between revisions

From Step Mods | Change The Game
No edit summary
Line 20: Line 20:


Don't forget to rebuild all the relevant shader variants with your changes as well. Each variant corresponds to a combination of flags found in the material files (e.g. _F01_DIFFUSEMAP). There are 64 possible flags. The value on the end of the shader name, such as '''ATMOSPHERE_FRAG_CLOUD_769.SPV''' is the 64-bit mask of the material flags. In this case, the value is 769. In binary, it would be <code>00000000 00000000 00000000 00000000 00000000 00000000 00000011 00000001</code>. This means, that flag 01, 09 and 10 (_F01_DIFFUSEMAP, _F09_TRANSPARENT, _F10_NORECEIVESHADOW) are defined for this shader (smallest bit is on the right)."
Don't forget to rebuild all the relevant shader variants with your changes as well. Each variant corresponds to a combination of flags found in the material files (e.g. _F01_DIFFUSEMAP). There are 64 possible flags. The value on the end of the shader name, such as '''ATMOSPHERE_FRAG_CLOUD_769.SPV''' is the 64-bit mask of the material flags. In this case, the value is 769. In binary, it would be <code>00000000 00000000 00000000 00000000 00000000 00000000 00000011 00000001</code>. This means, that flag 01, 09 and 10 (_F01_DIFFUSEMAP, _F09_TRANSPARENT, _F10_NORECEIVESHADOW) are defined for this shader (smallest bit is on the right)."
{{NMSPageClose}}
{{NMSPageClose}}

Revision as of 03:58, July 29, 2020

Template:TOC right

Vulkan Shader Modding[edit | edit source]

Editing shaders after the NMS Vulkan update (2.0+) has become tricky. GaticusHax has found a way to mod shaders nontheless. Here is his comment from the NMS modding discord:

"If anyone wants to mod shaders...
You should download this tool package: https://github.com/google/shaderc
Direct link to download: https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2017_release.html

These are command line tools, for compiling glsl to vulkan and for cross-compiling (decompiling) vulkan to glsl. There are similar tools in the Vulkan API but these are better. Unzip it wherever you want (e.g. C:\Tools\google-shaderc\).

You should add the C:\Tools\google-shaderc\bin path to your PATH environment variable.

Use spirv-cross to decompile the binary vulkan shaders to human-readable glsl (e.g. spirv-cross --version 450 --vulkan-semantics --stage vert PSTREAM_VERT_PSTREAM_STARS_0.SPV > PSTREAM_VERT_PSTREAM_STARS_0.GLSL).

Edit the glsl. Use glslc to compile the glsl to vulkan (e.g. glslc -std=450 -fshader-stage=vertex -o "PSTREAM_VERT_PSTREAM_STARS_0.SPV" "PSTREAM_VERT_PSTREAM_STARS_0.GLSL").

Make sure you set the correct shader stage. See glslc --help for options.

Don't forget to rebuild all the relevant shader variants with your changes as well. Each variant corresponds to a combination of flags found in the material files (e.g. _F01_DIFFUSEMAP). There are 64 possible flags. The value on the end of the shader name, such as ATMOSPHERE_FRAG_CLOUD_769.SPV is the 64-bit mask of the material flags. In this case, the value is 769. In binary, it would be 00000000 00000000 00000000 00000000 00000000 00000000 00000011 00000001. This means, that flag 01, 09 and 10 (_F01_DIFFUSEMAP, _F09_TRANSPARENT, _F10_NORECEIVESHADOW) are defined for this shader (smallest bit is on the right)."

Template:NMSPageClose