[Solved] 3D model rendering with Artifacts in Monogame


I have successfully converted LightPrespass XNA code to Mono for my future project.

I have got an issue like thin outline is being drawn with artifacts in all the models.

Please advice me on this issue.


Looks like anti-alias and sampler interpolation issues. The same code works correctly in XNA?

Yeah…It works perfectly in XNA. Is there any solution for this issue?

I’ve never seen this before :confused:

Is your GraphicsProfile set to HiDef? If you can make a minimal sample that shows the issue then I can take a look at it.

Thanks for the reply!

Yes My grapicProfile is HiDef.

What is minimal sample? Please tell me more haw to reproduce it…


I mean a project that just draws 1 or 2 models to the screen and has this issue. But if you don’t mind sharing the project that rendered the screenshot you posted, that’s fine too. It might be hard to get a simple project that shows the issue since we don’t know what is causing it…

Here it is,

I have drawn only one model, still anti-aliasing issue persist.

Is it because of my shader code?


Can you try rendering with the built in effect BasicEffect? If that works the problem is in your shader. Still, if this works in XNA it should work in MonoGame too

Thanks, I will do that and let you know.

But meanwhile I tried one more thing that I have changed my graphics resolution from 1280x720 to 1920x1080. After that the anti-aliasing seems to be reduced but not completely gone…

Do you render to the backbuffer directly or do you render to a rendertarget first? I just remembered there is an anti-aliasing issue when rendering to render targets

I render to RenderTarget first render all my postprocessing quads in it and then finally render the RenderTarget to BackBuffer.

Remove all half-pixel offsets (LightBufferPixelSize and GBufferPixelSize I think) from all shaders. They were needed when developing 3D apps under DX9 and MonoGame uses DX11 so they are obsolete now. :slightly_smiling:
In my case that was producing those ugly aliasing artifacts when sampling the light buffer.

@Sizaar Thanks :slightly_smiling:

That is what I doubted too.

Please help me how to remove from my shader…

Do you want me remove 0.5f from this code?

float2 TempBufferRes;
VertexShaderOutput VertexShaderBlur(VertexShaderInput input)
    VertexShaderOutput output = (VertexShaderOutput)0;
	output.Position = input.Position;
	output.TexCoord.xy = input.TexCoord + GBufferPixelSize;
	output.TexCoord.zw = input.TexCoord + 0.5f / TempBufferRes;
	return output;

Try removing all “GBufferPixelSize” fields from your shaders, and “LightBufferPixelSize” from LPPMainEffect. :slightly_smiling: After this remove all “0.5f / SomeResolution” because it’s obsolete now.

Thanks :slight_smile:

Its compiling now… hopefully it works… excited to see output…:slight_smile:

@Sizaar Thanks a lot!!

That ugly white line is gone now :slight_smile:

I hope you come across with LightPrePass sample.

That is what I am trying to convert, Now things are almost done, directional light is rendering properly,
but point light and Spot lights are not rendering…

Please help me if have faced any problem on this, however thanks a lot help me to fix this anti-alias issue.:slight_smile:

No problem :wink:.
Try swapping winding order on your light volume meshes, that should work for the lights. :slightly_smiling:

Now I am able to see all the lights, but point lights are only visible from only certain distance.

Why is it so? and tell me how to swap winding order…


Open your light volume models with VisualStudio model editor.
Then there’s a parchment icon at the end of the toolbar, click it and then in “Tools” there’s “Flip Polygon winding”, click it. That should work on your lights. :slightly_smiling:

Yeah… it is working nicely Thanks a lot… :slight_smile: but one final issue… When I move my camera some lights are rendering and some lights are not… why?

Do I need to remove this 0.5f; +float2(0.5f, 0.5f) also from all the shaders?

VertexShaderOutput VertexShaderFunction(VertexShaderInput input)
    VertexShaderOutput output = (VertexShaderOutput)0;
	output.Position = input.Position;
	output.TexCoord = input.Position.xy *0.5f; +float2(0.5f, 0.5f);
	output.TexCoord.y = 1 - output.TexCoord.y;	
	//output.TexCoord += GBufferPixelSize;

	return output;

Please help me, its almost done one final step…