Hot reloading of shader files

Does anybody know of a sample somewhere for shader hot reloading with MonoGame 3.8? If not what are the steps to do the content building of shader files? Start a process with the mgcb command line tool? The rest is just watching the files for changes I guess and then swapping out the shaders with the newer ones after they got built. Not sure how to handle that step with swapping out but maybe someone can describe how this could work?
Not sure I need it but if it is easy enough it could help a lot because I am playing around with shaders most of the time and so hot reloading would be really cool to have to quickly find a good set of parameters etc.

I didn’t try it as I have my own, but my own works directly with SharpDX.

1 Like

I think this will work. At least I got it to some point where I think it compiled the shader and I did not get an error through the stdOut. But for some reason the changed shader is not active. So something there is still not working.

When I have more time I can write more details.

Some notes:

I found the mgcb.exe on my machine at:


Passing this as Arguments:

Arguments = "/platform:Windows /config: /profile:Reach /compress:False /importer:EffectImporter /processor:EffectProcessor /processorParam:DebugMode=Auto /build:"+name+".fx",

For HiDef profile I would try (UNTESTED):

Arguments = "/platform:Windows /config: /profile:HiDef /compress:False /importer:EffectImporter /processor:EffectProcessor /processorParam:DebugMode=Auto /build:"+name+".fx",

For DesktopGL it would be:

Arguments = "/platform:DesktopGL /config: /profile:Reach /compress:False /importer:EffectImporter /processor:EffectProcessor /processorParam:DebugMode=Auto /build:"+name+".fx",

Maybe I can try to copy the created XNBs over and load them from another project and verify if they work as expected. If yes then I guess (if the file copy works from the intermediate dir to the final Content dir) I need to check if the loading fails or the swap?! Or everything works and I am just using an old reference or something…

1 Like