Actions

SCHG How-to

Assign Custom Materials to objects without additional materials in Sonic Heroes

From Sonic Retro

SCHG: Sonic Heroes
Main Article
Mechanic Editing
DOL Editing
EXE Editing
Music Pointers
Relocatable Editing (PC)
::::File Offsets
Model Editing
Model Format
Collision Format
Level Editing
Camera Editing
Indirect Editing
Level List
Object Editing
Object Porting
Visibility Editing
Particle Editing
Particle Editing
Sound Editing
Sound Editing
Music List
Voices
SCHG How-Tos
Custom Object Material Effect Tutorial
Level Editing Tutorial

(Original guide by Muzzarino)

This will teach you how to create injectable assembler codes using Cheat Engine to provide custom materials for an object without additional material parameters that manipulate the appearance to the object(s) operated in their functions in the executable.

Things you'll need

1. Cheat Engine 2. Sonic Heroes executable

Setting up and using Cheat Engine

You will need to download and install CE from the official Cheat Engine website, then launch it and and attach "Tsonic_win.exe" to the process.

Codes and Operations

Once you have the executable attached to Cheat Engine, open up the memory viewer by clicking on "Memory view", go to beginning RAM address at "00400000", click and hover over the search tab and click on "Find assembley code", type in the call address of "66B4F0" and then click scan. A number of results will be brought up in the assembly scan list, so if you encounter an object that uses this, then place a breakpoint on it. Make sure the function does not have materials in the function or doesn't use it but has them for other sets of the object. If the breakpoint freezes the code, then it should be the object using it. Also, place a nop on it to make sure it disappears and then restore the code to make the model come back to check if it is the correct object to place custom materials onto.

Applying Materials

If you have found an object function without materials (especially the codes with colors applied to them), highlight this opcode "call Tsonic_win.exe+26B4F0" and go to Auto Assembler in the tools menu.

SH Material Opcode 2.png

Under the template menu, use the "full injection" assembler template type and then click OK, but do not change the jump address in the box.

SH Material Opcode 3.png

Under code, place a material parameter, the type of it and then place the call address function of "Tsonic_win.exe+24C9B0". If a certain material such as blend equation or alpha testing functions cannot be achieved with that address to call, then use "call Tsonic_win.exe+247980" instead.

Custom materials should be placed above call Tsonic_win.exe+26B4F0 and the default materials should be below it. If you add one material, you will need to add an add esp opcode before the model appearance address call and after the end of the code injection before "jmp return" otherwise the game will crash. Each material function set are three codes which one is the parameter, the type and the call address which works this way:

push materialparamnumber
push materialtype
call materialfunctionaddress
SH Material Opcode 4.png

If there are more than one custom and default materials applied, you will need to add by 08 by the "add esp" code (for example: add esp,08) and if the value ends up with a 6 next to a value (like 16 after adding 08 by 08), then you will need to subtract that by 06 to convert it to a hexadecimal which would equal 10.


Examples of how the injectable material operation should be made to work properly:
One custom material:

push 02
push 0B
call Tsonic_win.exe+24C9B0
add esp,08
call Tsonic_win.exe+26B4F0
push 06
push 0B
call Tsonic_win.exe+24C9B0
add esp,08

Two custom materials:

push 02
push 0A
call Tsonic_win.exe+24C9B0
push 02
push 0B
call Tsonic_win.exe+24C9B0
add esp,10
call Tsonic_win.exe+26B4F0
push 05
push 0A
call Tsonic_win.exe+24C9B0
push 06
push 0B
call Tsonic_win.exe+24C9B0
add esp,10

Three custom materials:

push 02
push 0A
call Tsonic_win.exe+24C9B0
push 02
push 0B
call Tsonic_win.exe+24C9B0
push 01
push 14
call Tsonic_win.exe+24C9B0
add esp,18
call Tsonic_win.exe+26B4F0
push 05
push 0A
call Tsonic_win.exe+24C9B0
push 06
push 0B
call Tsonic_win.exe+24C9B0
push 02
push 14
call Tsonic_win.exe+24C9B0
add esp,18

If you want to preview it, click and hover the "File" tab, assign it to the cheat engine table and then put an X next to the the auto assembler script on the list. You should see changes like this when done properly:

SH Material Opcode 5.png

You can always edit the script by double clicking the <script> text next to the item. If you need to make it easier to recognize which object you applied the injection script at, you can rename "Auto Assembler Script" to a name you can easily get to next time.

Notes

Material flags are automatically assigned when called on a slot where the function address is placed at. It is not recommended to apply a code to disable z-writing if the function is rendering a normal a normal model as it will cause it to become invisible.

If you need examples of how it's done, use the cheat engine table uploaded here.