- Home /
Unity2D: Stretching Where Alpha Should Be
I'm working on this game in 2D where everything you see I drew in ballpoint pen. I photographed the results and cleaned it up in Photoshop so that some bits are transparent. That's all fine and dandy when using the Sprites-Default shader which looks like this:
It works but I wanted to make use of real-time lighting on some assets to help give it a little extra depth. I switched the material to the Default-Diffuse shader and ended up with this problem:
Everything looked great but then I noticed all of the stretching between the wood and curtains.
I'm thinking to just make the curtains separate in Photoshop and place them on back on top of the wood in Unity so that they appear seamless. Problem is, I'm worried that this could get very tedious if I were to make something that is much more complex. Is there a better way?
Answer by Paulius-Liekis · Jul 22, 2015 at 11:33 AM
This looks like filling of transparent areas of texture (i.e. areas with alpha=0). Unity does that to get better mipmaps, i.e. to avoid black lines on edges on lower mipmaps.
Your problem is that these pixels area showing for some reason. Did you change shader or something like that? Did you use Phong shader, in which case alpha is interpreted as reflectiveness of the surface instead of alpha?
The surrounding area is nothing but alpha and works just fine. That's sort of why I'm confused. I did scale it down within Unity but the problem persists with the larger version too.
I did indeed change the shader from Sprites-Default to Default-Diffuse where the former worked just fine but the latter stretched the inner alpha bits.
This is how it looks within Photoshop so that you can see which parts have alpha and which don't:
It sounds to me that Sprites-Default has transparency, and Default-Diffuse does not. What kind of color do you expect transparent pixel to be? It's kinda undefined...
$$anonymous$$aybe you could try fixing your issue by changing import settings, maybe one of the import settings doesn't affect transparent pixels.