Monogame 3.5 Stencil buffering.

Hello!

Im having some pixel trouble when using a depth stencil buffer for a mask and a texture when running my 2d game.

The mask stencil is rejecting the pixels outside itself, but the problem is that you can clearly see where its cutting off the pixels, like its not using any anti aliasing.

Code that im using to render mask and texture with.

I wanted to know if theres a way for it to blend out the pixels where it cut or something, im not an expert on this matter.
Please do ask question, it can only help!


Here’s a picture of the problem in action.

If the mask is working as intended, cant you just retouch/edit it to not include those pixels?

Hmm, well that would still show those jagged pixels, im trying to find a solution to blend them better with the environment. Like anti aliasing would do.

oh, I thought you meant those protruding single pixels…

Sorry if I wasn’t clear enough, I just meant those last pixels around the circle, im trying to blend them or something.

Well, I dont know about AA, but making things look like they fit together is the whole trick isnt it :wink:

What are you using the system for? Whats it going to perform in your game?

Yea its a tough one to make it fit :slightly_smiling:

It’s a local arena game and the players can choose different styles for their player (the circle), and I thought it would be a good idea to mask the players original circle and put the style (texture) they want to use on it, so I wouldnt have to hardfix with a circle texture ontop of the normal one.

So just a few sprites then?

Something I’ve done before in these situations, is so super-impose an image layer on top of everything else that inlcudes some shading and rounding out…

That TOP layer is set to match the player in size, so that no matter what ‘texture’ you select for the character, it can have scratches and wounds and decals/numbers on top…

So you get custom skins, with prefab-polish :slight_smile:

1 Like

Very interesting!
Do you some examples or something I can see?
Im having difficulty imagining how I can do this :smiley:

yes
just a sec… I have to post 20 characters… there

But yea it wouldn’t be much of a problem to just make a few sprites that I can switch between when the players are changing skins, the sprites are only 60x60.

Its just typical me to find some fancy pantsy solution to everything and fail :stuck_out_tongue:

Ok, here is the image. The part you want is the zoomed scope… Its not exactly what you need, but I think its the same sort of problem:
Ill post the image, then explan:

So, the scope actually draws a few rectangular segments of the scene, in a cluster that is “roundish”… I cant remember how many, maybe 8 recantngles…

Then, I draw a sprite that is just a ring with a cross and som glass, to cover up the jagged lines around the circle, and PRESTO… Round scope.

This is like replacing player uniforms dynamically, no?

1 Like

Very nice! It looks very cool.
I will try something like that, it sounds like a good solution.

Thanks… Its from grinder, you can find it here on the forum for download… :slightly_smiling:

1 Like

I think its cool. You will never get to practice or invent methods things like that, if you wait for the “big” projects to come along :slight_smile: Dont foreget to post an image under showcase when its playable!

1 Like

Instead of Stencil why don’t you use the DualTextureEffect or something like that to implement a smooth mask?

Will do! And thanks for the quick replies mate.

I will look into that, thanks!