NoMansSky:Tutorials/Vulkan Shaders: Difference between revisions
m (Z929669 moved page NoMansSky:Tutorials/Vulkan Shader Modding to NoMansSky:Tutorials/Vulkan Shaders) |
|||
(15 intermediate revisions by 3 users not shown) | |||
Line 1: | Line 1: | ||
{{PageTitle|logo=nomanssky|title=Vulkan Shader Modding}} | |||
{{ | {{NMSPage}} | ||
{{ | {{TOC}}[[Category:NoMansSky General Guides]] | ||
== Vulkan Shader Modding == | == Vulkan Shader Modding == | ||
Editing shaders after the NMS Vulkan update (2.0+) has become tricky.<br> | Editing shaders after the NMS Vulkan update (2.0+) has become tricky.<br> | ||
== The hard way == | |||
GaticusHax has found a way to mod shaders nontheless. Here is his comment from the NMS modding discord: | GaticusHax has found a way to mod shaders nontheless. Here is his comment from the NMS modding discord: | ||
Line 10: | Line 12: | ||
Direct link to download: [https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2017_release.html https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2017_release.html] | Direct link to download: [https://storage.googleapis.com/shaderc/badges/build_link_windows_vs2017_release.html 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: | 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 <code>C: | You should add the <code>C:/Tools/google-shaderc/bin</code> path to your '''PATH''' environment variable. | ||
Use <code>spirv-cross</code> to decompile the binary vulkan shaders to human-readable glsl (e.g. <code>spirv-cross --version 450 --vulkan-semantics --stage vert PSTREAM_VERT_PSTREAM_STARS_0.SPV > PSTREAM_VERT_PSTREAM_STARS_0.GLSL</code>). | Use <code>spirv-cross</code> to decompile the binary vulkan shaders to human-readable glsl (e.g. <code>spirv-cross --version 450 --vulkan-semantics --stage vert PSTREAM_VERT_PSTREAM_STARS_0.SPV > PSTREAM_VERT_PSTREAM_STARS_0.GLSL</code>). | ||
Line 22: | Line 24: | ||
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)." | ||
'''Eaqz''' has since released a [https://www.nexusmods.com/nomanssky/mods/1549 NMS Vulkan Shader Tool] to decompile and recompile .spv files to and from GLSL files. It sadly doesn't solve the fact shaders are now scattered in dozens of individual files, impossible to edit by a human standard. | == Using a new tool == | ||
'''Eaqz''' has since released a [https://www.nexusmods.com/nomanssky/mods/1549 NMS Vulkan Shader Tool] to decompile and recompile .spv files to and from GLSL files. It sadly doesn't solve the fact shaders are now scattered in dozens of individual files, making them impossible to edit by a human standard. | |||
Latest revision as of 20:27, August 5, 2021
Vulkan Shader Modding
Editing shaders after the NMS Vulkan update (2.0+) has become tricky.
The hard way
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)."
Using a new tool
Eaqz has since released a NMS Vulkan Shader Tool to decompile and recompile .spv files to and from GLSL files. It sadly doesn't solve the fact shaders are now scattered in dozens of individual files, making them impossible to edit by a human standard.