• Unity
  • Downscaling / zooming out without pixelation

  • Modifié
Related Discussions
...

Not sure if the solution to this will be technical or creative, any advice appreciated: I have a very high resolution character (about 600px tall), but in game I am zooming out quite far, so sometimes the character is downscaled to as little as 25% of original size. With mipmapping turned off, this leads to a sparkly/pixelated end result - with mipmapping on, the sprite looks blurry / low resolution. The best solution I have found so far is to half the resolution of the atlas in the unity inspector - but this means I no longer have the full resolution when I zoom in. The ideal solution would seem to be to swap between a high and low resolution atlas as the camera zooms - but I can't see a way to override the material or texture that each skeleton/animation uses.

thanks for your time

This is a texture filter thing that's handled on the Unity side that affects all renderers. This is not a Spine issue so consider this a bonus. And because it's not a Spine issue, you probably want to do this for all your stuff.

Add a Unity Quad to a scene
Drag your (Spine) Material onto it.
Adjust its dimensions so it's not warped.
Select the material's texture in Project view so you can see its Texture Import inspector.
Adjust the Anisotropic Filtering level (Aniso Level) slider until you get a result that you like. Lowering it usually gets rid of the overly sharp/pixelly look when zoomed out. Don't forget that you need to click Apply to see changes.

Hi Pharan - thanks for your reply, but no setting for Ansio level has a significant effect. I've attached my atlas if you want to try it for yourself. I'm aware this is a standard Unity issue rather than something specific to Spine - which is why I'm interested to know if there is a way to override the texture at runtime, to one that has been scaled down or manually blurred.

Ah, to override the texture, you have to do it through code.

If you're only using one texture, you can use MaterialPropertyBlock and Renderer.SetPropertyBlock

Texture texture = TheTextureYouWant;
var meshRenderer = GetComponent<MeshRenderer>();
MaterialPropertyBlock mpb = new MaterialPropertyBlock(); // cache this object somewhere. It's a reference type and it will alloc.
mpg.SetTexture("_MainTex", texture);
meshRenderer.SetPropertyBlock(mpb);

If you have to use more than one, you have to pass through SkeletonRenderer's override dictionary and create a new material object per instance.

SkeletonAnimation skeletonAnimation = GetComponent<Spine.Unity.SkeletonAnimation>();
skeletonAnimation.CustomMaterialOverride.Add(originalMaterial, replacementMaterial); // Do this for each material you need to substitute.

thanks a lot - i will try this


18 Nov 2016 10:53 am


worked perfectly, thanks