Tutorial  Updated

Dump Vertex and Fragment Shader code from Nintendo Switch Games

Okay, I don't understand why there's no tutorial about this. I am really thanked to @KillzXGaming and @gdkchan for helping me with this issue and of course, for making this possible.

Not all shaders work, but for most of them, you can get the code in a few steps.

upload_2019-8-22_1-48-6.png


What do you need?

- Ryujinx.ShaderTools: Download link (You can easily compile Ryujinx yourself too: https://github.com/Ryujinx/Ryujinx)
- Switch Toolbox (method 1): https://github.com/KillzXGaming/Switch-Toolbox
- HxD or your favourite hex editor (method 2): https://mh-nexus.de/en/hxd/
- Text Editor like Sublime Text: https://www.sublimetext.com/
- Decrypted switch games (RomFS format)

Step 1: Prepare your game

- Get the desired game (In this case Pokémon Let's Go Pikachu)
- Decrypt the game with your favourite method.
I recommend taking a look to these tutorials if you don't know how to do it: https://gbatemp.net/threads/decrypt...backup-loading-ryujinx-yuzu-in-1-click.506954 or https://gbatemp.net/threads/extract-nsp-nca-xci-update-all-in-one-tool-for-layeredfs.511156/

Step 2: Method 1 - Switch Toolbox

- Download Switch Toolbox from github and place it anywhere in your computer (you may have to install some packages. For more info, take a look to the github release info).
- Open Switch Toolbox. Click on File > Open.
- The files with extension .bnsh are shaders, so look for the .bnsh you wanna see the code and open it.
It's okay if the shader is called "name.bnsh_fsh" or "name.bnsh_vsh". "fsh" stands for Fragment Shader and "vsh" stands for Vertex Shader.
-
Open the visual folder structure by clicking on the "+" until you can see the Vertex Shader or Fragment Shader folder (after Shader Variation).

upload_2019-8-22_2-0-1.png


- Right click on the last one > Export Shader1.bin > save it anywhere in your computer. The name doesn't matter but it is recommended to save this file in ShaderTools folder (See step 3). Sometimes it's not shader1 but shader0, if one gives you error, try the other.

Step 2: Method 2 - HxD and manual file editing

- Open the .bnsh file with the hex editor (HxD in this case).
- All the shaders start with the hex values 78 56 34 12. Look for them.

upload_2019-8-22_2-13-48.png


- Count 0x30 bytes from that point.The shader code starts from there.

upload_2019-8-22_2-23-33.png


- Copy the data from there to the all zeros (can be the end of the file) to other new hex file.
- Save it as .bin. The name doesn't matter but it is recommended to save this file in ShaderTools folder (See step 3).

Step 3: See the code

- Go to the folder where you have the Ryujinx.ShaderTools.
- Open the cmd window with Windows + R > cmd or Shift + Right Click > Open CMD Prompt here.
- In the cmd window use the command:

(For FragmentShader) Ryujinx.ShaderTools f path/to/shader1.bin/relative/to/Ryujinx.ShaderTools folder.
(For VertexShader) Ryujinx.ShaderTools v path/to/shader1.bin/relative/to/Ryujinx.ShaderTools folder.

e.g, if the binary is in the Ryujinx Shader Tools folder:

Ryujinx.ShaderTools f fragmentShader.bin
Ryujinx.ShaderTools v vertexShader.bin

- if everything went well, the cmd window will display the code and you can copy it to your favourite text editor.
-Enjoy

Is there anything missing?

Leave a comment to know what I missed so we can help others too ^^

Credits:

- @KillzXGaming: Switch Toolbox
- @gdkchan: Ryujinx and huge help
- @PRAGMA: Romfs decrypting tutorial
- @huma_dawii: Other decrypting tutorial
 

Attachments

  • upload_2019-8-22_2-14-17.png
    upload_2019-8-22_2-14-17.png
    184.4 KB · Views: 484
  • upload_2019-8-22_2-23-18.png
    upload_2019-8-22_2-23-18.png
    184.7 KB · Views: 448
Last edited by Manurocker95,

Manurocker95

Game Developer & Pokémon Master
OP
Member
Joined
May 29, 2016
Messages
1,512
Trophies
0
Age
29
Location
Madrid
Website
manuelrodriguezmatesanz.com
XP
2,809
Country
Spain
What is the usefulness of this?

Is it useful?
Well, if you wanna know how does it work, it is useful. If, not... nope

--------------------- MERGED ---------------------------

What is the usefulness of this?

Is it useful?
For example, I am recreating Pokemon Lets Go in Unity. For me, it is useful.
 

KillzXGaming

Well-Known Member
Member
Joined
Jan 2, 2016
Messages
1,629
Trophies
0
Age
28
XP
1,618
Country
United States
I don't have bnsh saving finished, but it is quite a simple format i could get that done. I am not sure on compiling back or if Yuzu or Ryujinx can compile these back as a switch shader binary.

Also i appreciate the tutorial, i didn't know the code offset to 0x30, so i'll fix it to read off that so it can decompile within the tool properly.
 
Last edited by KillzXGaming,

Manurocker95

Game Developer & Pokémon Master
OP
Member
Joined
May 29, 2016
Messages
1,512
Trophies
0
Age
29
Location
Madrid
Website
manuelrodriguezmatesanz.com
XP
2,809
Country
Spain
I don't have bnsh saving finished, but it is quite a simple format i could get that done. I am not sure on compiling back or if Yuzu or Ryujinx can compile these back as a switch shader binary.

Also i appreciate the tutorial, i didn't know the code offset to 0x30, so i'll fix it to read off that so it can decompile within the tool properly.

we can check that if you can get the repack working. You did a really good work there.
 

kiddy

New Member
Newbie
Joined
Oct 14, 2019
Messages
3
Trophies
0
Age
32
XP
55
Country
China
Hey, I want to ask a question. I don't know much about the third step in the tutorial on cracking shaders. Can you elaborate?
 
Last edited by kiddy,

Manurocker95

Game Developer & Pokémon Master
OP
Member
Joined
May 29, 2016
Messages
1,512
Trophies
0
Age
29
Location
Madrid
Website
manuelrodriguezmatesanz.com
XP
2,809
Country
Spain
Hey, I want to ask a question. I don't know much about the third step in the tutorial on cracking shaders. Can you elaborate?
If you got to that step, just open the cmd window (the regular black windows command window) and write the command with the name of the shader you exported and it will show the code
 

Nick3421421

Member
Newcomer
Joined
Dec 24, 2019
Messages
19
Trophies
0
Age
22
XP
67
Country
Germany
hey so i dont know how i can get those .bnsh files i decrypt it but i dont have .bnsh

--------------------- MERGED ---------------------------

Hey there. So in my case i dont find those .bnsh files. I dump my game correcty but i dont can find them
 

masagrator

The patches guy
Developer
Joined
Oct 14, 2018
Messages
6,325
Trophies
3
XP
12,161
Country
Poland
all right so how i can find those for my game
Well, custom means you need to find it yourself by hex viewing and determining if this is it or not.
Each engine = different method.

--------------------- MERGED ---------------------------

You should start from at least sharing what game are you editing.
 

Site & Scene News

Popular threads in this forum

General chit-chat
Help Users
  • Xdqwerty @ Xdqwerty:
    @BigOnYa, and since the default emulator is below average i downloaded some "replacements" like snes9x for snes games for example
    +1
  • Xdqwerty @ Xdqwerty:
    And I also have my ps3
    +1
  • BigOnYa @ BigOnYa:
    Yea ps3 is a beast still to today compared to most "sticks"
  • K3Nv2 @ K3Nv2:
    If you just want pi for emulation no point when Anbernic releases new shit every two seconds
    +1
  • BigOnYa @ BigOnYa:
    What's really cool about Pi's tho is you can have multiple SD cards with different OS on each SD card and change from say a gaming machine to a full fledged pc if wanted
  • K3Nv2 @ K3Nv2:
    Plus all bios are set up and usually includes at least 128gbs or 64
  • K3Nv2 @ K3Nv2:
    Yeah but if your main goal is just to play n64 and GameCube you can save about $50 and have the portability option
    +1
  • BigOnYa @ BigOnYa:
    True, but on 2 monitors at 4k. Its just want you want really, to each they own.
  • K3Nv2 @ K3Nv2:
    For a kids aspect Anbernic would be the better option they'd probably melt over the price on a good 4k display
    +1
  • BigOnYa @ BigOnYa:
    For that texasroo guy, I'd recommend the Spell and speak as his first system.
    +1
  • K3Nv2 @ K3Nv2:
    So they buy a pi5 kit for about $150 and say a 28" 4k display probably looking around $400 total
  • K3Nv2 @ K3Nv2:
    They'll be getting in the territory of portable Pcs anyway
    +1
  • BigOnYa @ BigOnYa:
    Again you get what you pay for, its like buying a S series for $300 but its only 1440p native, if you want true 4k, gotta get the X model for $500. But yea you right, when moms buying it anyways, you gotta stay cheap.
  • K3Nv2 @ K3Nv2:
    They could use HD out on their TV no real need for a monitor these days tbh the purists will disagree
  • K3Nv2 @ K3Nv2:
    I'm kind of phasing out on the need for wanting all these consoles cool to have but they just become dust build ups
  • BigOnYa @ BigOnYa:
    I here ya there, I have too many myself, and have hard time letting them go, since most of mine I've modded at some point. Anymore I just play Switch on the go, seriesx at home.
  • Xdqwerty @ Xdqwerty:
    ack my throat
  • K3Nv2 @ K3Nv2:
    I need to invest in some storage totes tbh
  • BigOnYa @ BigOnYa:
    Tots?
  • K3Nv2 @ K3Nv2:
    Tootles
  • BigOnYa @ BigOnYa:
    Tootles? Wtf
  • K3Nv2 @ K3Nv2:
    Oh tootles
  • BigOnYa @ BigOnYa:
    Oh totes , lol, like Tupperware storage, I gotcha
  • BigOnYa @ BigOnYa:
    I'm designing my own entertainment cabinet for my man cave, to store all my systems, then I'm also designing a power supply/HDMI switcher so I can switch to whichever system I want, and power it also. Already picked up the cabinet board, but tinkering with my drawings before start
  • BigOnYa @ BigOnYa:
    But yea, I have frogger arcade cabinet that I gutted and put a Pi4 then Pi5 into, but it never gets played much anymore, should sell it. Even when the kids come over, they don't want to play on it, just the xbox. TMNT and Simpson's arcade is still so fun on it, esp w 2 players.
    BigOnYa @ BigOnYa: But yea, I have frogger arcade cabinet that I gutted and put a Pi4 then Pi5 into, but it never...