In order to edit this wiki, you must register and verify your account.

Tutorial:How to create graphic pack

From CEMU Wiki
Jump to: navigation, search

Graphic packs behave like graphic mods. Anyone can make one (assuming they have the necessary know-how) and users can download and install them. In the options of Cemu, individual graphic packs can then be enabled or disabled. Additionally, multiple graphic packs can be active for the same game as long as they don't interfere with each other. You can mix and match according to your own personal preference. By default, Cemu will come with a bunch of graphic packs already pre-installed.

What graphic packs can potentially do:

  • Change the game's internal resolution
  • Increase the resolution and quality of shadows
  • Modify or remove post-processing effects
  • Workarounds for graphic bugs until we find a proper solution
  • Change lighting related aspects of the game
  • Add or change any visual aspect of the already existing materials
  • Custom Anti-Aliasing

From a technical standpoint, graphic packs allow the following:

  • Overwrite certain texture properties (like the resolution)
  • Overwrite shaders (very powerful since everything uses shaders)
  • Custom textures and some more complex control over drawcalls (Not yet supported but planned for the future)

However, there are some limitations as well. Graphic packs intercept at the rendering level, so they can't alter the logic of the game.

Create a graphic pack

A graphic pack is a folder with the the name of the game, without spaces and at the end the resolution. For example:NameOfGame_1080p

Resolutions are for example:

  • 360p
  • 540p
  • 720p
  • 1080p
  • 2160p
  • 2880p
  • 4320p
  • 5760p

In this folder are the txt file rules.txt. Click here to learn how to install a graphic pack

rules.txt

rules.txt contains information about the graphic pack, the games it is applied to and one or multiple rules that can modify texture properties. Everything after a # character is considered a comment.

Note: While not necessary, knowledge about engines, rendering concepts, graphic effects etc. is helpful when trying to create your own graphic packs.

Here is a example of a rules.txt

[Definition]
titleIds = 000500001010ec00,0005000e1010ed00,0005000e1010eb00
name = "Mario Kart 8 - 2160p (4K)"
version = 2

[TextureRedefine]
width = 1280
height = 720
formatsExcluded = 0x41A # exclude the intro background texture
overwriteWidth = 3840
overwriteHeight = 2160

There are the two Section [Definition] and [TextureRedefine] and under this section are some variables that can be changed

Section: [Definition]

Variables in the section [Definition]
variable description
titleIds
List of one or multiple titleIds (unique game indentifier) which are used to determine for which games this pack is active.
name
Name which appears in Cemu's "Graphic packs" window. We recommend a "gamename - effect" style naming scheme. E.g. "Mario Kart 8 - 1080p resolution".
version
Version 2 is used since Cemu 1.8.0 and must always be set

Section: [TextureRedefine]

After the [Definition] section one or multiple texture rules can follow. Currently there is only one type of rule supported, called 'TextureRedefine'. Below is a description of what it does and how it works.

This rule type can be used to overwrite certain texture properties, like the resolution or format. There are two parts to each 'TextureRedefine' rule:

  • The filter settings - The rule will only apply to textures when the original texture properties match the values given by the filter settings.
  • The overwrite settings - If a texture matches the filter, these properties are applied. The idea is that via these rules you can tell Cemu which textures to modify and how to modify them.

Note that texture rules are applied upon creation of the texture. Multiple rules can apply to the same textures as long as they don't interfere with each other (e.g. one rule to set the width/height and another rule to set the format)

Filter settings

Variables in the section [TextureRedefine]
variable description
width
height
formats
Texture format must match any of these ('0x' prefix denotes hexadecimal format, can contain multiple formats separated by comma)
formatsExcluded
If any of the filter settings above are omitted they are not evaluated. This allows you to write a rule that, for example, only filters for the width of a texture but not the height.
overwriteWidth
Like filter settings you can omit individual overwrite settings. This allows to selectively overwrite the width but not the height etc.
overwriteHeight
Like filter settings you can omit individual overwrite settings. This allows to selectively overwrite the width but not the height etc.
overwriteFormat
new texture format

Common use case example:

Many games run in 1280x720 resolution and we would like to use a textureRule to upscale those games to 1920x1080.
Here is how it would look:

[TextureRedefine]
width = 1280
height = 720
overwriteWidth = 1920
overwriteHeight = 1080 

This rule applies to all textures that have a resolution of 1280x720 and overwrites their resolution to be 1920x1080. Depending on the game, this might suffice for simple upscaling. However, since the filter settings in this example are very loose (only width and height is checked) the rule might catch unwanted textures. Some games use background or splash screen textures that have the same resolution as the intended screen resolution. Since Cemu resets the contents of a texture if any rule is applied, you would end up with a black background. A workaround for this is to use the texture dump feature of Cemu and figure out more exact filters.

List of all texture formats:

name value
R8_UNORM 0x00000001
R8_UINT 0x00000101
R8_SNORM 0x00000201
R8_SINT 0x00000301
R4_G4_UNORM 0x00000002
R16_UNORM 0x00000005
R16_UINT 0x00000105
R16_SNORM 0x00000205
R16_SINT 0x00000305
R16_FLOAT 0x00000806
R8_G8_UNORM 0x00000007
R8_G8_UINT 0x00000107
R8_G8_SNORM 0x00000207
R8_G8_SINT 0x00000307
R5_G6_B5_UNORM 0x00000008
R5_G5_B5_A1_UNORM 0x0000000a
R4_G4_B4_A4_UNORM 0x0000000b
A1_B5_G5_R5_UNORM 0x0000000c
R32_UINT 0x0000010d
R32_SINT 0x0000030d
R32_FLOAT 0x0000080e
R16_G16_UNORM 0x0000000f
R16_G16_UINT 0x0000010f
R16_G16_SNORM 0x0000020f
R16_G16_SINT 0x0000030f
R16_G16_FLOAT 0x00000810
D24_S8_UNORM 0x00000011
X24_G8_UINT 0x00000111
D24_S8_FLOAT 0x00000811
R11_G11_B10_FLOAT 0x00000816
R10_G10_B10_A2_UNORM 0x00000019
R10_G10_B10_A2_UINT 0x00000119
R10_G10_B10_A2_SNORM 0x00000219
R10_G10_B10_A2_SINT 0x00000319
R10_G10_B10_A2_SRGB 0x00000419
R8_G8_B8_A8_UNORM 0x0000001a
R8_G8_B8_A8_UINT 0x0000011a
R8_G8_B8_A8_SNORM 0x0000021a
R8_G8_B8_A8_SINT 0x0000031a
R8_G8_B8_A8_SRGB 0x0000041a
A2_B10_G10_R10_UNORM 0x0000001b
A2_B10_G10_R10_UINT 0x0000011b
D32_FLOAT_S8_UINT_X24 0x0000081c
X32_G8_UINT_X24 0x0000011c
R32_G32_UINT 0x0000011d
R32_G32_SINT 0x0000031d
R32_G32_FLOAT 0x0000081e
R16_G16_B16_A16_UNORM 0x0000001f
R16_G16_B16_A16_UINT 0x0000011f
R16_G16_B16_A16_SNORM 0x0000021f
R16_G16_B16_A16_SINT 0x0000031f
R16_G16_B16_A16_FLOAT 0x00000820
R32_G32_B32_A32_UINT 0x00000122
R32_G32_B32_A32_SINT 0x00000322
R32_G32_B32_A32_FLOAT 0x00000823
BC1_UNORM 0x00000031
BC1_SRGB 0x00000431
BC2_UNORM 0x00000032
BC2_SRGB 0x00000432
BC3_UNORM 0x00000033
BC3_SRGB 0x00000433
BC4_UNORM 0x00000034
BC4_SNORM 0x00000234
BC5_UNORM 0x00000035
BC5_SNORM 0x00000235

Shader replacement

Wii U's GPU supports a fully programmable pipeline. Meaning each drawcall is associated with a vertex and pixel shader and an optional geometry shader. Cemu's graphic pack feature allows to overwrite individual shaders giving control over many aspects of a game's render pipeline.

In order to get access to the shaders that are used by Cemu you can enable the debug option 'Dump shaders' before or while a game is running. Since the shaders generated by Cemu are translated from low-level binary instructions they contain little to no human-readable information. You likely won't be able to figure out what a shader does just by looking at it's source. Therefore it is recommended to use third-party tools like Nvidia's NSIGHT or AMD's GPU PerfStudio to do realtime graphics debugging while a game is running in Cemu.

Once you have located a shader that you want to edit, you can copy it from the dump/shaders/ directory into your graphics pack. You then can make any adjustments you want to the shader source. Any GLSL compilation errors will be written to log.txt