Difference between revisions of "Editing MBM Textures"

From Kerbal Space Program Wiki
Jump to: navigation, search
(added alternative software)
m (Added about section for non-dead-end page)
 
(7 intermediate revisions by 7 users not shown)
Line 1: Line 1:
 +
== About MBM file ==
 +
3D model texture used by [[Kerbal Space Program]]; saves textures referenced by the .MU mesh file; used for providing the surface appearance of [[craft]]s and other space objects.
 +
 
== Requirements ==
 
== Requirements ==
 
Before we start, we need these tools:
 
Before we start, we need these tools:
 
+
* Photoshop
Photoshop
+
* Hex Editor HxD or frhed
 
 
Hex Editor HxD or frhed
 
  
 
== Example ==
 
== Example ==
 
Let's take an example of a model with two textures.
 
Let's take an example of a model with two textures.
 
+
* model.mu
model.mu
+
* model000.mbm
 
+
* model001.mbm
model000.mbm
 
 
 
model001.mbm
 
  
 
== Editing Textures as .PBM Images ==
 
== Editing Textures as .PBM Images ==
01) First, we rename model000.mbm to model000.pbm and model001.mbm to model000.pbm.
+
# First, we rename model000.mbm to model000.pbm and model001.mbm to model001.pbm.
 
+
# Now, we open model000.pbm with HxD and you will see a picture like this:<br />[[File:Hex 01.png|none]]<br />The first 20 bytes is what makes the MBM format different from PBM - Portable Bitmap Format.
 
+
# Also, pay attention to the Magical Number. Each model000.mbm has its own Magical Number, so always make a backup, or write somewhere these first 20 bytes for later, so you are able to restore the image to the original formatting.<br />[[File:Hex 05.png|none]]
02) Now, we open model000.pbm with HxD and you will see a picture like this:
+
# Now, we select them and replace them with one of these 20 bytes and replace them with one of these lines:
[[File:Hex 01.png|left]]
+
#* For 1024 x 1024 pixel images use this row:<br />[[File:Hex 02.png|none]]
 
+
#* For 512 x 512 pixel images use this row:<br />[[File:Hex 03.png|none]]
 
+
#* For 256 x 256 pixel images use this row:<br />[[File:Hex 04.png|none]]
 
+
# Open .PBM images with Photoshop, and do anything you want with it. Then save. Avoid changing texture size, because I haven't tried to change texture size, so I can't tell if it will work correctly or not.
 
+
# Now, open the changed .PBM image with HxD again:<br />[[File:Hex 08.png|none]]
 
+
# And replace with original 20 bytes that were there:<br />[[File:Hex 06.png|none]]
 
+
# And don't forget about the corresponding Magic Number:<br />[[File:Hex 07.png|none]]
 
+
# Save and now rename them back from model000.pbm to model000.mbm and model001.pbm to model001.mbm.
 
+
# ?????
 
+
# PROFIT
 
+
# I don't know about other editors if they work with PBM or no, check it at you own risk.
The first 20 bytes is what makes the MBM format different from PBM - Portable Bitmap Format.
+
# Also when you writing in HxD be sure that "." is '''0A''' and not '''2E'''.
 
 
 
 
 
 
03) Also, pay attention to the Magical Number. Each model000.mbm has it's own Magical Number, so always make a backup, or write somewhere these first 20 bytes for later, so you are able to restore the image to the original formatting.
 
[[File:Hex 05.png|left]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
04) Now, we select them and replace them with one of these 20 bytes and replace them with one of these lines:
 
 
 
For 1024 x 1024 pixel images use this row:
 
[[File:Hex 02.png|left]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
For 512 x 512 pixel images use this row:
 
[[File:Hex 03.png|left]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
For 256 x 256 pixel images use this row:
 
[[File:Hex 04.png|left]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
05) Open .PBM images with Photoshop, and do anything you want with it. Then save. Avoid changing texture size, because I haven't tried to change texture size, so I can't tell if it will work correctly or not.
 
 
 
 
 
 
 
06) Now, open the changed .PBM image with HxD again:
 
[[File:Hex 08.png|left]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
07) And replace with original 20 bytes that were there:
 
[[File:Hex 06.png|left]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
08) And don't forget about the corresponding Magic Number:
 
[[File:Hex 07.png|left]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
09) Save and now rename them back from model000.pbm to model000.mbm and model001.pbm to model000.mbm.
 
 
 
 
 
11) ?????
 
 
 
 
 
12) PROFIT
 
 
 
 
 
13) I don't know about other editors if they work with PBM or no, check it at you own risk.
 
 
 
 
 
14) Also when you writing in HxD be sure that "." is '''0A''' and not '''2E'''.
 
 
 
  
 
== Editing Textures as .RAW Images ==
 
== Editing Textures as .RAW Images ==
01) Rename the image file extension from .MBM to .RAW
+
# Rename the image file extension from .MBM to .RAW
 
+
# Remove the first 20 bytes via HEX editor (copy them somewhere with Magical Number) & save file.<br />[[File:Hex 05.png|none]]
 
+
# Now, open in Photoshop. This part is a bit tricky, here starts the game "guess images size and amount of channels", but a little bit of mathematics can help you:
02) Remove the first 20 bytes via HEX editor (copy them somewhere with Magical Number) & save file.
 
 
 
[[File:Hex 05.png|left]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
03) Now, open in Photoshop. This part is a bit tricky, here starts the game "guess images size and amount of channels", but a little bit of mathematics can help you:
 
  
 
For example, after removing 20 first bytes,the picture size in bytes is '''1,048,576'''. Let's assume that picture's size is 512 x 512 pixels.
 
For example, after removing 20 first bytes,the picture size in bytes is '''1,048,576'''. Let's assume that picture's size is 512 x 512 pixels.
Line 171: Line 42:
 
And in our case it means: 1048576/512*512 = 1048576/262144 = 4 channels in 8 bit colors or 2 channels in 16 bit colors.
 
And in our case it means: 1048576/512*512 = 1048576/262144 = 4 channels in 8 bit colors or 2 channels in 16 bit colors.
  
 
+
''Channels'' - assumable amount of channels in image. Defaults are 2, 3, 4 & etc. channels.
''Channels'' - assumable amount of channels in image. Defaults are 2, 3, 4 & etc channels.
 
  
 
''Depth'' - assumable size in bits of every channels. Defaults are either 8 bit, or either 16 bit. 8 bit means 256 in decimal, so 256*3 channels and 16,777,216 colors.
 
''Depth'' - assumable size in bits of every channels. Defaults are either 8 bit, or either 16 bit. 8 bit means 256 in decimal, so 256*3 channels and 16,777,216 colors.
Line 182: Line 52:
 
''Bytes'' - exact size of image in bytes after we removed first 20 bytes.
 
''Bytes'' - exact size of image in bytes after we removed first 20 bytes.
  
 
+
# Edit via Photoshop, saving again as RAW image.
03) Edit via Photoshop, saving again as RAW image.
+
# Add first 20 bytes back.
 
+
# It should work. For me it does.
 
+
# ?????
04) Add first 20 bytes back.
+
# PROFIT
 
 
 
 
05) It should work. For me it does.
 
 
 
 
 
06) ?????
 
 
 
 
 
07) PROFIT
 
  
 
== Converting Textures in to .PNG Images and making .MU Model to load them ==
 
== Converting Textures in to .PNG Images and making .MU Model to load them ==
01) Rename image file extension from .MBM to .RAW
+
# Rename image file extension from .MBM to .RAW
 
+
# Remove first 20 bytes via HEX editor once and for all.<br />[[File:Hex 01.png|none]]
 
+
# Now open in Photoshop. Follow previous instructions of how-to open .RAW Image in Photoshop.
02) Remove first 20 bytes via HEX editor once and for all.
+
# Before editing, Flip image Vertically and save it as .PNG
[[File:Hex 01.png|left]]
+
# Open '''model.mu''' with HxD hex editor, go the end of the file. You will see this there:<br />[[File:Hex 09.png|none]]
 
+
# Now, change "mbm" extensions for all images in to "png" and save.<br />[[File:Hex 10.png|none]]
 
+
# Now models should load PNG images, instead of MBM. It does for me.
 
+
# ?????
 
+
# PROFIT
 
 
 
 
 
 
 
 
 
 
 
 
 
 
03) Now open in Photoshop. Follow previous instructions of how-to open .RAW Image in Photoshop.
 
 
 
 
 
04) Before editing, Flip image Vertically and save it as .PNG
 
 
 
 
 
05) Open '''model.mu''' with HxD hex editor, go the end of the file. You will see this there:
 
[[File:Hex 09.png|left]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
06) Now, change "mbm" extensions for all images in to "png" and save.
 
[[File:Hex 10.png|left]]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
07) Now models should load PNG images, instead of MBM. It does for me.
 
 
 
 
 
08) ?????
 
 
 
  
09) PROFIT
+
[[Category:Modding Tutorials]]

Latest revision as of 04:14, 24 July 2024

About MBM file

3D model texture used by Kerbal Space Program; saves textures referenced by the .MU mesh file; used for providing the surface appearance of crafts and other space objects.

Requirements

Before we start, we need these tools:

  • Photoshop
  • Hex Editor HxD or frhed

Example

Let's take an example of a model with two textures.

  • model.mu
  • model000.mbm
  • model001.mbm

Editing Textures as .PBM Images

  1. First, we rename model000.mbm to model000.pbm and model001.mbm to model001.pbm.
  2. Now, we open model000.pbm with HxD and you will see a picture like this:
    Hex 01.png

    The first 20 bytes is what makes the MBM format different from PBM - Portable Bitmap Format.
  3. Also, pay attention to the Magical Number. Each model000.mbm has its own Magical Number, so always make a backup, or write somewhere these first 20 bytes for later, so you are able to restore the image to the original formatting.
    Hex 05.png
  4. Now, we select them and replace them with one of these 20 bytes and replace them with one of these lines:
    • For 1024 x 1024 pixel images use this row:
      Hex 02.png
    • For 512 x 512 pixel images use this row:
      Hex 03.png
    • For 256 x 256 pixel images use this row:
      Hex 04.png
  5. Open .PBM images with Photoshop, and do anything you want with it. Then save. Avoid changing texture size, because I haven't tried to change texture size, so I can't tell if it will work correctly or not.
  6. Now, open the changed .PBM image with HxD again:
    Hex 08.png
  7. And replace with original 20 bytes that were there:
    Hex 06.png
  8. And don't forget about the corresponding Magic Number:
    Hex 07.png
  9. Save and now rename them back from model000.pbm to model000.mbm and model001.pbm to model001.mbm.
  10.  ?????
  11. PROFIT
  12. I don't know about other editors if they work with PBM or no, check it at you own risk.
  13. Also when you writing in HxD be sure that "." is 0A and not 2E.

Editing Textures as .RAW Images

  1. Rename the image file extension from .MBM to .RAW
  2. Remove the first 20 bytes via HEX editor (copy them somewhere with Magical Number) & save file.
    Hex 05.png
  3. Now, open in Photoshop. This part is a bit tricky, here starts the game "guess images size and amount of channels", but a little bit of mathematics can help you:

For example, after removing 20 first bytes,the picture size in bytes is 1,048,576. Let's assume that picture's size is 512 x 512 pixels.

I use such formula to calculate: Channels * (Depth/8) = Bytes / (Length * Width)

And in our case it means: 1048576/512*512 = 1048576/262144 = 4 channels in 8 bit colors or 2 channels in 16 bit colors.

Channels - assumable amount of channels in image. Defaults are 2, 3, 4 & etc. channels.

Depth - assumable size in bits of every channels. Defaults are either 8 bit, or either 16 bit. 8 bit means 256 in decimal, so 256*3 channels and 16,777,216 colors.

Length - assumable length of images. Defaults are 256, 512, 1024.

Width - assumable width of images. Defaults are 256, 512, 1024.

Bytes - exact size of image in bytes after we removed first 20 bytes.

  1. Edit via Photoshop, saving again as RAW image.
  2. Add first 20 bytes back.
  3. It should work. For me it does.
  4.  ?????
  5. PROFIT

Converting Textures in to .PNG Images and making .MU Model to load them

  1. Rename image file extension from .MBM to .RAW
  2. Remove first 20 bytes via HEX editor once and for all.
    Hex 01.png
  3. Now open in Photoshop. Follow previous instructions of how-to open .RAW Image in Photoshop.
  4. Before editing, Flip image Vertically and save it as .PNG
  5. Open model.mu with HxD hex editor, go the end of the file. You will see this there:
    Hex 09.png
  6. Now, change "mbm" extensions for all images in to "png" and save.
    Hex 10.png
  7. Now models should load PNG images, instead of MBM. It does for me.
  8.  ?????
  9. PROFIT