Post-processing-effectors (PPE)
From Mod Wiki
Post-process effectors (.ppe) in STALKER are used to create visual effects like radiation-exposure, drunkenness, psy-effects, night-vision and other. They are binary files that have a certain internal structure. Once you understand the structure and manage to keep the overview in the file, you can edit them or even create new effectors. Note that PPEs always effect the whole screen, so it is not possible to limit effects to certain areas. A necessary tool to edit PPEs is a decent hex editor like HxD.
This article is based on the Russian version by Green Hawk (see interwiki link). Many thanks to him for doing the research and sharing with the community!
Contents |
Analysis
It may help you to understand the structure of PPEs if you look into \gamedata\script\postprocess.script and into some ltx like \gamedata\config\scripts\proba.ltx. It seems like postprocess.script was used to create PPEs - or at least read PPE configurations from .ltx'.
Every PPE file contains multiple sets of rules. The structure of these rule-sets can be guessed by looking at the files above. But to make things easier, here is an overview over the structure. If you open a PPE in HxD to compare the structure with this explanation, it can be useful to change the number of bytes per row to something like eight. It may help you to gain a better overview of the file segments.
File header
Every file starts with 01 00 00 00. This is most likely a signature to identify the file content (the camera animations share the same structure and have the signature 00 11 00 00). Then four bytes with unknown meaning follow. Usually they are 7C 00 00 00 but there are slight variations. So our file until here looks like 01 00 00 00 7C 00 00 00. Now the rule-sets follow.
Rule-sets introduction
Every set begins with 01 01 XX 00 where XX is the number of rules that the set contains. For example 01 01 00 00 means that no rule follows, so the set is not active at all. Many mistakes happen if the number given at the start of the set does not fit the number of rules. Make sure to check it, every time you change something.
Rules always consist of 23 bytes! This makes keeping the overview more complicated because now we have even headers and odd content. So your lines will pretty fast break. If a rule-set started with 01 01 04 00 then there will be 04 x 23 bytes of rules following.
To get a better understanding, it might be good to look at an example file wit comments now, before we look at the explanation of the segments.
Example file with comments
The following example shows the structure of a PPE with comments. It is taken from the Russian article and translated with google. Since the translations do not always make sense, I left the Russian originals for future improved translations.
01 00 00 00 ;signature ;Colors twisted at a maximum ; Цвета выкручиваем на максимум 7C 00 00 00 ;unknown1 01 01 02 00 ;color_add_red 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 ;color_add_green 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 ;color_add_blue 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 ;Do not understand how, but this triad podkrashivaet already translated into ; Не понимаю как, но эта триада подкрашивает уже переведенное в ;chb image, that is doing slightly sinevatym result, at the same time ; чб изображение, то есть делаем слегка синеватым результат, заодно ;rusticate slightly red or green. ; огрубляем слегка красные или зеленые. 6C 10 00 00 ;unknown2 01 01 02 00 ;color_base_red CD CC CC 3D 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 CD CC CC 3D 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 ;color_base_green CD CC CC 3D 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 CD CC CC 3D 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 ;color_base_blue CD CC 4C 3E 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 CD CC 4C 3E 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 ;In the gray mode all red objects - white, blue and green - black ; В сером режиме все красные обьекты - белым, синие и зеленые - черным 7C 00 00 00 ;unknown3 01 01 02 00 ;color_gray_red 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 ;color_gray_green 00 00 80 BF 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 BF 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 ;color_gray_blue 00 00 80 BF 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 BF 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 ;Fully black-and-white image, subject to the rules color_gray_ * ; Полностью черно-белое изображение с учетом правил color_gray_* 01 01 02 00 ;gray 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 00 00 ;blur ;Dvoeniya in the eyes will not be ; Двоения в глазах не будет 01 01 00 00 ;duality_h 01 01 00 00 ;duality_v ;Noise will not be ; Шума не будет 01 01 00 00 ;noise_intensivity 01 01 00 00 ;noise_granularity 01 01 00 00 ;noise_fps
Rule-sets explanation
Chosen color component multiplied by the factor, the parameter equal to 1 pure white color will remain white and pure black - black, the other component preobretut shade.
- unknown1
- color_add_red
- color_add_green
- color_add_blue
This value was adopted as a base for the colour, that is, if the value of the pixel color below the specified, it was adopted as specified and, if more, it remains the same. It should be noted that this is the only set of variables, which zadirat values above 0.5 is meaningless, added 0.5 somewhere in the wild engine.
- unknown2
- color_base_red
- color_base_green
- color_base_blue
This triad is responsible for the rules of weight in grey color / brightness presentation and color in the usual result is not visible. But with increased regulations gray, it is clear that in such color_gray_red = -1 pure red components will become black, 0 = remain unchanged, 1 - pure white:
- unknown2
- color_gray_red
- color_gray_green
- color_gray_blue
Variable manages the saturation value of the inverse, that is, the more gray (maximum 1) the lower the saturation of images:
- gray
Blur images at large (try 25) begins shoals, the lower part of ports, if long stand still:
- blur
Split image horizontally and vertically, respectively. Perhaps indicated on the screen, that is, with 1 copy of object, originally located in the center will be exactly at the edges:
- duality_h
- duality_v
- noise_intensity
- noise_granularity (the size of noise grain)
- noise_fps (how many times per second should noise be calculated)
Rule explanation
Every rule (23 bytes) consists of different fields. Example rule with field labels:
value | time | function | k1 | k2 | k3 | unused (?) |
---|---|---|---|---|---|---|
9A 99 99 3E | 00 00 A0 40 | 00 | 00 80 | 00 80 | 00 80 | 00 80 00 80 00 80 00 80 |
- value is what you usually want to change.
- time
- function is 00 in all PPEs, but it can be changed to 03 sinus, 01/05 cosine, 02 linear, 04 CTD.
- k1, k2, k3 are probably ratios affected by function, but their usage is yet unresolved.
- unused doesn't seem to be used, thus the name.
Source codes
You can copy the following source codes and use them as templates for experiments. Simply make a new file (for example a blank .txt and open it with HxD. Then copy the hex codes from this page into HxD (ignore the warning) and save the file. If you want to compare both source files, to see what I have changed to make the gray vision, you can copy them into a text file, save as text document and compare them with WinMerge or Compare It!.
Please add more source codes, if you achieve interesting effects.
Example file without comments
01 00 00 00 7C 00 00 00 01 01 02 00 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 6C 10 00 00 01 01 02 00 CD CC CC 3D 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 CD CC CC 3D 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 CD CC CC 3D 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 CD CC CC 3D 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 CD CC 4C 3E 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 CD CC 4C 3E 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 7C 00 00 00 01 01 02 00 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 00 00 80 BF 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 BF 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 00 00 80 BF 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 BF 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 00 00 01 01 00 00 01 01 00 00 01 01 00 00 01 01 00 00 01 01 00 00
Gray vision effector
01 00 00 00 7C 00 00 00 01 01 02 00 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 00 00 80 3F 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 80 3F 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 6C 10 00 00 01 01 02 00 CD CC CC 3D 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 CD CC CC 3D 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 CD CC CC 3D 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 CD CC CC 3D 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 CD CC CC 3D 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 CD CC CC 3D 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 7C 00 00 00 01 01 02 00 00 00 00 01 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 00 01 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 00 00 00 01 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 00 01 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 00 00 00 01 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 00 01 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 02 00 00 00 DD DD 00 00 00 00 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 00 00 DD DD 00 00 00 41 00 00 80 00 80 00 80 00 80 00 80 00 80 00 80 01 01 00 00 01 01 00 00 01 01 00 00 01 01 00 00 01 01 00 00 01 01 00 00
Questions
As you can see, there are still open questions:
- What are the byte blocks that are labled unknownX?
- How do k1, k2, k3 work?
- Is there a meaning for the unused part of each rule?
Feel free to contribute if you find out anything about it.