[info]SWBF MSH Forensics

Started by tirpider, February 17, 2013, 03:26:33 PM

Previous topic - Next topic
Funny, I try your "64" code (04 00 00 00 64), but all, what it can do, is  simple transparent... and actualy, how you put triple number code "128" in to binare code lines, or you just rip it apart, like this: 04 00 00 00 12 80 ?...

Wow, that's realy long code list, but... I did not try it yet, but I am almost sure, most of those numbers do nothing, or repeat the same thing, again and again...
Beauty is, the way to perfection.

Glory to Ukraine!  :mf:

February 21, 2013, 02:47:23 PM #16 Last Edit: February 21, 2013, 02:54:05 PM by tirpider
The list is every permutation of the factors 0, 1, 2, 4, 8, 16, 32, 64, and 128. 

Those factors are the flags that all combine to make the render flag byte in the ATRB section of the msh.
[spoiler] A  T  R  B
41 54 52 42  04 00 00 00  00 00 00 00
              |        |   |  |  |  |
              |        |   |  |  |  |
size field----+--------+   |  |  |  |
                           |  |  |  |
render flag----------------+  |  |  |
                              |  |  |
render type-------------------+  |  |
                                 |  |
data1----------------------------+  |
                                    |
data2-------------------------------+

(data1 and data2 provide extra information for
the type and flag fields as needed so their
meaning is flexible.)

Render flags:
dec  hex   desc
  0 = 00 = none
  1 = 01 = Emissive
  2 = 02 = Glow
  4 = 04 = SinglesidedTransparency
  8 = 08 = DoublesidedTransparency
16 = 10 = HardedgedTransparency
32 = 20 = PerPixelLighting
64 = 40 = AdditiveTransparency
128 = 80 = Specular
[/spoiler]

Each one is a discrete number and does not repeat any more than the integers from 0 to 255 repeat.

The way to get them into a format usable for hex editing,  change the decimal number to a hexadecimal number.  (see also, base10 to base16, or decimal to hex)

I use built-in functions to convert the numbers, so I forget the actual method..  I think it uses a lot of division.. but it's been years, so I forget. 
128 in hex would be "80", and in the file it would look like:
41 54 52 42  04 00 00 00  80 00 00 00


That 64 flag (addative transperancy) really suprised me.  The only thing special about the test files is the tga. It has an alpha channel with a full range of values. the lower values were the invisible parts.  I think it must be interacting with the rest of the colors in the other channels as well.  I plan on digging into it more after I get emmisive working without specifying a render type.

Oh, that's explain a lot. So, if I have to convert 64, it will be 40... So, the code, after ATRB, should look's like this: 04 00 00 00 40 ?... I am afraid, to got your effect, it will be far not enough... Seems, more bigger part of code, that you use, also have some certain RGB parameters, just like my "super shiny" code.
Beauty is, the way to perfection.

Glory to Ukraine!  :mf:

February 21, 2013, 04:03:33 PM #18 Last Edit: February 21, 2013, 05:55:38 PM by tirpider
Quote from: Sereja on February 21, 2013, 03:23:46 PM
Oh, that's explain a lot. So, if I have to convert 64, it will be 40... So, the code, after ATRB, should look's like this: 04 00 00 00 40 ?

Yes.

Quote from: Sereja on February 21, 2013, 03:23:46 PMI am afraid, to got your effect, it will be far not enough... Seems, more bigger part of code, that you use, also have some certain RGB parameters, just like my "super shiny" code.

The test I ran on the 64 flag used a wide spread of values for the colors.  ZeroEdit noticed that the diffuse color was different, but after munging, the game did not notice the difference in the color values at all.

It had the same effect on all the models, regardless of how the colors were set in the msh file.

I am not certain, but I believe the fiery yellow was caused by the rgb channels interacting with the alpha channel in the tga. The way to test would be to set the 64 flag, and try different texture combinations.
It has to have an alpha in the tga, else the effect will not show up.
If the alpha is entirely blank, then it would probably just make the model invisible.
If the alpha is completely opaque, then it should still have some remnant of the fiery look to it.

An example of the hex in the format of your shiney code:
[spoiler]44 41 54 41 34 00 00 00 00 00 00 43 00 00 00 43 00 00 00 43 00 00 80 3F 00 00 00 43 00 00 00 43 00 00 00 43 00 00 80 3F 00 00 00 43 00 00 00 43 00 00 00 43 00 00 80 3F 00 00 48 42 41 54 52 42 04 00 00 00 64 00 00 00[/spoiler]
That starts at the DATA tag and ends just before TX0D. I copied it staight out of one of the test files.
It has every color set to 128,128,128 and the specular decay set to 50. (this shouldn't effect anything.)

-edit
oh my god.....
You know what? thank you for asking about this...  I have to redo those tests .   I was reviewing the numbers in the DATA fields, and instead of making them into percents before encoding as a float, I just encoded the raw color numbers as foating points.  .....

So you are right about it needing something more...  the numbers in that test code are exactly 128% 255% larger than the numbers Zero, the munger, and the game expected.....

I'll redo the tests, it shouldn't take long since I already have the files made and named.  Perhaps things like specular will behave this time around and emisive might emiss.

The test code above is what I used the incorrect tests, so it should give you the glowy-yellowy-transperant look that I got before.

(Note that the numbers for DATA and the numbers for ATRB are encoded differently regardless of my mistake.)

February 22, 2013, 12:18:21 AM #19 Last Edit: February 22, 2013, 01:00:33 AM by Sereja
Seems, I found "code" line, responsible, for color regulation:
[spoiler][/spoiler]

Explanation:

Additive, means, it uses added color palette. In this case, it uses ambient colors, from your .SKY file. So, to change colors, you need to change this line:
    AmbientColor(40, 36, 76);
That's it! :)
Beauty is, the way to perfection.

Glory to Ukraine!  :mf:

Quote from: Sereja on February 22, 2013, 12:18:21 AM
Seems, I found "code" line, responsible, for color regulation:
[spoiler][/spoiler]

Explanation:

Additive, means, it uses added color palette. In this case, it uses ambient colors, from your .SKY file. So, to change colors, you need to change this line:
    AmbientColor(40, 36, 76);
That's it! :)
Excuse me if I'm wrong, but does that mean we can finally change the CP colour?

Oh, I am afraid, CP's hologramm, has totaly different nature...
Beauty is, the way to perfection.

Glory to Ukraine!  :mf:

Quote from: Sereja on February 22, 2013, 02:20:06 AM
Oh, I am afraid, CP's hologramm, has totaly different nature...
Oh well.

However this stuff is all great anyhow.. uh carry on.

Bad thing about changing SKY file ambient color, is that it applies the color to all of the objects in the map..
It would be cool to have some slightly transparent crystals like the model above, with some beautiful glow in a night time setting.

While we are talking about light, I cannot seem to get whitelight.ODF to work, and is crashing my map.
Any ideas? (It is unmodified)

Quote from: -RepublicCommando- on February 22, 2013, 10:32:04 AM
Bad thing about changing SKY file ambient color, is that it applies the color to all of the objects in the map..
It would be cool to have some slightly transparent crystals like the model above, with some beautiful glow in a night time setting.
Well, I guess, that easy can be done, with some other hex codes, like simple "Glow Soft Edged Transparent" code:
04 00 00 00 09
Quote from: -RepublicCommando- on February 22, 2013, 10:32:04 AM
While we are talking about light, I cannot seem to get whitelight.ODF to work, and is crashing my map.
Any ideas? (It is unmodified)
Hope, you didn't try add whitelight.ODF, just with ZE? It is for some prop odf attach only. If msh, has some hp firepoint, you may attach whitelight.ODF, by open prop odf, and add this lines:
AttachOdf = "whitelight"
AttachToHardPoint    = "hp_light"
Beauty is, the way to perfection.

Glory to Ukraine!  :mf:

February 22, 2013, 10:57:48 AM #25 Last Edit: February 22, 2013, 10:59:54 AM by -RepublicCommando-
Oh yes.. I should have known this
I looked at tusken fire pit and it had those lines in it, so theoretically, I could use tat2_barge_turret (since it has hp node) and use it as a light "host" ?

Will it read any node as long as it's in the MSH?

Yes, but it works only for prop, but not for turret, vehicles, units etc.
Beauty is, the way to perfection.

Glory to Ukraine!  :mf:

I revised the render flag tests in my previous post and double checked the way the numbers were encoded.

Basicly it reveals little more than yes, there are render flags, and no, the data chunk has nothing to do with how they render.

There are still a few more to go through, but they may require more than just the data color values to work, so they are a different array of tests.

Comming soon: Glow, why doesn't it?


any idea what this would do when called on?
-- set sun light for the model
ScriptCB_SetSunlight( this )

It is strange, but for me, 04 00 00 00 01, hase shadow :confused:...
Also, 04 00 00 00 02, has different look's.
But, here, few more interesting codes, I found:
[spoiler][/spoiler]
04 00 00 00 00 0A - "Misterious Code".
It's totaly ignore any texture, and, under different view angles, become totaly black, white, or transparent.
04 00 00 00 00 0B - "Secondary Texture Switcher".
Become super glow, if you come too close. Actualy works only with -vertexlighting, in msh.options, and wraped secondary texture. Without it, become totaly black, in close look's.
04 00 00 00 16 00 - "Blur Code".
Make dissapear any lights, or lighted objects behind of it.
04 00 00 00 40 04 - "Glass Code".
Stopping use alpha channel, for transparence.
Beauty is, the way to perfection.

Glory to Ukraine!  :mf: