assuming I want my game to have a Cel-shaded look. There are plenty of tutorials how to implement Cel-shading in hlsl f.e. But what is the point? If I am creating my assets with Blender or 3d-max I have a lot of possibilities to add materials and shaders in the modeling software.

So why write shaders?

  • \$\begingroup\$ Less work in Blender? \$\endgroup\$
    – Zolomon
    Commented Jan 7, 2012 at 11:57
  • 4
    \$\begingroup\$ Because you probably can't use those materials in a game? Even if you could, those materials are designed for batch rendering and not real-time. \$\endgroup\$ Commented Jan 7, 2012 at 12:09
  • \$\begingroup\$ So whats the point of adding materials to formats like .x or .fbx then? They are mostly used in games? Aren't they? \$\endgroup\$ Commented Jan 7, 2012 at 12:22
  • 4
    \$\begingroup\$ @bodycountPP No they usually aren't. The materials will most like just contain information about the diffuse color, specularity, ambient factor and probably the used texture. They won't generate shader code that you can directly use in game (which would be required for toon shading). \$\endgroup\$
    – bummzack
    Commented Jan 7, 2012 at 13:13
  • 2
    \$\begingroup\$ Is this actually a problem you're facing, as per gamedev.stackexchange.com/faq#dontask? It kind of sounds like you're going on a fishing expedition, here, and have made no attempt to actually do anything related to this question. \$\endgroup\$ Commented Jan 8, 2012 at 1:08

3 Answers 3


First, ok-to-good question. Definitely not a bad question. To answer it, you just have to know what a shader is and why you need one.

A shader is exactly what it sounds like - it "shades" vertices and pixels different colors. "Shading" isn't just "making it darker" (as the technical artistic term means I believe), it's application of textures, lighting, and everything else that gives a vertex it's final color.

"Shading" often makes the most sense if you think about some light source. You can't really have toon shading without a light source. You have to have light (and an angle to the light) to know how to shade an object in that light. And that's the job of the shader.

So, now you have a vertex/pixel shader that will do toon shading in Blender. Great. Why do you need to know HLSL if you can make a toon shader in Blender?

If Blender exports HLSL code that you can plug into XNA, then you don't need to write the HLSL yourself. You are correct. You wouldn't need to hear about, see, or touch HLSL code if Blender exports it for you. But I'm not sure if Blender can do that.

So if Blender does not HLSL shading code, then you need to write a toon shader in HLSL because all you'd get is the model and vertices and their respective solid colors, but you wouldn't get "how it should look at every single angle and under every possible light source" right - that needs to be computed at runtime (by a shader).

  • \$\begingroup\$ +1 this is a good "introduction to shaders and why we care" answer \$\endgroup\$
    – ashes999
    Commented Dec 21, 2012 at 18:03

Materials made for a 3D modeling program won't translate directly into the materials used in your game. You would have to construct a content pipeline for your Blender or 3DS assets, or use one that's pre-made, and then you have to tell the hardware how to use the data extracted in these assets to display the graphics. That is what shaders are responsible for. Your program cannot guess exactly how these files are supposed to be used.

Shaders are especially useful in applying screen-space effects, which do not take in regard the geometry in the scene, at least not discreetly. Even if you use BasicEffect in XNA, you are using some sort of shader, just a pre-built one.

Unlike DirectX 9, XNA does not have a fixed function pipeline. So even diffuse texturing is a very simple use of a shader. There are ways to minimize shader use, by using the 3D modeling software to bake the effects to your models as textures, such as ambient occlusion. But these tricks do not work well for dynamic scenes.


Shaders are not only used to draw textures and effects on an object, would you for example be able to create a motion blur without shaders? Besides, most materials in 3DS max have shaders underneath to create the texture with its effect.

  • 1
    \$\begingroup\$ "most materials in 3DS max have shaders underneath" ...what? \$\endgroup\$
    – jhocking
    Commented Jan 8, 2012 at 0:11
  • \$\begingroup\$ try searching your 3ds max 2011 install folder for .fx files, you will find a lot of them \$\endgroup\$
    – Thomas
    Commented Jan 8, 2012 at 10:59

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .