Porting from MME

A creator's summary of moving MME (MMD Effect) .fx to MMDX Effects - license first, choosing a kind, a semantic mapping table, textures and rights, and a checklist.

What porting means

Moving an MME effect (.fx) to MMDX Effects is not a direct translation of D3D9 state: it means rewriting it against the pack API. MMDX Effects has no arbitrary scene re-rendering (ScriptExternal), no free-form offscreen passes and no script VM. So some effects get simpler, some are made differently, and some cannot be expressed.

This page is a summary. For detailed examples and the full table, see docs/mme_porting.md in the app repository.

License first

Port only what you are allowed to port.

  • Your own effects, or effects whose license / author permits modification (改変) and redistribution. Read the readme / readme.txt / license text shipped with the effect. “It is public on the internet” is not a license.
  • Credit the original author in the pack’s authors, and mention them in the localised description if needed. Keep the original effect name in the description so users can find the source.
  • Never put textures extracted from a game into a pack. Keep textures you do not own in the user texture folder and declare them as "origin": "user" in pack.json. The pack samples them as pack textures and renders them white if the user has not set the folder.

If the license is unknown, ask the author, and do not publish to the gallery until then.

Choosing a kind

MME effectMMDX Effects formDocumentation
Screen / post-process effect (ScriptClass=scene, ScriptOrder=postprocess)Screen effect ("type": "effect")Screen effects
Object / material shader (object, object_ss, edge)Surface shader ("type": "surface", default)Shader API
Object shader that must follow PT / offline GISurface shader + pt_surface.hlslPT / GI
.x accessory particles / world propsWorld effect (see built-in Snow)-
Controller-driven parameters (CONTROLOBJECT morphs)Pack parameters, Studio timeline keysManifest
Lighting / effects / pack selection bundleLook ("type": "look")Looks

post or pre-bloom? MME post-process effects were written for the MMD back buffer, i.e. display values after tone mapping. That is the pack’s "stage": "post". Use "pre-bloom" only when you really need linear HDR (glow, exposure, physically scaled blur), and do not move MMD colour correction into pre-bloom.

Surface or screen? If you paint character / stage materials it is a surface shader; if you only read the finished image it is a screen effect. MME effects that do both are split into two packs.

Accessories do not port 1:1. .x accessories with their own .fx (eyes, dust, magic circles) are world effects: entities placed in the scene and keyed, with world.hlsl defining spawn / simulate / shade functions. Accessory effects can follow the built-in “Snow” world effect structure or continue running as MME effects.

Mapping table

MMEEquivalent in a packNotes
TIMEi.time (effect / pass), gTime (surface / pass)Scene time in seconds, not wall clock. Studio scrubbing and offline renders reproduce it.
ELAPSEDTIME<SyncInEditMode>i.dt, PackStateInput::dtPer rendered frame. 1/60 for deterministic runs, 1/fps for offline video, 1/60 per state step for GI stills. Do not assume 60 Hz.
VIEWPORTPIXELSIZEi.outputSize (effect), i.size (pass), s.pixel + gViewportSize (surface)The output resolution, not the MME render target. PackPassSize(n) is the pass’s own size.
CONTROLOBJECT item = "X"/"Y"/"Z"/"Rx"/...Pack parameters (PackParam(i)), timeline keysControllers were animation channels; parameters are the native equivalent. Static in playback / looks, keyed in Studio.
CONTROLOBJECT bone position / matrixScene inputs: "inputs": ["performer.head", ...] -> PackInputValid, PackInputPos, PackInputFrameRoles resolve through the humanoid map. There are head, centre, both hands and both feet, plus light.key and camera.focus.
CONTROLOBJECT morph weightsPack parameters, or scene / audio inputs for automatic motionThere is no API for reading morphs. Convert morph animation into parameter keys.
RENDERCOLORTARGET + ScriptExternal / multi-passv5 "passes" (float4 Entry(PackPassInput i), PackPassSample, PackPassLoad, PackPassSize)Up to 8 passes, 1/64 .. 1 scale, RGBA16F. ScriptExternal (redrawing the scene) has no equivalent. Effects see the frame that already exists (gEffectSource, depth / normal / motion).
Multi-pass needing the previous frame"passes": [{ ..., "history": true }] (passes.history)Previous frame results follow the same reset / advance rules as v4 state. Read with PackPassSampleHistory / PackPassLoadHistory.
Mip chains / blur levels in scripts"mips": true on a pass (passes.mips)A mip chain is built after the pass runs and read with PackPassSampleLevel(n, uv, lod).
RENDERDEPTHSTENCILTARGET / ScriptExternal depthPackEffectInput::depth (raw device depth), gEffectDepth, LinearZ(depth)Read-only. depth = 1 is the background. You cannot write to the depth-stencil target.
OFFSCREENRENDERTARGET masks (AutoLuminous, M4Layer, ObjectLuminous)Redesign with "requires": ["inputs.id"] + surface PackResult::tagDo not translate 1:1. Use the gEffectId bit layout and PackSampleId / PackId*.
WORLDVIEWPROJECTION, WORLD, VIEW, PROJECTION (+ inverses / transposes)gView, gProj, gViewProj (common.hlsli), gEyePos, gLightDirSurface code also has s.worldPos, s.N, s.V, s.L and s.viewZ. There is no separate MME-style light camera.
POSITION / DIRECTION (camera / light)gEyePos, gLightDirThe same values in every pass.
MaterialDiffuse / DIFFUSEPackDiffuse(), PackAmbient(), PackSpecular(), PackSpecularPower(), PackEdgeReflectivity()Gamma space, material morphs applied. Same as MMD.
MaterialTexture (use_texture)PackSurface::tex (gamma space, morphs applied), strength via PackParamMaterials without a texture are white.
Sphere maps (use_spheremap, add / multiply)PackSphereMode(), PackSampleSphere(s.N); Sekai UV slots via PackHasSphereTex(), PackSampleSphereUv(uv)PackSampleSphere is the MMD view-space lookup. PackSampleSphereUv is only for the Project Sekai _H layout.
Toon (use_toon)PackHasToon(), PackSampleToon(v) (v = 0 lit .. 1 shadow); UV-mapped via PackHasToonMap(), PackSampleToonUv(uv)Materials without a toon return white, so guard with PackHasToon.
Self shadow (object_ss, depth map in register(s0))PackSurface::shadow (0 shadow .. 1 light) and the host lighting helpersDo not sample MMD’s shadow buffer. Cascaded / RT shadows are already composited by the host, and PackMmdLit(s) starts from the MMD colour model.
sampler_state + tex2DPackSampleTex / PackSampleTexLevel (surface), PackFxSampleTex / PackFxSampleTexLevel (effect), or gLinear / gPoint / gClamp / gWrap + SampleLevelPacks sample explicitly and PT has no implicit Sample. Declare the address mode with "address" in pack.json. sRGB textures are already linear, so do not apply SrgbToLinear again.
ANIMATEDTEXTURE (gif / APNG)Not supportedBake frames into a sprite sheet or turn the animation into a parameter sequence. A single static texture is the supported scope.
MMM_* (multi-light arrays, GPU skinning, MMM_UnpackDepth, toon / shadow samplers)Not supportedMMDX12 follows MMD semantics and has no MMM extension branches. Use the pack’s scene / audio inputs instead of MMM globals.
TEXTUREVALUE, LEFTMOUSEDOWN / mouse semanticsNot supportedTexture reads and real-time mouse are not in the pack contract.

Depth and normals

PackEffectInput gives the same G-buffer the engine uses.

  • i.depth: raw device depth (1 = background). Convert to view-space z with LinearZ(i.depth); gNearZ / gFarZ are in common.hlsli.
  • i.normal: view-space normal, octahedral encoded (the normal target). On the background the direction is meaningless, so guard with i.depth < 1.
  • i.motion: uv(current) - uv(previous). 0 in offline GI.

Textures and samplers

"textures": [
  { "file": "textures/grain.png", "address": "wrap", "srgb": false },
  { "file": "textures/mask.png",  "address": "clamp" }
]

Screen effects sample with PackFxSampleTex(i, uv) (linear for sRGB), surfaces with PackSampleTex. Missing files are white and do not kill the pack. The limits are 16 textures, 4096 px and 32 MB.

Checklist

  • License checked, original author credited in authors / description, game-extracted textures set to "origin": "user".
  • pack_check <folder> --compile passes: PackEffect / PackEffectState, every passes entry, and PackEvaluate / PackEvaluateLighting if pt_surface.hlsl exists.
  • Before / after previews: preview_before.png is the same frame with the pack off, preview.png the same size and composition with it on.
  • Same frame when off: no effects in the stack means no targets or passes, and no surface pack selected means nothing changes.
  • Every render path checked: raster, RT, PT, offline GI. Effects do not apply to unlit / wireframe / quad views.
  • No [E] / [W] lines for the pack in mmdx12.log.
  • Rebalanced constants for the pack’s colour space: MMD gamma-space looks go to post, linear terms to pre-bloom.
  • No claim of exact parity. Say “based on” / “inspired by” and describe intended differences in the description.