• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

PKB Editor?

Status
Not open for further replies.
Hey guys, one of the things I enjoyed on Warcraft 3 for many years was being able to easily modify the graphics of spell effects. Maybe I want to make Immolation blue instead of Green, for example.

But on Reforged as many people know the spells are often stored in a binary format called PKB. We are told that these files are the output of a program from popcornfx.com and during Reforged Beta when someone posted on that website asking how to change the color, this is what they were told:

These are compiled binary files, so you won't be able to open them in the PopcornFX editor, which only opens the source assets, and does not provide a "decompile" functionality AFAIK.


Depending on how the effect is made, the colors can be anything from an actual constant RGB value, to a texture lookup, to a curve lookup with the curve control-points saved somewhere in the file, to a mathematical expression depending on particle age, to countless other things.

One thing that might work would be to replace the .pkb file entirely from one you made, but how it's baked can depend on some specific things the game engine expects (some special attributes, special sim interfaces, a special renderer material, and so on), which also makes it very painful to do unless you know the exact process they used.

Frankly your best bet might be to ask the developers directly ? perhaps they're opened to the community modding the effects and would be willing to provide some of that information ?

Other than that, I'm afraid you're going to have an extremely hard time changing that color.

While I was thinking about this topic I was reminded that someone else already asked something similar on Hive as well. I had forgotten about myself responding to this long ago. But as I was reviewing this topic when wanting to create my thread, here it was: (Resolved) Frost Immolation Model (For Reforged)

As you can see here on our modding site we took my word as final and apparently marked this fellow's topic as "Resolved" because I told him to give up on modding Reforged because it was too difficult, basically...

But that's not good enough. I tried doing a binary search and replace in the file for data containing 4 bytes in a row where the 3 of them were loosely in the shape of RGB yellow-green. Then I had my program muck about with what it thought were the colors. It replaced binary values in hundreds of places and I do not really understand what it did. But it created an interesting version of immolation that is different.

PKB_blue.gif


Does anyone else know anything about how to edit PKB? Do we have any Hive tutorials on this or anyone else who tried to do it?
Yes, in that other thread I trollishly said that we should not try, but I was watching Wtii play the Chronicles of the Second War on YouTube and I realized that not everyone is just going to give up on modding Reforged and try to write their own game like I have been doing. Apparently some people are actually still in this thing.
So, in honor of how crazy they are, I wanted to be able to mod PKBs color values, that was what I was thinking.

I found that by looking at PKB files -- literally just looking at what I see in the binary -- I was able to discern some things (I am not affiliated with PopcornFX company in any way and I did not use their tools to learn anything about this, I was just looking at the binary files from my Reforged installation).

Based on what I was seeing, I wrote a program with a UI that can open the PKB and it shows two parts, the "nodes" and the "strings" and we can edit any string and save the PKB again. This is kind of nifty since I made it change the metadata defining the length of the string as well, but otherwise not much better than a hex editor.

I tried and I was able to open the purple PKB effect below and make it blue by changing its texture reference:

1620489764531.png


And this really was as simple as File->Open, typing in war3mapImported/OrganicBlobs_Blue.tif and then doing File->Save.

1620489834068.png


But in this same program I started trying to analyze the nodes and it gets really confusing. And for models like the Immolation effect, if we want to turn it blue, we need to understand the nodes. It is using a white texture with a color applied!

So I started tagging nodes in my UI based on what they might be since I have no idea. I found what seems to be a correspondence between the first binary integer in the node and the string table, and after parsing this every file begins with a node labelled "Particle Effect" followed by "Particle Attribute List" followed by numerous "CLayerGraphCompileCache" and then a bunch of EntrySlot and EventSlot for it.

1620489895714.png

Notably the blue and yellow stuff on the right hand-side is guesswork and most of the time is labelled incorrectly.

But as I continued down this rabbit hole into the late hours of last night, I got to the point where I felt like I was seeing a Color field as a Layer Cache Field.

1620490030826.png


But when I looked at the binary contents of the CLayerCompileCacheField "n42__Color" node, it has something in there about being a "float4" that it is labelled but then I don't find the floating point values for me to tinker with. And it got late so I had to stop and sleep for the night, even though this view was able to display substantially more information for me after a few hours of hacking than I would have expected. This program is able to click on the nodes and modify single bytes within the nodes, much like a hex editor, so if we could determine what part of the CLayerCompileCacheField "n42__Color" node or related information actually defined the color, then I think that we could change it. But it's unclear to me whether this node is a variable declaration or something that would actually define it to hold a value. Like I said the contents of the node do not quite make sense to me.


Has anyone else ever attempted anything like this? Is there an easy way to make Immolation be blue?
 
Level 8
Joined
Aug 13, 2009
Messages
361
I offer no value to this subject as I am not a programmer. However, I am like you that I loved changing spell effect colors to "uniform" my races with specific magic types (ie: changing fires to purples to make shadowfire, or changing the holy light abilities to a bluish for Night Elves (based off Tyrande's ability in Hearthstone).

All I can say, I hope that you and others are able to figure this out, being able to modify Reforged spell effects to change the color would open up a huge portion to creating Reforged content. So I hope you and whoever the best of luck. I am definitely keep my eye on this thread.
 
Based on my earlier program, the Horrible PKBlaster, I discovered that the layer cache field "n42__Color" is not directly home to the RGB data. It turns out the data was inside CParticleNodeSamplerData_Curve typically, and is labelled as group type 17 or 18. Using this, I was able to produce a first draft script (doesnt have a GUI) that would perform a successful color shift on a particle. I did this last night and i tested with Blood Elf Ball (sphere) and also with making Immolation blue (in keeping with the start of this thread).

So I think we are nearing the era of being able to recolor Reforged particles. But many people asked me how and I am not quite sure how to easily explain to an artist how to find the sampler data (curve) inputs that I modified yet, so I probably need to make a better UI and get away from just hex editing meaningless binary.

But here are some teaser images from the test:
1621638995242.png

For me personally these tests from last night are personally a lot more exciting than my previous attempt because they are actually usable recolors.

1621639054667.png


So, already people who saw these images that I posted last night on discord are asking me, "How?" But it's important to understand the nature of the beast. I was not using popcorn software, I dont know this format, I literally guessed randomly in the binary and changed random things until it worked.
 
Level 8
Joined
Aug 13, 2009
Messages
361
I for one, am extremely excited for when you get this usable by dumb folk like me. I can't wait to be able to recolor effects like I used to.

Thank you for all your hard work, it's very much appreciated by me and everyone else.
 

Here is a link to a binary build so you can try it!

It will probably break or something, lol
 
Status
Not open for further replies.
Top