How to Build HLSL Shaders for Maya: The Compilation Guide

When using HLSL shaders in Maya, compiling shader files speeds up the loading process. This article explains how to do that.


You can use DirectX11 (HLSL) shaders in Autodesk Maya and Autodesk 3DSMax. When doing so, you can choose to either use text files or precompiled binaries for your shader files. Using precompiled binaries is overwhelmingly advantageous in terms of loading speed. However, there is little information available on how to compile these binaries; only sample files exist.

So, this article aims to document the steps for compiling shader files. An introduction to HLSL will not be covered here; please consult another article (other articles when I feel like writing them) or resources for that information. Note that the information provided here pertains to the Windows environment.


The environment in which testing was conducted is as follows, as of the time of writing:

  • Windows10
  • Maya 2020 - 2023
  • Direct3D Shader Compiler 10.1


First, prepare the necessary compiler, which is fxc.exe. It's not available as a standalone package, so you will need to install it by some means. If you're already using Visual Studio or Build Tools, it should be installed along with the Windows SDK. Search for fxc.exe under C:\Program Files (x86)\Windows Kits\10\bin\. If it doesn't exist, explicitly specify the SDK during Build Tools setup for installation.


Command Example

fxc.exe effect.fx /Fo effect.fxo /I .\ /T fx_5_0 /Gec /D _MAYA_=1

Command Explanation

fxc.exe {Input File Path} /Fo {Output File Path} /I {Include Folder} /T {Shader Profile} /Gec /D {Preprocessor Macro}
  • Input File Path: The path of the file you wish to compile.
  • Output File Path: The path for the output file.
  • Include Folder: The base folder for #include. Specify multiple if needed. By default, the compiler will not look in any folder (not even the current folder), so specify it explicitly, e.g., /I .\ to include the current folder.
  • Shader Profile: Specifies what you are compiling. Since it's an effect file for Direct3D 11, use fx_5_0.
  • Preprocessor Macro: To compile externally for Maya, define _MAYA_. This can also be used to prepare shader variants.

For other options not discussed here, refer to fxc.exe /? for command help or check the reference links.


  • Although fx_5_0 is not listed in fxc's /T option help, it actually works.
  • What "effect" refers to in DirectX may not align with its general meaning.