[ALTERNATE SOLVED] How can I do override SpriteBatch class?

#Problem

In previous thread, I asked can possible floating position, size, etc in SpriteBatch class.

So I tried override SpriteBatch class, but it’s can’t possible because the class was not available due to the level of protection.

If there is no way for this, can I find some example or guide for making spriteBatch system?

#Way I want do this…

Cause I want do make smooter visual for vector-like graphics.


This video is testing my ‘SVG files to MSDF texture atlas’ tool.
I tried use this to my MonoGame project but SpriteBatch make some pixel spaces. so sad…

How I can do achieve this?


Wait, what is MSDF?

MSDF(Multi-channel Signed Distance Field) is one of the techniques for expressing vivid shapes.
Primarily exert great power in the font.


MSDF on MonoGame

MSDF on Unity

1) You may simply not have your renderstates set up to act as you think.
Try setting
GraphicsDevice.SamplerState[0] = SamplerState.PointClamp;

Be aware of what antialiasing does?

There are two main categories of texture filtering, magnification filtering and minification filtering.
Texture filtering - Wikipedia

2) You are mis-understanding some vital things.
When you make a point to say…

it’s impossible because spritebatch is only casting integer values.

Your physical screen is made up of discret pixels (physical integer amounts).
The monitor itself has a physical resolution of pixels in integer values.

3) To say that you want to make

real smoother position scale.

What does this mean if you are rendering at the maximum resolution on a 1 to 1 scale ?
What does it mean to say you want to render at .33 of a pixel or 1.33 then when each rectangle integer position is equal to a physical screen position. Do you know what this will mean in terms of your current filter settings and resolution ?

4) SpriteBatch cannot simply be overriden.

You can download monogame alter it and build it yourself from source but i don’t think you realize that any alterations you make to it will be futile.

If you are determined to build your own and need proof of the above. You can take a look at a couple of my old experimental test projects that basically do the things spritebatch does.

These are neither made as tutorials or for use in a real game or app they were simply tests and they have multiple tests and versions in the same project so you will have to follow the flow from program thru execution as each project also has multiple game1 classes basically.

1 Like

Amm, maybe this thread article is what I want.
How make it to possible?
This is really I want to do.
gif

I’m still reading the code now, and that’s probably what I was looking for.
I think I should continue studying about this part, thanks!

Or Not…

Turns out there is a very good reason to not allow for vertice corners of quads to be non rectangular.

Take a look at the links i posted both do exactly the above, one project focuses on text, the other on batching regular quads.

Thanks for your advice, willmotill, I’m checking both now :blush:
It’s so interesting cause I never seen before.

Drawing quads as sprites with effects is simple.
You can draw quads with basic effect as well.
Batching and drawString are bit more complicated though.

You can actually get close to the effect he shows there by simply turning on ansiostropic filtering but i was under the impression you wanted crisp output in that case you want PointClamp for the sampler state.

1 Like