NoMansSky:Tutorials/Vulkan Shaders: Difference between revisions

From Step Mods | Change The Game
Line 2: Line 2:
{{NMSPage|contentTitle=Tutorials // Vulkan Shader Modding}}
{{NMSPage|contentTitle=Tutorials // Vulkan Shader Modding}}
{{TOC_right}}
{{TOC_right}}
== 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 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)."


== 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, impossible to edit by a human standard.
'''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.


{{NMSPageClose}}
{{NMSPageClose}}
[[Category:No Man's Sky]][[Category:NMS-Tutorial]]
[[Category:No Man's Sky]][[Category:NMS-Tutorial]]

Revision as of 09:54, August 9, 2020

Template:TOC right

Vulkan Shader Modding[edit | edit source]

Editing shaders after the NMS Vulkan update (2.0+) has become tricky.

The hard way[edit | edit source]

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[edit | edit source]

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, impossible to edit by a human standard.

Template:NMSPageClose