Customize MME Effects by Editing .fx Files


A feature article by KillerBeer ... a New Author on LearnMMD.com!How do I customize MME effects? Can I edit an MME effect’s .fx file? How can I control the parameters of an effect from the Accessory Manipulation Panel settings? How can I fine-tune the settings of a an effect?

Customize MME Effects by Editing .fx Files!

One of the laws of the nature states that there’s no end to discoveries once you start exploring. Apparently, there are more new tricks that this old dog TV can be taught.

In my previous MME tutorial, I introduced the idea of editing .fx files as a way to get more from the OldTV Effect. Modifying parameters directly in the script, though, seems to be a crude and ineffective way to achieve it. You have to edit the .fx each time you want different settings, and as you do, you either lose your older settings by re-editing or you have to keep every version of the basically same effect, cluttering your folder with multiple copies of it. Isn’t there a more elegant and universal method to customize MME effects?

If you try to tune the effect with Accessory Manipulation Panel‘s controls like “Tr”, “Rx” or others, nothing actually happens. Transparency does not change, angle of lines does not turn, no other signs of being aware of controls (at least, other than “display”). It seems that unlike with accessories, those settings aren’t hard-coded into the MMD engine when dealing with effects. On the other hand, among other MME effects, there are those (like Beamman’s Bomb Effect, for example) that are actually *controlled* by the AMP settings… and it doesn’t seem that what the Tr “Transparency” control governs is actually transparency!

How do they do that?

Let’s take a look at ParticleEX_Bomb‘s script: PE_Bom.fx. The very first line of it says… (drum-roll)

float AnmTime : CONTROLOBJECT < string name = “(self)”; string item = “Tr”; >;

This actually *is* the code that gets us the control’s value. The “Tr” you see in the object’s parameter corresponds with the “Tr” setting in the AMP… so that statement says that “Tr” in the AMP will now control the custom variable “AnmTime”. More than that, *every* numeric field in that panel can be accessed this way. It allows MME writers a new degree of flexibility. We do not need to edit the .fx file every time we want to make an adjustment… we set The OldTV MME Effect represents a Really Olde TV! Learn how to reconfigure the OldTV MME Effect.a control variable into the .fx file once and then make adjustments, on the fly, by changing the value of Tr in the AMP!

Now we see how to customize MME effects. Armed with this new knowledge, we can turn our OldTV into a fully configurable effect.

Let’s try to change the fragment we edited earlier in the OldTV.fx file.

FIRST: COPY the original .fx file and give it a new name: OldTV_Orig.fx (or similar) and keep it so that you can always revert to your original settings. Then, get to work on your custom FX file… right-click, “Open with…”, choose “Notepad” (or whatever your poison is, as long as it’s not rich-formatting. (If you plan to make .fx-changing business a regular habit, you also may want to setup the text editor in “Choose default program…” option for .fx files permanently). Now, let’s go Frankenstein on this one!

//at the beginning:
float RudderTr : CONTROLOBJECT < string name = “(self)”; string item = “Tr”; >;
float RudderSi : CONTROLOBJECT < string name = “(self)”; string item = “Si”; >;
float RudderX : CONTROLOBJECT < string name = “(self)”; string item = “X”; >;

// … and finally distort
img.x += distortionScale * noisy * dst * RudderSi; //instead of a constant
float4 image = tex2D(Image, img);

// Combine frame, distorted image and interference
image.rgb += interference * rand * RudderTr; //can you guess how it works?

if(RudderX==0)
{ //instead of erasing the line, let’s make it flexible
image.rgb *= frame;
}

EDITOR’S NOTE: The WordPress engine used by LearnMMD site edits the posted text as it finds necessary; I can not control it. In particular, it changes straight ASCII double quotes into Unicode curved ones that MME script interpreter does not recognize. If you want to copypaste the fragment above into your own script, make sure to fix them back.

Now what we previously did by editing the script’s text can be done directly in MMD. By entering a value into the “Si” field of the AMP panel we can change the level of distortion (although for some reason it is multiplied tenfold compared to the original, it *is* adjustable, just use decimals), by setting X to a non-zero value – turn off the frame, and there’s also a new setting we didn’t do before: “Tr” now can set an effect’s visibility gradually rather than turn it on/off like “Display” does. Now we not only won’t have to re-edit the script each time we want the effect to look differently – but we can change it on the fly, involving those transformations in the video as a part of the effect itself.

Our OldTV gets even smarter!

Can we teach it to make coffee too, while we’re at it?

In the next episode: With a Smile! Learn to create unlimited amount of effect-adjusting sliders using facial expressions of a .pmd model!


 

Need help? email LearnMMD@aol.com to ask questions and get answers!


– SEE BELOW for MORE MMD TUTORIALS…




Visit the LearnMMD.com Homepage! Plenty of Mikumikudance instruction and info!