I’m playing with Post Processing in MonoGame, my first tests with the OpenGL port are sweet but when I switch to Windows DX I get an empty screen with a light blue color…
This is my code
private void renderBuffers()
if (_e == null)
_e = Application.Content.Load<Effect>("FX/PostProcess/Blur");
_spriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone, _e);
_spriteBatch.Draw(_sceneRT, Vector2.Zero, Color.White);
_e.Parameters["blurDistance"].SetValue(Input.Mouse.Drag() ? Input.Mouse.Delta.X * 0.001f : 0);
As I said, it works with OpenGL port and I’ve aven’t errors in the Visual Studio’s console.
How can I debug it and eventually report a problem ?
My guess is the signature of the pixel shader. Under DX11 the inputs to the pixel shader need to be exactly the same as the outputs of the vertex shader.
You can see the inputs that SpriteEffect.fx expects in the HLSL source:
Best way to debug DirectX is to use the built in graphics debugger in VS2012/2013:
You can capture a frame and step thru and see what the GPU is getting and figure out what is not being set.
Note you need to enable “Native code debugging” in the game project debug settings for this to work.
Thanks again for your reply. My code hasn’t vertex shader function, it has only a pixel shader function, you can take a look at my (really simple) blur effect here.
I read tutorials and they do like this, without VS function (I know that it’s maybe bad tutorials). But I just found a nice article about SpriteBatch effect here. If I’ve correctly understand, I can solve my problem by creating a VS function with correct inputs right ? I’ll test that tomorrow.
Sure… that is a common technique. When you do that with SpriteBatch it is using the vertex shader from the default SpriteEffect.fx file.
You still have to match the function signature it expects.
You could… but it isn’t necessary. Simply change you pixel shader to this:
float4 position : SV_Position,
float4 color : COLOR0,
float2 textureCoord : TEXCOORD0):COLOR
That will fix your issue.
This is a new requirement for DirectX11… XNA4 didn’t have this requirement because it was using DirectX9.
Thanks it’s works !
I need to update my tutorial with that now
All my effects works as expected now.