Monogame content builder fails to build valid shader

When building this shader effect below, the monogame content builder throws some errors.

Here are the shader files. SMAA_LOW is the actual shader added to the content builder, it builds perfectly in normal XNA.

SMAA.h : freetexthost.in
SMAA.fxh : freetexthost.in
SMAA_LOW.fx : freetexthost.in

This is the error I get.

ERROR LOG > D:/Desktop/2.0 Projects/Games/Block Games/Craft World/Source Content/Shaders/SMAA_LOW.fx

D:/Desktop/2.0 Projects/Games/Block Games/Craft World/Source Content/Shaders/SMAA_LOW.fx: D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(207,66) : Unexpected token β€˜c’ found. Expected CloseParenthesis
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(207,66) : Unexpected token β€˜c’ found. Expected CloseBracket
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(207,66) : Unexpected token β€˜c’ found. Expected CloseBracket
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(228,67) : Unexpected token β€˜c’ found. Expected CloseParenthesis
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(228,67) : Unexpected token β€˜c’ found. Expected CloseBracket
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(228,67) : Unexpected token β€˜c’ found. Expected CloseBracket
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(253,67) : Unexpected token β€˜d’ found. Expected CloseParenthesis
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(253,67) : Unexpected token β€˜d’ found. Expected CloseBracket
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(253,67) : Unexpected token β€˜d’ found. Expected CloseBracket
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(278,74) : Unexpected token β€˜e’ found. Expected CloseParenthesis
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(278,74) : Unexpected token β€˜e’ found. Expected CloseBracket
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(278,74) : Unexpected token β€˜e’ found. Expected CloseBracket
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(304,69) : Unexpected token β€˜c’ found. Expected CloseParenthesis
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(304,69) : Unexpected token β€˜c’ found. Expected CloseBracket
D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.fxh(304,69) : Unexpected token β€˜c’ found. Expected CloseBracket

Please help if you can :smile:

This

PixelShader = compile ps_3_0 DX9_SMAALumaEdgeDetectionPS(colorTexG);

does not work in MonoGame. You can’t pass parameters to the function. This needs to be:

PixelShader = compile ps_3_0 DX9_SMAALumaEdgeDetectionPS();

(Also, you need to ignore the error line/column numbers. Those are wrong since MonoGame switched to CppNet for preprocessing. :frowning: )

1 Like

We need to address this soon… the guy that implement CppNet support dropped the ball on that. Nothing I hate more than incorrect line numbers in error messages.

1 Like

FYI. I put up a new issue in particular for the line number problem.

1 Like

Is there any place where all the shader differences are documented?

I didn’t realise the error messages were on the wrong line numbers, that was one of the reasons I gave up trying to fix it. The errors made no sense to me.

And thanks mgarstenauer for the help.

Also I have made it much further with my shader conversion for monogame, but have hit another stumbling block. I now get this error (which seems to refer to a correct line)

: D:\Desktop\2.0 Projects\Games\Block Games\Craft World\Source Content\Shaders\SMAA.h(1102,9): error X3528: can’t use flow control on this profile

I am trying to compile the pixelshader using ps_4_0_level_9_3.

If I cannot get this working I might have to move from SMAA to FXAA which looks a little simpler to migrate to monogame. Anyone know of any post process AA methods that are already monogame compatible?

Thanks again for all your help.

There is SMAA for XNA, which works but it is slightly more inefficient than normal version of SMAA because XNA stencils limitations. If you are alright with it then https://github.com/iryoku/smaa FXAA is, as you said, simply to migrate to monogame and 3.11 works without issues.