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.
The second solution, that included in this repo, uses mip biasing. Mip biasing tells the GPU to adjust what mip level to use. The shaders use mip bias of -1.0 that pushes the mip level one full mip back to make 2D sprites look much sharper. It’s almost as fast as the standard materials. Use this first. If it fits your project well, keep it and don’t try RGSS at all.
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.
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. 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.
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.
I have a similar problem on Switch. I don’t know if this is related but I ended duplicating all builtin’s. Note that some builtin materials have NOT the texture_sampler at all. Maybe the default value for the filter of a non-declared texture_sampler is a bit random? Or maybe I missed completely the point of your problem
Are your atlases 4K in size or more? Do you have fixes from this commit? I noticed that you have custom shaders for RGSS, i.e. not from the sharp_sprite directory.
I’m still looking into this issue, but I can’t reproduce it on my devices.
The new version of Sharp Sprite 0.2.0 has been released! I added new materials and reworked the demo. New materials use mip biasing to increase the performance of RGSS and not only for that. Mip biasing tells the GPU to adjust what mip level to use. The shaders use mip bias of -1.0 that pushes the mip level one full mip back to make 2D sprites look much sharper.
Now Sharp Sprite contains three sets of materials that are drop-in replacements for the standard 2D materials:
Mipmap Bias -1.0 (/sharp_sprite/mipmap_bias/): almost as fast as the standard materials. Use this first. If it fits your project well, keep it and don’t try RGSS at all.
RGSS (/sharp_sprite/rgss/): slow, and requires OES_standard_derivatives (see docs), and doesn’t require mipmaps.
RGSS Mipmap Bias -1.0 (/sharp_sprite/rgss_bias/): a bit faster than RGSS, and requires mipmaps.
BREAKING CHANGE: previous materials moved into the subdirectory /rgss/.