SDP Files

From the Oblivion ConstructionSet Wiki
Jump to navigation Jump to search

Bethesda Shader Package .sdp files are located under data/shaders. Multiple packages can be found. Higher numbers contain more shaders and require higher shader model support, however it is not just simple "higher=better".

Header contain 3 DWORD's: 1. 0x64 - (description needed) 2. number of the shaders in that package 3. Size of the data (file size minus 3*4 bytes)

After the header array of shaders blocks is located. Every shader block contains: - shader's name (always 256 bytes long filled with 0's), - DWORD with size of the shader - shader data block

Shader data block is the output of D3DXCompileShader(...). In general it contains shader's token, CTAB comment block and shader compiled code.

CTAB comment block contains header with constant details and array of constant names with some extra data. It ends with compiler version information and some extra data.

CTAB comment block is used by the game engine but it might be lost after calling D3DXAssembleShader(...) since (according to MSDN) CTAB block is created by D3DXCompileShader(...) only.

Generic shader package content[edit | edit source]

0x00000064 // Unknown header
0x******** // number of shaders included in the package
0x000***** // shader data size (filesize-12)
{shader blocks}

shader blocks:

{256 bytes with shader's name filled with 0's}
0x******** // shader's size
0x****F*FF // vertex/pixel shader code, version **.**
0xFEFF**00 // CTAB token and its size in DWORD's
{CTAB data}{Compiler version}{something}
{shader code}

D3DXAssembleShader returns by default vertex/pixel shader code and version (1*DWORD) and the shader's code without CTAB. It can be optionally assembled with debug flag which adds DBUG table. Then the shader's content is returned in ID3DXBuffer->GetBufferPointer() if you compile or assemble your shader. You can add CTAB to that assembled code after assembling it.

CTAB block[edit | edit source]

As for the shaders CTAB block - I was not able to locate any resources/documentation about it.

That format is in general (note that values are saved in different "indian" order):

4B: constant "CTAB"

4B: 0000001C - constant value that I was not able to identify

4B: size of the data block (without "CTAB" and compiler version information but with "ps_*_*" string)

4B: FFFExxyy (pixel shader) or FFFFxxyy (vertex shader) token with shader model (ex. 2.1=ps_2_x)

4B: Number of constants defined in the CTAB/shader

4B: 0000001C - constant value that I was not able to identify

2B: 0001 - constant value that I was not able to identify

2B: 0000 - constant value that I was not able to identify

4B: size of the data block (without "CTAB", compiler version information or "ps_*_*" string) given in bytes

array of structures X: 5-DWORD's per variable

array of structures Y and Z: strings (ASCIIZ) mixed with data description blocks.

ASCIIZ: string with the shader's version (ex. "ps_2_x")

ASCIIZ: Compiler version information (ex. "Microsoft ® D3DX9 Shader Compiler 9.08.299.0000")

Sequence of n characters 0xAB (where n is between 0 and 3) to align the data to DWORD-size

Every structure X is:

4B: byte-based offset to the name (starting after "CTAB")

2B+2B: destination register (ex. 0002+0007 is c7, 0003+0005 is s5)

4B: some value that I was not able to identify (it can have different values for the same variable in different CTAB's but seems to be in some way related to the data type)

4B: byte-based offset to the data type (starting after "CTAB")

2B: 00000000 - constant value that I was not able to identify Every Y structure is:

nB: variable names ended with 0; several names can be defined in 1 structure; structure is alligned with 0xAB characters to a DWORD-size (since the structure is DWORD-based)

Every Z structure is:

2B+2B: some value that I was not able to identify

2B: number of rows in the data type (ex. float4 => 4, float3 => 3)

2B: number of columns in the data type (ex. float4 => 1, float4x4 => 4)

2B: number of elements in the array (ex. float4[5] => 5)

2B+2B+2B: 0000 0000 0000 - constant values that I was not able to identify


In order to export/disassemble and then assemble/import all the shaders you need to extract CTAB blocks as well. Without that step you might be missing some effects (one that I have seen is still water without any ripples).

If you need help with the shaders (or some simple tools to extract/import them) you might try timeslip's shader tool (to do: verify how it handles CTAB block cause I think that it is ignoring it), use oldblivion (to do: check how it is handling CTAB block) or contact with me (adderek at bethsoft forums).