Sharp Sprite - RGSS for Defold

Sharp Sprite is a collection of Defold materials that implements Rotated Grid Super-Sampling (RGSS) for the Defold engine. If you use down-scaled high-resolution images in your game and you want to get rid of blurriness (because of mipmapping) or sharpness (because of disabled mipmapping), then RGSS is for you:

How does it work?

RGSS samples the texture multiple times with an offset on each sample and averages the results. For this, it uses a 4x MSAA rotated grid pattern, sometimes called 4 rooks.

It’s based on an original idea by Ben Golus - Sharper Mipmapping using Shader Based Supersampling.

Pros and Cons

  • RGSS requires the OES_standard_derivatives OpenGL extension to run. It’s universally supported by WebGL 1.0, by the most of OpenGL ES 2.0 devices (Android stats and by all iOS devices).
  • On mobile GPUs, it can have a significant performance impact. You should always check the game performance on your target devices!
  • Sharp Sprite’s implementation of RGSS is blurring at 1:1 scaling.
  • Also, it doesn’t use mipmapped textures. You can turn off the mipmapping in your texture profile and save 30% of disk space.

Online Demo

https://indiesoftby.github.io/defold-sharp-sprite/

Downloads

21 Likes

I have been testing RGSS across all my devices this week and found out that PowerVR-based devices (iPad Air 2, Samsung SmartTVs) output a corrupted image. It turned out that UV coords should have the highp precision in fragment shaders.

PowerVR%20RGSS%20Bug

Fixed in 0.1.1.

9 Likes

There is a question about how the shader works when the sprite turns out to be larger rather than smaller.

Here’s an example:

The current shader causes pixelation (with the sampler Mag filter set to linear).
Is there any way to fix this?

1 Like

Oh. I’m pretty sure that you posted a screenshot where images are upscaled with the “nearest” filter. Could you please check? All Sharp Sprite’s materials have linear filtering enabled.

I noticed that you use it on Spine models, so I made a quick test scene with x5 upscale to check: Dropbox - jXQ5FVG.png - Simplify your life. The image with the RGSS material is the same as the image with built-in material with linear filtering. This is the best quality you can achieve with RGSS.

4 Likes

I purposely wrote that smoothing is linear, as I have checked it several times.
Here are the material settings:

I also checked that if I change the shader to builtins, everything starts working properly. So in my case it’s the shader that affects the smoothing setting.