Search code examples
.netwpfpixel-shader

How to compile shader fx-file for use in WPF?


I have a Shader.fx-file and want to compile it into a Shader.ps-file that can be used as input to a ShaderEffect in WPF.

I'm using the compiler in Windows 10 SDK (fxc.exe) like this:

fxc /O0 /Fc /Zi /T  fx_5_0 /Fo Shader.ps Shader.fx

This works fine but when loading it in WPF I get an exception:

Shader bytecode must be an integral number of 4-byte words.

Any idea how to solve this? How do I get it to the correct size?


Solution

  • The problem was this:

    /T fx_5_0
    

    Should be:

    /T ps_2_0