Mental Mill Artist Edition

From SEWiki
Jump to: navigation, search

Mental Mill Artist Edition (aka MMAE) is a free GUI-based shader editing tool from Mental Images. The interface should be somewhat familiar to you if you have used Art of Illusion's procedural texture editor, as it uses "blocks" with inputs and outputs similarly to AoI.

Shaders are similar to textures in that they are used to apply color to a model, but they are much more flexible than textures - one shader can be used to create textures for multiple models, as shaders are procedural (defined mathematically in a special graphics programming language), and not specific to a single model's geometry and UV coordinates. Thus, you can define one shader in MMAE and use it for an entire shipset, as opposed to tediously creating individual textures for each and every ship in a program such as GIMP.

However, Space Empires V does not support shaders, so you will need an intermediate program to convert the shaders into textures for each model you want to use them with. This can be done with Wings 3D version 0.98.37-SE, which is available via the Wings forum. (TODO - add a link directly to the download site here!) It will not work with earlier versions of Wings, as they either had a bug preventing the texture conversion from working, or (if you go back far enough) the functionality had not been introduced yet.

To convert a shader into a format usable by Wings 3D takes a number of steps:

1. Create your shader in Mental Mill's GUI.

2. Export it to GLSL from the File menu. That's the OpenGL shader programming language. Yes, I know SE5 uses DirectX, but we're going through Wings here which uses OpenGL.

OK, now you have 2 files, "yourshader_f.gl" and "yourshader_v.gl". What to do with them? Copy them into your wings\plugins\autouv directory. (You'll need the Scorpius v0.98.37 version of Wings because the 0.98.36 version had a bug where these shaders don't work at all!)

Now there's still a few more steps - hang on, though, this will be pretty nifty!

3. Create a text file in the autouv directory where you just placed the shader files. Call it "wpc_yourshader.auv" - the "wpc" and "auv" are important, otherwise Wings won't recognize the shader!

4. Place the following text into your newly created text file:

{name, "My Shader"}. {vertex_shader, "myshader_v.gl"}. {fragment_shader, "myshader_f.gl"}.

5. Look in the "yourshader_f.gl" file for the following lines:

// // The following are free parameters of the shader // that should be set by the application at runtime. //

Take note of any lines immediately following that begin with the word "uniform". Those are parameters for your shader, and you need to map those to items in Wings' UI for the shader to be as functional as it could be.

6. For each of those lines, add a line to your new file along the following format:

{uniform, type, variableName, DefaultValue, "StringInGUI"}.

For instance, if you see

uniform float msl_Generator_checker_1_checkerSize;

you need to put something like

{uniform, float, "msl_Generator_checker_1_checkerSize", 0.2, "Checker Size"}.

Note that if you see a "vec4" you need to put "color" instead in your file, not "vec4", as the vec4 type is used to represent a color in RGBA format.

Don't worry, we're almost there!

7. Open up the "myshader_v.gl" file and insert the following text above the "void main()":

varying vec2 w3d_uv; varying vec3 w3d_pos;

8. Also in the same file insert the following text before the closing curly brace:

w3d_uv = gl_Vertex.xy; w3d_pos = gl_MultiTexCoord1.xyz; vec4 Position = gl_Vertex; gl_Position = gl_ModelViewProjectionMatrix * Position;

9. On the line that looks like this:

tex_coord0 = gl_MultiTexCoord0;

change the second zero to a one:

tex_coord0 = gl_MultiTexCoord1;

OK, now we can open up Wings and try this baby out!

10. Load your Wings model and run through the AutoUV functionality to create a texture mapping for your model, just like you normally would before exporting it to GIMP for that tedious editing process. But instead of exporting to GIMP, select the faces you want to apply your shader to (or all of them if you only want to use the one shader), right-click in the AutoUV window, and choose "Create Texture".

11. You are now presented with a list of options. Choose a size for your texture, and in the second dropdown box you *should* find the name of your shader! Select it, then click on Options.

12. In the second options dialog, presto! You should find all those parameters you spent that time setting up earlier, ready for customization! (See, I told you setting them up was worthwhile! ) Set them to your heart's content, then click OK.

13. Click OK on the original options dialog, and wait a moment. WHOA! Is that... could that be?!? Did Wings just apply your *shader* to the model, and create a *texture* out of it??? And it looks so NICE on your ship! And you... you can REUSE the shader! On the other ships in your shipset! Instead of texturing them all again from scratch!!!

Links

[1] - NVIDIA FX Composer, with which MMAE is bundled.

[2] - The official home page with a description of MMAE.