Ray-MMD Toon Shading Basics

How can I set up Raycast/Ray-MMD toon-shading? How can I use toon-shading with Raycast? What is one method of toon shading?

Ray-MMD Toon Shading Basics

Ray-MMD Toon Shading Basics - Finished image

Hi, folks! I’m MuffinMo, and this is my first article, so please treat me kindly. Today, I’m going to teach you how to do toon shading with Raycast-MMD. This is the technique that I used in my Ai Kotoba III video, and it can look very good if used correctly.

Please be warned though, I’m only going over how to set up the code for Raycast toon-shading. I will happily answer any questions you might have about my settings and/or personal techniques.

Quick side note: toon shading is only available in ray-mmd-1.5.0 and later.

My “Ai Kotoba III” featuring Ray-MMD Toon Shading…

First Step: get Notepad++ to edit text files

You’ll need a source code editor. I recommend Notepad++. It’s free, and works really well. You can get it here:


Configuring the Start

Before you open MMD, you’ll need to open the Raycast configuration file. I’m using the master version of Raycast. Once you go into the ray.conf file, scroll down to where it says “Toon-shading material.” You’ll need to set the value below it to 2.

You’ll also need to scroll down to “Screen Space Subsurface Scattering” and set that value to 0.

You can turn on the outlines, but that’s optional.

Basic Set Up

Now you can open MMD. Go ahead and set up your video or picture.

Don’t set up your lighting just yet, though. You’ll want to do that later.

Once you’ve set up your video/picture, load in a skybox of your choice. I’ve loaded Time of Night.

Now load in ray.x, and apply main.fx to your stage and model. If you’re using time of day or time of night, you’ll have to apply material_skybox.fx to the skybox under the MaterialMap tab manually, same thing with the EnvLight tab. Instead of adding the lighting effect inside the individual folder, add the one titled “skylighting_none.fx” inside the skybox folder. This will get rid of any weird spots on the model. Also be sure to disable MMD’s anti-aliasing, ground shadow, and the coordinate axis.

Editing the Material

At first, things aren’t going to look so great.

(I’ve had to adjust my lighting due to the nature of the stage I’m using, but usually I wait until I’m finished material mapping to adjust the lighting.)

This is where things are going to get a bit more complicated.

Go ahead and open up material_2.0.fx in Notepad++. Scroll down to the CustomA and CustomB slots. Make a copy of the file before you proceed.

Now set the “CUSTOM_ENABLE” value to 8 and copy the following settings:


“#define CUSTOM_A_MAP_FROM 0





#define CUSTOM_A_MAP_FILE “custom.png”

const float customA = 0.62;

const float customAMapLoopNum = 1.0;





#define CUSTOM_B_MAP_FILE “custom.png”

const float3 customB = float3(0.61, 0.55, 0.548);

const float2 customBMapLoopNum = 1.0;”


Save the file, and your screen should look like this:

Congratulations! You’ve officially created a toon shader!

Final Words…

These settings are not set in stone; feel free to experiment! Try playing with different colors, try normal mapping, try all sorts of things! Like I said before, any questions that you have, feel free to ask! I will do my very best to get back to you in a timely manner.

Thanks for reading, and remember to take care of yourself!


TDA Miku by Xoriu

Unknown Mother Goose Motion by ゲッツ

Facials by しのざき

Lip motion by kaz

Hand motion by すぱにぃ

IK motion by kemo

Camera by 鷹羽はるひ

椛暗式-遇见_暮ver1.0 by 椛暗/bananasteamedstuffs

Raycast by rui

Have fun with Ray-MMD and MikuMikuDance!


', enableHover: false, enableTracking: true, buttons: { twitter: {via: ''}}, click: function(api, options){ api.simulateClick(); api.openPopup('twitter'); } }); jQuery('#facebook').sharrre({ share: { facebook: true }, template: '
', enableHover: false, enableTracking: true, buttons:{layout: 'box_count'}, click: function(api, options){ api.simulateClick(); api.openPopup('facebook'); } }); jQuery('#pinterest').sharrre({ share: { pinterest: true }, template: '
', enableHover: false, enableTracking: true, buttons: { pinterest: { description: 'Ray-MMD Toon Shading Basics',media: 'https://learnmmd.com/wp-content/uploads/2020/01/preview-image-copy.jpg' } }, click: function(api, options){ api.simulateClick(); api.openPopup('pinterest'); } }); jQuery('#linkedin').sharrre({ share: { linkedin: true }, template: '
', enableHover: false, enableTracking: true, buttons: { linkedin: { description: 'Ray-MMD Toon Shading Basics',media: 'https://learnmmd.com/wp-content/uploads/2020/01/preview-image-copy.jpg' } }, click: function(api, options){ api.simulateClick(); api.openPopup('linkedin'); } }); });
Notify of
Inline Feedbacks
View all comments
3 months ago

Hey! Thank you so much for this tutorial! Everything worked really well but when I turned the outline on(code: #define OUTLINE_QUALITY 1), it gives me the error “failed to open file ./outline/fixed colour/outline.fx(parameter: OutlineMap). Is there any way I can fix it? Thank you!

Reggie_Dentmore (@reggie_dentmore)
3 months ago
Reply to  Ruki

Sorry… I don’t know the answer… In all of our years, you are the first to mention that issue. … ?
Sorry!– Reggie

3 months ago

Thank you for the reply! It’s a really weird issue :”( But maybe it’s because I’m using Ray 1.5.0? I’ll have to experiment around to see what the issue is.

1 year ago

Hi everybody. Thanks for this tutorial. I have finally read it and I realize this is the legendary technique every super-mmder has been using! You really need to watch this mmd video, it’s also using Toon shader!

1 year ago

the character model became black and everything looks so bright and white

UndeadLuciel (@undead-luciel)
1 year ago
Reply to  non

Make sure to edit the model draw order in the edit tab so that the Skybox is above the model! The order should be Skybox>Stage>Model>ray controller

1 year ago

is there any way to do this but instead of using ray use ik polishader? i’ve seen some motions that don’t hold ray : /

Reggie_Dentmore (@reggie_dentmore)
1 year ago
Reply to  chipa

It’s all up to you. The wonderful thing about MikuMikuDance is that it’s so “personal”… each of us “digs in” in our own way… following our own mind-set. If you’d like to come up with these results by traveling a different route, Go for it! … If something works for you, let us know.
… If you make a discovery you’d like to share with LearnMMD, you can leave a comment, or send me an email: ReggieDentmore@aol.com … or you can join us and become an author on LearnMMD.com and write your OWN articles on LearnMMD: see the link at the foot of this page to sign-up.
— Reggie

1 year ago

hmm i see… i’m gonna try, thank you!

Coon Productions
1 year ago

Oof I know I’m a few months late but I’m using 1.30

Reggie_Dentmore (@reggie_dentmore)
1 year ago
Reply to  MuffinMo

Okay… do we need to amend that tutorial? I can “unpublish” it and set it as a Draft so you can edit it, if you wish to.
— Reggie

Jonah Snyder
1 year ago

Nice! Where can I download the TDA Miku?

Reggie_Dentmore (@reggie_dentmore)
1 year ago
Reply to  Jonah Snyder

That’s part of the game with MMD… you need to get good at searching and finding… Google: download TDA Miku mmd

Coon Productions
1 year ago

I can’t find where it says “Toon shading material”, either I’m using an outdated version or it’s really gone :/

Goose Gas
7 months ago

The person mentioned a master version. IDK what that means…

Exit mobile version