Jitter-free Pixel Art Scaling in MonoGame

Поділитися
Вставка
  • Опубліковано 10 лют 2025
  • This video is in response to a question asked by a user in the MonoGame subreddit. They were looking for a way to do the Jitter-free pixel art scaling in GoDot from the video by ‪@uheartbeast‬ at • Jitter-free Pixel Art ... but in MonoGame.
    So here is the video showing it working in MonoGame while I ramble on about it, as I tend to do.
    You can find the source in the GitHub repo at github.com/Ari...

КОМЕНТАРІ • 11

  • @Drenzor
    @Drenzor Рік тому +5

    Hey, OP here :) Did everything step by step as you mentioned in the video. It works like a charm, thank you so so much!

  • @guipazs
    @guipazs Рік тому +2

    That's great! I've been trying to use shaders in Monogame for the first time and this is concisely enough for me to take as reference. Thank you!

    • @aristurtledev
      @aristurtledev  Рік тому +1

      Awesome, glad I could be of help. If you have any questions, remember MonoGame has a discord if you use that (discord.gg/monogame) or you can always ask on the community forums (community.monogame.net)

  • @diligencehumility6971
    @diligencehumility6971 Рік тому +1

    I tried to add this shader to my project, but found I already use a BasicEffect for projection and view matrix. Can I somehow add two different effects?

    • @aristurtledev
      @aristurtledev  Рік тому +2

      When using the SpriteBatch, you can only apply a single effect to a batched call.
      If you want to apply both the BasicEffect and this effect you have a couple of options.
      1. You could render to a RenderTarget2D in one batch using the BasicEffect, then render the RenderTarget2D to the backbuffer using the effect from this video
      or
      2. You can create a new effect that combines the BasicEffect and the code from this effect. You can find the BasicEffect in the MonoGame GitHub repo. Doing this, you would need to make use of applying multiple passes in the shader, one to go through the passes for the original BasicEffect part and a final pass for the jitter free shader part.
      Of the two, the first one is probably the simplest to implement. There may be other ways of achieving this, but these are the only two I can think of off the top of my head at the moment.

    • @diligencehumility6971
      @diligencehumility6971 Рік тому

      @@aristurtledev Thanks for answer!!

  • @diligencehumility6971
    @diligencehumility6971 Рік тому +2

    I noticed you don't use PointClamp when using the shader? Does the shader replace the need for point clamping?

    • @aristurtledev
      @aristurtledev  Рік тому +2

      Sorry, I forgot to include this in the video.
      In the original video that this was translated from, they mention in Godot that you have to turn filtering off. In MonoGame, this is essentially the same as not using SamplerState.PointClamp and the shader acts as a replacement. If you use this in combination with SamplerState.PointClamp, then the result will not work.

    • @diligencehumility6971
      @diligencehumility6971 Рік тому

      @@aristurtledev Cool thanks!

  • @Equisdeification
    @Equisdeification Рік тому +2

    Very cool! Funny enough I was thinking these days about using this system (I made a port of this shader for Unity) in MonoGame!
    Can this be used for every texture using a RenderTarget2D?

    • @aristurtledev
      @aristurtledev  Рік тому +1

      It can be used for any Texture2D that you apply effects to. RenderTarget2D inherits from Texture2D, so yea, you can apply it to that as well.