Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Antialiasing not occurring #87

Closed
OctarineSourcerer opened this issue Aug 1, 2016 · 3 comments
Closed

Antialiasing not occurring #87

OctarineSourcerer opened this issue Aug 1, 2016 · 3 comments

Comments

@OctarineSourcerer
Copy link
Contributor

I'm currently having a go at porting my current project to Nez. It's a version of a board game I own which employs the use of cards. Hence, my chosen method of rendering them was in a fan shape - this let me scale it appropriately with the number of cards in the hand and look decent. Pre-Nez, this worked fine.

However, the card fan was one of the first things for me to port, and rendering it did not go so well.
Before | After. The issue is clearer if you look at the text on rotated cards, and it's that no antialiasing seems to have occurred.

I'd like to point out that the actual bug itself isn't specifically part of Nez, but this Monogame issue here here - and the way Nez works means it's far more prevalent.
The issue is that when rendering to a RenderTarget2D, multisampling does not work correctly (on Windows 8+ I believe). Normally, the workaround would be rendering directly to the backbuffer using a SpriteBatch, but as Batcher renders to a RenderTarget2D first, this means that antialiasing just doesn't occur.

Is there anything that would enable antialiasing or the ability to render directly to the backbuffer without violating the concepts behind SceneResolutionPolicies?

@prime31
Copy link
Owner

prime31 commented Aug 1, 2016

The first thing I would do is make sure you set Core.defaultSamplerState. By default it is SamplerState.PointClamp and you probably want linear for that kind of artwork.

If that doesn't produce sufficient results you've got 2 more options:

  1. make an antialiasing shader and stick it in a PostProcessor: scene.addPosProcessor( new PostProcessor( 0, yourAntiAliasingEffect ) )
  2. strip the RenderTarget usage from the Scene class and let it write straight to the back buffer. Doing that will end up making post processing impossible due to the RenderTarget being required. This method will require doing a few modifications to the base Scene class to get rid of the RenderTarget usage. Start with this change and it should get you pretty close:
  • comment out calls to updateResolutionScaler() (that is where the RenderTargets are created).

There might be a couple other minor changes required but that change will keep the _sceneRenderTarget from being created and null. graphicsDevice.setRenderTarget will then always be called with null and render to the back buffer.

@prime31 prime31 closed this as completed Aug 1, 2016
@OctarineSourcerer
Copy link
Contributor Author

Ah - thank you very much, setting Core.defaultSamplerState worked! I wasn't aware of sampler states, and I would have gone with the first option otherwise, there's another shader or two I use elsewhere.

Nez is awesome though, thanks for putting the time and effort into it, and supporting it too.

@prime31
Copy link
Owner

prime31 commented Aug 1, 2016

Glad to hear you are liking Nez!

Related: I just moved the sampler state details from the Wiki into the FAQs so it is clear that you can set them globally: 4ef1ebc

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants