Skip to content

shaders ​

Tool tools/formats/shaders.py (program, Formats). Find the shaders inside a game's files: compiled Direct3D 9 and 10-12 shaders, SPIR-V, and shader source text in GLSL, HLSL and the OpenGL ARB assembly.

Run it with ./gameframe run shaders ARGS or python3 tools/formats/shaders.py. Source on GitHub.

Its own help ​

This is the help text in the tool itself, as ./gameframe tool shaders prints it.

text
Find the shaders inside a game's files: compiled Direct3D 9 and 10-12 shaders, SPIR-V, and
shader source text in GLSL, HLSL and the OpenGL ARB assembly.

Usage: shaders.py FILE [--dump DIR]

Shaders are small programs that run on the graphics card, and they decide what each frame
looks like: lighting, fog, water, the colour of the terrain. Games keep them in their own files,
in archives, or inside the executable. This tool finds each one, prints its kind, its version,
its size and the names it carries, and with --dump writes each to its own file for a
disassembler or a decompiler:

  Direct3D 9 (vs_1_1 to ps_3_0)  version token 0xFFFE.... (vertex) or 0xFFFF.... (pixel), ending
                                 with 0x0000FFFF. The constant table (CTAB) names the inputs.
                                 Disassemble with fxc /dumpbin, or a D3D9 disassembler.
  DXBC (Direct3D 10 and 11)      'DXBC' container of chunks: RDEF (names of the constants), ISGN and
                                 OSGN (inputs and outputs), SHDR or SHEX (the code). Disassemble
                                 with fxc /dumpbin or decompile with a DXBC decompiler.
  DXIL (Direct3D 12)             the same container with a DXIL chunk: LLVM bitcode. dxc -dumpbin.
  SPIR-V (Vulkan)                magic 0x07230203. spirv-dis, or spirv-cross to GLSL or HLSL.
  GLSL, HLSL, ARB                source text: #version, void main(, technique, !!ARBfp1.0.

Names in the constant tables (fog colour, light direction, world matrix) say what each
shader is for. RenderDoc or a similar capture tool shows which shader draws which object in a
frame; this tool finds them in the files without running the game. Standard library only.

Named by ​

Skills: re-format.

Agents: re-decoder.

Code: Apache 2.0. Content: CC0 1.0. No game material: bring your own copy.