How ray-cast/ray-mmd works
Project’s Purpose and Components
• Ray-MMD is aimed at integrating a physically based rendering pipeline and shader effects into MikuMikuDance.
• Its purpose is to enhance rendering using realistic material properties, varied lighting, fog effects, post-process operations, and sky/atmosphere simulation.
• The key external requirements include MikuMikuDance (the host application), MikuMikuEffect (for shader effects management), and a Direct3D 9 environment with Shader Model 3.0 support.
Main High-Level Components
a. Rendering Core and Entry Point
– The “Main” directory holds core shader files (e.g., main.fx, variants) that kick off the rendering pipeline.
b. Shader Utility and Shared Resources
– The “Shader” directory contains shared code (e.g., BRDF, tone mapping, post-process effects) and textures used by many other modules.
c. Materials System
– The “Materials” folder is organized into several material types (ClearCoat, Cloth, Editor, Emissive, Hair, Metallic, Programmable, Skin, Subsurface, Transparent, Video) that define how surfaces interact with light.
d. Lighting Module
– The “Lighting” folder is a robust sub-system with definitions for multiple light sources (Directional, Disk, Point, Spot, Sphere, and more, including IES profiles), handling both basic illumination and shadow techniques.
e. Atmosphere and Fog Effects
– The “Fog” directory covers different fog implementations (atmospheric, ground, volumetric) to simulate scattering and distance effects.
f. Post-Processing and Outline Effects
– The “Outline” directory holds shaders specific to edge outlining, while various shader files in the “Shader” folder (and parts of “Lighting” and “Shadow”) implement post-process features such as FXAA, SMAA, bloom, and HDR.
g. Skybox and Environment
– The “Skybox” folder contains shader and texture files for various sky rendering techniques (static, time-of-day transitions, night effects).
h. Extensions
– The “Extension” folder provides plug-in effects such as ColorGrading, FilmGrain, FXAA, LightBloom, SMAA, Spectrum, and StereoImage. These extend or modify the rendering pipeline.
Relationships and Interactions
• The “Main” component (core renderer) drives the shader pipeline and delegates various tasks to sub-systems.
• The “Shader” and “Materials” modules are closely integrated; materials use shader routines to compute physical light interactions.
• The “Lighting” module delivers light data and shadow maps to the main shader pipeline, interfacing with both post-process modules and the materials system.
• “Fog,” “Skybox,” and “Shadow” components provide environmental effects that feed into the rendering pipeline.
• “Extensions” act as optional plug-ins that can further modify the image, applied as additional post-process or pre-render effects.
Architectural Patterns and Design Principles
• Modularity – The project is organized in a directory structure that mirrors functional modules (Materials, Lighting, Fog, etc.), encouraging independent development and plug-in based extensions.
• Data Flow Separation – The rendering pipeline is depicted as a sequence of processing stages: core shader entry (Main), material evaluation, lighting/shadow computation, environmental effects, and finally post-processing.
• Reusability – Shared shader functions, common effects, and texture resources are centralized in the “Shader” folder, reducing duplication.
Final Elements
– Clear labels for each component and sub-module.
• Core Rendering Components
• Modular Shader/Material Components
• Environmental/Post-Processing Effects
• Plug-In Extensions
• External Dependencies
Happy diagramming!