Importing an image as a texture

This tutorial will explain how to To manipulate image files, we'll here use Gimp. It's an open-source software that works on Windows and MacOS.
 * edit an image so it can be imported in MagicaVoxel
 * import a new color palette to correctly display that image
 * import your image as a new MagicaVoxel object

You can of course use any other program you'd be more familiar with.

This tutorial may be easier to follow on a computer.

Choose a texture example
Let's browse, for example, texturex.com and choose a simple wood plane surface like this one.

Download the small version:  pixels (px).

Open the image in Gimp (if you get a dialog window about the color profile, click ).

The software's interface may seem complex, but don't worry, every step needed will be explained.

To be able to import it in MagicaVoxel, we need to:
 * change the image's resolution
 * decrease the number of colors

Why resize the image? Because each MagicaVoxel object cannot exceed 126  voxels (vx) in any dimension.

As each pixel of an imported image fills  voxel of a new object, we need to resize down our image so its biggest dimension will be less than 126   pixels (px).

[EDIT] : Since MagicaVoxel v0.99.5, objects can now go up to vx in any dimension.

And why decrease the number of colors? Because the image we use has a color depth of 24-bit (RGB), which means a color palette of more than 16.7 millions colors.

MagicaVoxel's Model editor works with a color palette of 256 colors. Lowering the color depth of our image allows to precisely control its render, as each color will have an equivalent in MagicaVoxel's palette.

Change image resolution
To change the image resolution, use the top menu.



Then choose these settings: Then click.





Note:

will give you a more pixellated effect with more contrast.



Decrease the number of colors
To decrease color depth, use the top menu  and choose



Then, we'll choose: Then click.
 * with a maximum number of colors of
 * Check
 * Choose

The number of colors can be changed depending on:
 * the texture quality you need
 * the amount of palette colors you want to reserve for this object in MagicaVoxel





We need now to save this image in PNG format.

Use  or CTRL + SHIFT + e and choose your filename and saving location.

Be sure to add a  extension to your filename and click   twice (leave the default settings).





Import a new MagicaVoxel palette
Now that our texture file is resized and color optimized, we can easily create a new palette:
 * Activate the 3rd palette index
 * RButton drag your texture file and drop it over the palette cells

Note how the palette is entirely updated, and how colors  to   are replaced by the exact number of color we chose in Gimp.



Import an image as a new object
For this final step, we have: We can create our new object:
 * a  image of less than 126   pixels wide, a.k.a. our texture file
 * that texture file color depth equal or less than 8-bit/256 colors (4-bit/16 colors in our example)
 * MagicaVoxel color palette ready and matching exactly our texture file colors
 * switch MagicaVoxel in World editor mode with TAB
 * RButton drag your texture file and drop it over the world window

Note how a new object of  voxels (x/y/z) has been added to our project.

You can also drag and drop that texture file in Model editor, but it will resize the active object according to the texture resolution, and replace all existing voxels in that object.



Pros and cons of this technique
Should you consider using this kind of texture import?
 * YES, if you're beginning a new project, and need a color palette close to an existing reference (portrait, movie scene, landscape, etc.)
 * YES, if you're planning to use small flat elements or patterns you don't want to model from scratch, and which share the same palette
 * YES, if you use imported images as proportion canevas (like top, front, side silhouettes), don't change your color palette, and will delete these objects after use
 * NO, if you're at the end of your project, with palette and materials already ordered and assigned
 * NO, if you need bigger textures than 126  px wide, i.e. for a ground map - use Zarbuz's FileToVox instead!
 * NO, if you're afraid to micro-manage your colors when importing objects like editing your palette file manually

I hope this tutorial will be of any help... Feel free to |comment or ask for help in our discord.

Thanks for reading!