Monday, March 5, 2012

DLL's Update.

DLL's updated !

Rewrote big part of the code for smart shader management. Some games recreate shaders at level loading that can cause duplication of shaders in the lists. with new version shades list will be reduced in some games. New version delete shaders from lists properly.

Added ability to bind shader with used texture it helps to use shader only with required textures or split code in the shader for different logic. I.e. now possible to split game HUD , cursor/ effects which draws by the same shader to different code.

Example of using can be found in MassEffect 3 fix. It fixes only croshair and borders around an enemy and leaves HUD and menu untouched.
Here example of the config made for ME3.
 CheckTexCRC parameter let DLL know that this shader will use textures CRC list.
 DefinedTexturesVS  parameter define textures crc with stereo texture should work(in other cases it will pas zero to stereo texture and all offsets calculates with it also will be zero). Each element of the list should be separated by ";" sign (even last !).

[VS44D42C54]
CheckTexCRC = true
DefinedTexturesVS = 5DCBE194;954ADD3B;3606D4F3;91C86B9C;9CD760E4;


[VS6D053316]
CheckTexCRC = true
DefinedTexturesVS = C335EB77;

How to check textures CRC'S ?
Create "DX9Settings.ini" in the game directory and add shaders you wold like to handle:
[VS44D42C54]
CheckTexCRC = true
This code will handle vertical shader with  44D42C54 CRC.
After you added all shaders to the config, run a game with debug dll.
Go to the place where required shader using and press F12 key(by default).
Wait for 5 sec.
This action will make "TEXTURESLOG.txt" log in the game directory. This log contain calls of shaders you described before. The Log will contain something like this:
Shader CRC: 0x44D42C54 Last texture CRC: 0x7E11A26D

Shader CRC: 0x44D42C54 Last texture CRC: 0x2F33D52

Shader CRC: 0x44D42C54 Last texture CRC: 0x954ADD3B

Shader CRC: 0x44D42C54 Last texture CRC: 0x954ADD3B
Now you can see what texture using for shader call.
The only one problem is find out appropriate texture, fortunately you don't need to restart game every time after you're editing textures list. Open  "DX9Settings.ini" and add   DefinedTexturesVS  parameter and fill textures CRC's. Return to the game (alt + tab) and reload textures list by using F8 key(by default).
Repeat until you find required textures. Textures defined in the list doesn't show up when you capture  "TEXTURESLOG.txt"  again !

If you want use different values or different code for every texture you should define "TexCounterReg"  for thhis texture (in shader each section you want to use). This parameter determines the register which will be used for passing index of the current texture defined in the list.

[VS44D42C54]
CheckTexCRC = true 
TexCounterReg  = 251
DefinedTexturesVS = 5DCBE194;954ADD3B;3606D4F3;91C86B9C;9CD760E4;


It means that shader will revive index of the current texture in c251 register in x component.
For texture with  5DCBE194  it will be "0" , for  954ADD3B - "1", for  3606D4F3 - "2"  and etc.
Now you can use "if" instruction in the shader with this value and make difference calculations for each texture!

Added ability to save presets.
You can define up to 9 presets and switching between them by hot keys.
Presets can store values for convergence/separation and addition parameter which will be passed to the shader. Constant parameters can be used as flags to turn on/off some effects.

Example from ME3 config
[General]
DefVSConst1 = 250 
Preset1Key = 79//o key
Preset2Key = 80// p key

[Preset1]
Const2 = 0x3f800000// 1.0 in hex

[Preset2]
Const2 = 0x00000000// 0 in hex

Here  DefVSConst1 parameter defines register which will be used for passing first 4 constants ( Const1-  Const4,  c 250 .x -  c250.w).  Const2  in presets settings defines  y component. In game shaders use c 250 .y value in "if" instruction.

mov r14.x, c250.y
if_eq r14.x, c245.x// if  Const2  = 0 turn effect on, else turn it off
texldl r11, c245.z, s0
add r11.y, r0.w, -r11.y
mul r11.x, r11.x, r11.y
add r0.x, r0.x, r11.x
mov o5, r0
endif 
So by pressing "O" key you can turn self shadows effects off in ME3 and by pressing "P" turn it on.
Also you can assign convergence/separation values like this:
[Preset1]
Convergence = 0x42ec701f
Separation = 0x42940000
UseSepSettings = true
You can use this online converter for float to HEX conversion.

Some games use same binary shader to create different in game shaders, i.e. basically it will be different shader in tha game , but has same crc. In this case you can override each of those shaders by different  shader code. For this you should add index to the end of the shader file as extension. For example we have 0F602182.txt in ShaderOverride folder. And game engine creates two shaders from this one (you can see this kind of shaders in LOG.txt). So if you want override only first shader you should use "0F602182.txt.1" as its file name and "0F602182.txt.2" for second shader.

Also you can insert vertex shader before pixel shader, it's very useful when game doesn't have vertex shader and you need to move vertex position. I will explain this later with X3 fix as example.


Release DLL.

Debug DLL

DebugLOG DLL

Use debug log only if you game crashes to get detailed log.

I will post more info later.




0 comments:

Post a Comment

 
Copyright 2009 helixmod-Newsday. Powered by Blogger
Blogger Templates created by Deluxe Templates
Wordpress by Wpthemescreator