Repository navigation
Materials & PBR Shading
Ray-MMD ReForge is a Physically Based Rendering (PBR) engine utilizing metallic-roughness workflow and custom shading models.
| Shading Model | ID | Material Preset Path | Description |
|---|---|---|---|
| Standard (Default) | 0 | Materials/material.fx |
Standard metallic/roughness PBR (Cook-Torrance GGX). |
| ClearCoat | 6 | Materials/ClearCoat/ |
Car paint, polished wood, lacquered surfaces, and eyes. |
| Skin (Dual-Lobe) | 2 | Materials/Skin/ |
MetaHuman/UE5 dual-specular lobe with SSSS scattering. |
| Subsurface (Marble/Wax) | 1 | Materials/Subsurface/ |
Organic translucent materials with deep scatter profile. |
| Hair (Anisotropic) | 4 | Materials/Hair/ |
Kajiya-Kay anisotropic highlights with shifted tangents. |
| Cloth (Sheen) | 5 | Materials/Cloth/ |
Velvet, denim, cotton with grazing-angle rim sheen. |
| Glass (Chromatic) | 3 | Materials/Transparent/ |
Physical RGB chromatic dispersion refraction. |
| Emissive | 0 | Materials/Emissive/ |
Self-illuminating neon, screens, and light sources. |
Ray-MMD ReForge combines the Unreal Engine artist subsurface toolchain, optimized dual-lobe microfacet specular, and camera distance-invariant texture-space SSS diffusion:
-
Unreal Engine Subsurface Toolchain: Direct lighting evaluates WrappedDiffuse (
$w=1/3, n=1.5$ ) with AO-scaled BackScatter, view-dependent InScatter, and Beer-Lambert transmission with HSV-luminance-preserving hue shifting. -
Henyey-Greenstein Backlit Forward Glow (
SubsurfaceShadingBacklitGlow): Simulates translucent forward transmission through thin tissue (ears, nostrils, fingers) using Henyey-Greenstein phase evaluation at refraction-corrected view angles (SKIN_BACKLIT_STRENGTH,SKIN_BACKLIT_G 0.76). -
Texture-Space SSS Diffusion (
SSSS_TEXSPACE 1): Direct sun irradiance renders into the character's UV atlas once per frame and convolves with the Christensen-Burley profile in model UV space. The scatter radius remains strictly invariant to camera distance and completely eliminates screen-space silhouette haloing and light bleeding into hair or background geometry. -
Calibrated Skin Shadows & Indirect Lighting (v1.20.14):
- Softened ambient occlusion (
SKIN_AO_STRENGTH 0.50) prevents facial contours and deep creases from crushing into blackness. - Broadened light dermal reflectance (
SKIN_GI_REFLECTANCE_LIGHT 0.68f) preserves authored texture warmth. - Dynamic albedo multi-bounce interreflection curve (
$1.0 + \frac{\text{albedo} \cdot 2.2}{\max(1.0 - \text{albedo} \cdot 0.5, 0.1)}$ ) and linearized cavity occlusion prevent unnatural dark shadowing under SSPT/SSGI. - Subtle indirect specular GI sheen (
specGi * 0.25f) preserves volumetric depth in shadowed silhouettes.
- Softened ambient occlusion (
- Optimized Dual-Lobe Skin Specular: Evaluates Smith joint visibility and Fresnel once for the blended microfacet distribution (70% broad dermal, 30% tight epidermal/sebum layer), halving instruction count while maintaining dual-lobe realism.
- Implements dual-highlight tangent-shifted specular:
- Primary Lobe (R): Sharp specular shifted towards the root.
- Secondary Lobe (TRT): Broader transmission highlight shifted towards the tip, tinted by hair albedo.
-
Burley 2012 Aspect Ratio Parameterization: Energy-preserving anisotropic aspect ratio parameterization for
SpecularBRDF_GGXAniso, producing smooth highlights without sub-pixel shimmering or crawling noise.
-
Band-Limited Hashed Alpha Hair Cutout (v1.20.10): Stochastic alpha testing is strictly band-limited to boundary fringe texels (
[ALPHA_THRESHOLD ± 0.12]) using Dave Hoskins' polynomialHash31without sine. Solid hair interiors (alpha >= 0.62) remain 100% solid and grain-free. -
Dedicated
_realistic.fxHair Variants (v1.20.11):- Base hair presets (
material_hair*.fx) retain classic crisp alpha cutout (HASHED_ALPHA_TEST_ENABLE 0) for anime and stylized models. - 40 dedicated
*_realistic.fxshaders across the collection enable Wyman & McGuire (2017) Hashed Alpha (HASHED_ALPHA_TEST_ENABLE 1) with TAA history reconstruction for soft anti-aliased hair cards and subpixel strands.
- Base hair presets (

Preview rendered using a procedural silky semi-matte hair material configuration.
Tip
ReForge Material Editor: You can procedurally author and preview silky hair fiber normals, Marschner specular tangent shifts, and highlight breakup directly using the Hair Strand Generator node and the Silky Hair preset. See ReForge Material Editor.
ClearCoat Analytical Refraction, Thin-Film Iridescence & Energy Conservation (SHADINGMODELID_CLEAR_COAT)
-
Belcour & Barla (2017) Spectral Iridescence: Implements physical wave interference through thin dielectric films (
EvaluateIridescenceSensitivity,ThinFilmIridescence). Evaluates convolved Gaussians against CIE 1931 XYZ / Rec.709 curves for authentic spectral rainbow interference across automotive clearcoats, oily puddles, soap bubbles, and pearl jewelry. -
Energy Conservation Under Top Coat (
1 - Fc): Physical Fresnel attenuation scales down the substrate diffuse and base specular reflectance based on top coat reflection, preventing unphysical energy gains. -
Snell Refraction Angle Deflection (
RefractBlendClearCoatApprox): Propagates angular refraction deflection to the substrate without tracing secondary rays. -
Beer-Lambert Optical Transmission: Evaluates physical optical absorption through the top coat layer (
exp(-0.06 * max(thinDistance - 2.0, 0.0))), attenuating and tinting underlying specular while preserving energy.
- Colored Penumbra (Filament Fake SSS): Warms and saturates shadow terminator boundaries on skin, cloth, and organic materials with a soft reddish/amber hue, eliminating flat unnatural grey borders between lit and shadowed areas.
- Specular Multi-Bounce AO for Metals: Jimenez multi-bounce formulation prevents deep crevices in colored metals (gold, bronze, copper) from turning black, preserving rich metallic specular interreflections.
- Implements Steve McAuley (2011) energy-conserving two-sided wrapped transmission for
SHADINGMODELID_SUBSURFACE. - Delivers physical backlit translucency for foliage, leaves, paper, petals, and thin cloth without G-buffer thickness artifacts or dark blotches.
MMD anime models are typically modeled with concave (sunken) eye geometry, causing inverted reflections.
- Setting
CONVEX_NORMAL 1inmaterial_eye_anime.fxautomatically inverts the mesh normal curvature: $$\mathbf{N}{xy} = -\mathbf{N}{xy}$$ - Converts flat/concave geometry into a convex refractive corneal dome with realistic spherical skylight reflections.
-
Cornea Iris Parallax Mapping (
ComputeCorneaIrisParallax): Traces view-dependent refraction rays into the eye interior, giving anime and realistic eyes physical iris depth and pupil immersion without modifying mesh geometry. -
Analytical Eye Iris Caustic Highlight (
EyeIrisCaustic): Evaluates focused illumination on the iris opposite incident light direction per Jorge Jimenez (2014).
Tip
ReForge Material Editor: The editor's Eye Cornea & Iris Parallax node automatically synthesizes corneal dome normals, radial iris depth maps, limbal ring darkening, and Snell's law refraction previews with one click. See ReForge Material Editor.
| Standard Eye Shading (Concave Mesh) | ReForge Convex Normal (CONVEX_NORMAL 1) |
|---|---|
![]() |
![]() |
- Multi-layer stochastic glint simulation for cosmetic makeup, shimmering dresses, and metallic flake car coatings (
material_glitter.fx,material_glitter_gold.fx). - Simulates micro-facet orientation noise with view-dependent sparkling highlights that catch direct sun, area lights, and IBL.
- Enabled via
DIFFUSE_BRDF_TYPE 1inray.conf(Portsmouth, Kutz & Hill, JCGT 2025). - Replaces empirical Disney/Burley retroreflection with an analytical energy-preserving model that prevents loss of diffuse bounce energy on rough surfaces (cloth, matte plastics, stone, skin).
4-Wavelength Spectral Dispersion, Beer-Lambert Volume Absorption & Newton Refraction (SHADINGMODELID_GLASS)
-
Beer-Lambert Volumetric Absorption: Physical exponential transmittance attenuation (
$T = e^{-\sigma_{\text{abs}} \cdot d}$ ) calculated along the optical refraction path through the volume. Gives thick glass objects, colored bottles, and water realistic body and depth gradients instead of flat planar transparency. -
4-Wavelength Spectral Dispersion (
$K_0..K_3$ ): Full spectral rainbow splitting mapped across Fraunhofer lines (C, d, e, F lines at 486.1, 546.1, 589.3, 656.3 nm) with temporal jitter, rendering authentic prism refractions along glass edges and faceted gems. -
Elimination of Background Object Duplication: Re-engineered screen-space refraction offset driven directly by view-space normal tilt (
screenNormal = float2(material.normal.x, -material.normal.y)). Planar glass viewed straight-on has zero false lateral displacement, completely preventing ghosted and duplicate objects behind windows and showcases. -
Physical Thin-Glass Default (
customA = 0.5): Calibrated default refraction strength inmaterial_force_glass.fxdelivering subtle, physically convincing thin-glass refraction without geometric warping. -
Ultrafast Newton's Method Refraction (
GLASS_REFRACTION 1): Traces refracted rays directly against native G-buffer depth using Mayer, Assarsson & Sintorn (JCGT 2026) 3D root-finding with bounded deflection (clamp(deltaUV, -0.015, 0.015)). Converges to subpixel accuracy in 3–4 iterations without requiring heavy depth pyramids. -
Dielectric Glass Resolve Bypass & Transmission: Surfaces tagged as
SHADINGMODELID_GLASSbypass diffuse GI accumulation (return 0.0f;in SSPT and SSGI combines), eliminating milky matte fogging and preserving 100% optical clarity. Furthermore, screen-space raymarching traversal cleanly skips glass hits viacontinue;so indirect rays transmit through windows and bottles without false diffuse bounces or artificial occlusion shadows. - Ray-MMD ReForge includes dedicated presets for thick refractive glass (
material_glass.fx), anti-reflective optical spectacles (material_glasses.fx), and forced-transparency presets (material_force_glass.fx). -
Tinted Presets: Inherit the MMD material diffuse color into transmission (
material_glass_color.fx,material_glasses_color.fx,material_plastic_color.fx).GLASS_TINT_EXPONENT(0.25) compresses the tint towards white with hue preserved, so colored glass stays strongly transparent.
Tip
Best Practice for Cockpit / Car Interior Cameras: Automotive PMX models frequently contain multi-layered or single-sided window meshes (exterior glass, tint film, interior window pane, black ceramic frit borders). In a deferred rendering pipeline with single-depth G-buffers, rendering nested transparent surfaces from an interior viewpoint can cause occlusion or sorting artifacts between window layers. When shooting scenes from inside a car cockpit, the industry-standard workflow in MMD is to hide the vehicle's window material subsets in MME (or set their alpha/opacity to 0 in PMX Editor). This eliminates mesh collision artifacts and guarantees pristine HDR lighting, full SSGI bounces, and unobstructed volumetric fog/skybox views through the windshield.
All passes share a single alpha cutout threshold of 0.5: pixels with alpha ≥ 0.5 render as opaque cutouts through the full deferred path — so SSR, GI, and shadows apply to them correctly instead of pushing them into the forward-blended pass with its sorting artifacts. In the Wetness subsystem the threshold is additionally modulated per pixel by Interleaved Gradient Noise, dissolving semi-transparent texels into a stochastic screen-door pattern rather than clipping along hard geometry edges.

Rainbow chromatic aberration along refractive eyeglass lens edges and frames.
- Calculates screen-space geometric normal variance (
$\sigma^2 = |\nabla N|^2$ ) using hardwareddx(N)andddy(N). - Filters microfacet roughness values at distance, completely eliminating high-frequency specular aliasing and shimmering on hair strands, chainmail, and jewelry.
Eliminates repetitive checkerboard and tiling grid artifacts across expansive surfaces (terrain, ground, grass, asphalt, rock, concrete, fabrics) by partitioning the 2D plane into an equilateral triangular grid with stochastic rotations:
-
Luminance- & Slope-Weighted Blending: Albedo maps blend according to luminance contrast, while normal maps blend through heightfield partial derivatives (
$dH/duv$ ), keeping surface features sharp instead of turning into mush. -
Unified Per-Pixel Context: Computes the triangular grid decomposition, hashes, barycentric weights, and screen-space partial derivatives (
ddx/ddy) once per pixel and reuses them across all enabled material channels (Albedo, Normal, Smoothness, Metalness, Occlusion). -
Distance-Adaptive LOD Fade (
HEX_TILING_DISTANCE_LOD 1): As the camera distance increases beyondHEX_TILING_LOD_START(default 15m), the barycentric weights smoothly collapse to the dominant cell, saving texture bandwidth and suppressing distant subpixel moiré. -
Height-Blended Displacement (
HEX_TILING_HEIGHT_BLEND 1): Uses physical crevice depths from height maps (Frostbite/Unreal height-lerp) to route transitions along natural geometric seams (e.g., stones protruding through mud).
Caution
When NOT to use Hex-Tiling:
- Character Models & Unique UVs: Do NOT enable Hex-Tiling on faces, bodies, or hair. Because Hex-Tiling rotates and shifts triangular coordinate patches, a unique UV unwrap will be torn into rotating fragments.
-
Directional Patterns: Textures with strict rectangular alignment (brick walls, parquet wood, striped fabric) will have their mortar joints rotated in random directions under full rotation (
HEX_TILING_ROTATION 1.0). For such surfaces, either useHEX_TILING_ROTATION 0.0or keep Hex-Tiling disabled. -
Performance Budget: Hex-Tiling evaluates 3 texture samples (
tex2Dgrad) per enabled map. Keep it disabled (0) on small props and enable it selectively on vast background surfaces.
#define HEX_TILING_ENABLE 1
#define HEX_TILING_ROTATION 1.0f // 0.0 = aligned offset only, 1.0 = full random orientation
#define HEX_TILING_CONTRAST 0.6f // Contrast falloff for feature blending
#define HEX_TILING_SHARPNESS 7.0f // Barycentric sharpening exponent
#define HEX_TILING_DISTANCE_LOD 1 // Fade to 1 sample at distance
#define HEX_TILING_LOD_START 15.0f // Fade start distance (meters)
#define HEX_TILING_LOD_END 35.0f // Fade complete distance (meters)Replaces hard pixelated alpha cutout edges (clip(alpha - threshold)) with a scale-invariant spatial hash:
- The Nuance (TAA Synergy): In a static single frame, hashed alpha produces a subpixel high-frequency dither. When paired with Temporal Anti-Aliasing (TAA), the multi-frame history reconstruction filter resolves the stipple into silky-smooth, continuous semi-transparency.
- Why it beats Forward Alpha Blending: Transparent meshes in forward passes cannot cast clean contact shadows, receive SSAO/GTAO, or write proper depth into G-buffers. Hashed Alpha renders directly through the deferred G-buffer path, maintaining 100% correct shadow casting, shadow reception, SSGI bounces, and depth-tested SSR reflections without sorting bugs.
- Ideal for anime hair tips, soft eyelashes, foliage leaves, lace ribbons, and sheer fabrics.
#define HASHED_ALPHA_TEST_ENABLE 1
#define HASHED_ALPHA_SCALE 1.0f // Spatial hash frequency scaleAdds a secondary high-frequency normal map that repeats at high UV frequency across the surface:
- Reoriented Normal Mapping (RNM): Blends the micro-detail layer onto the primary normal map without flattening or distorting the underlying base surface curvature.
-
Distance Attenuation (
detailFadeDistance): The micro-detail smoothly fades to flat as distance increases, preventing specular shimmer, noise, and moiré patterns when viewed from afar. - Perfect for skin pores, clothing fabric weave, denim texture, stone grit, and brushed metal grain.
#define DETAIL_MAP_ENABLE 1
#define DETAIL_NORMAL_MAP_FILE "detail_normal.png"
const float detailNormalScale = 1.0;
const float detailNormalLoopNum = 20.0;
const float detailFadeDistance = 15.0; // Distance in meters where detail normal fades outRay-MMD ReForge includes a built-in World Position Offset (WPO) Procedural Wind Engine inside the vertex shader (Materials/material_common_2.0.fxsub). It breathes life into static backgrounds without requiring physical bones or PMX rigging:
| Material Preset | Wind Type ID | Behavior & Use Case |
|---|---|---|
material_leaves_tree.fx |
0 |
Tree Foliage & Canopy: Multi-octave primary branch sway combined with rapid high-frequency UV leaf flutter. |
material_grass.fx |
1 |
Grass & Meadows: Base anchored at ground level ( |
material_vines.fx |
2 |
Vines & Hanging Ivy: Top anchored to arches/columns, lower tendrils swing smoothly like a pendulum. |
material_palm.fx |
3 |
Palm & Broad Fronds: Undulating stem flexing with aerodynamic normal-based edge flapping. |
Every foliage material exposes intuitive physical controls:
#define WIND_ENABLE 1
#define WIND_TYPE 0 // 0: Trees, 1: Grass, 2: Vines, 3: Palm
const float windSpeed = 1.3; // Overall breeze/gust speed
const float windStrength = 0.18; // Sway amplitude
const float windFrequency = 0.45; // Spatial wavelength across world space
const float3 windDirection = float3(1.0, 0.15, 0.4);// Wind vector (X, Y, Z)
const float windTurbulence = 0.35; // High-frequency micro leaf flutterTip
Because Ray-MMD ReForge is a Deferred Renderer, sun shadows, screen-space contact shadows, reflections, and SSGI light bounces automatically animate in real-time together with the moving leaves!
Every material .fx file exposes clean parameters:
// Base Color / Texture Map
#define ALBEDO_MAP_ENABLE 1
#define ALBEDO_MAP_FILE "texture.png"
// Roughness (0.0 = mirror smooth, 1.0 = completely rough)
#define SMOOTHNESS 0.85
// Metalness (0.0 = dielectric/plastic/skin, 1.0 = pure metal)
#define METALNESS 0.0
// Normal Map
#define NORMAL_MAP_ENABLE 1
#define NORMAL_MAP_FILE "normal.png"
#define NORMAL_MAP_SCALE 1.0Ray-MMD ReForge is an open-source next-generation PBR render engine for MMD based on Ray-MMD (Rui). Released under the MIT License.

