1
\$\begingroup\$

I made 3 models, each has own material. And after texture painting, I combined each their texture to single textures for optimization.

Currently making Mobile Game with Unity 2018 and using Mobile/BumpedSpecular shader for rendering, which is actually simplified BlinnPhong lighting model.

However after checking the result, I get weird result in some spots with Diffuse texture.

enter image description here

Note that Mobile/BumpedSpecular shader in Unity uses alpha channel of diffuse texture as glossiness. So after I combined those three different diffuse textures, I exported with no background(transparent background) like this:

enter image description here

UV mapped correctly, diffuse texture has alpha, importing alpha channel as well.

enter image description here

Everything seems fine, but why do I have this wrong result? First time I thought that I did something mistake, so I repeated whole process again, but still have same result, not this one, with other models also. So I thought that it was bug from Unity, actually but it wasn't, I tried with Blender and have same result.

So one thing I can know that there might be something missed in my integrated diffuse/glossiness texture. What am I missing?

\$\endgroup\$
  • \$\begingroup\$ Those stretches looks like what some image editing applications will do when compressing png. Do you have areas with zero alpha (completely transparent)? Have you tried exporting your texture with a solid background, to see if the artifacts come from the alpha channel? \$\endgroup\$ – Morten Andersen Jul 14 '18 at 9:09
  • \$\begingroup\$ @MortenAndersen I just tried with adding white background, now texture seems fine. Looks like it's coming from alpha channel. Yes, background is completely transparent. \$\endgroup\$ – modernator Jul 14 '18 at 11:39
1
\$\begingroup\$

DMGregory's suggestion to use a different format is simple and straight forward. So perhaps try that first and see if it solves your issue.

However, if you for some reason want to keep using PNG, you can try disable compression or use a plugin like SuperPNG for Photoshop - I can't tell if you're using Photoshop, but it looks like an older version.

Reasons for sticking with PNG can be compatibility with other tools in your pipeline, where formats like TIFF and TGA can sometimes lead to different results depending on the application.

If you're comfortable with command-line tools, ImageMagick may also be an option to convert your file to a PNG.

\$\endgroup\$
  • \$\begingroup\$ Thank you, I just installed ImageMagick and using command line to solve the problem. I'll leave the command what I typed for people who want to know: "magick convert diffuse.psd -background none -flatten out.png". Tested in Windows 10 Command Prompt. \$\endgroup\$ – modernator Jul 14 '18 at 13:27
  • \$\begingroup\$ Hey, today I realized that using that command line has wrong result. Those stretch is gone but total color is looks different than original. Might be wrong with parameters when using ImageMagick CLI, however I just tried with SuperPNG plugin and now I have perfect image. Thank you. \$\endgroup\$ – modernator Jul 15 '18 at 8:20
  • \$\begingroup\$ Glad you figured it out. I don't know why IM gave strange results. Perhaps due to color profile, blending or something. But yeah, SuperPNG is a great little plugin to have. \$\endgroup\$ – Morten Andersen Jul 15 '18 at 15:32
1
\$\begingroup\$

This often happens when saving in PNG format. As Morten Andersen points out, those streaky stripes are a telltale sign of PNG compression in zero-alpha areas.

The reason is that PNG exporters assume that the alpha channel is transparency, and thus zero-alpha regions will be completely invisible. So, they figure they're free to do whatever weird stuff they want with the colours in those regions in order to get better compression ratios - like extruding stripes of the same colour so adjacent pixels are really easy to predict.

To avoid this, you can save your source assets in a format that does not assume that an alpha channel with a value of zero will be invisible, like TGA "Targa" or PSD itself. Rather than storing the alpha in the transparency of each layer, you'd go into your channels window in Photoshop and paste your gloss map on a new alpha channel.

(This same reason is why Unity has that "alpha is transparency" checkbox on its importer, so it knows how to interpret zero-alpha regions)

These formats tend to be bigger on disc than png, but ultimately your assets get baked to GPU-friendly formats when you build your game anyway, so it shouldn't impact your published game's size or memory footprint.

\$\endgroup\$
  • \$\begingroup\$ Thanks, but I just tried both TGA and PSD, each makes new problems. First using PSD directly changes black area to just "white". With TGA format, all textures almost white colors, it's even worse. \$\endgroup\$ – modernator Jul 14 '18 at 12:45
  • 1
    \$\begingroup\$ It sounds like you forgot to make your colour layers opaque, and store your alpha in a separate alpha channel rather than as layer transparency, as described above. \$\endgroup\$ – DMGregory Jul 14 '18 at 12:47
  • \$\begingroup\$ Sorry, I didn't understand what you suggested. First, makes my diffuse/gloss texture opaque is too ambiguous, which color should I use as background? Black or White? Second, I can't found any feature to "seperate alpha channel" from imported diffuse/glossiness texture. Yes, I'm not good at photoshop, however I can't find any related searching on Google(Maybe I don't know what feature exactly should find). Could you give me some hint or keywords that I can find any related articles? (For now, solved with ImageMagick anyway) \$\endgroup\$ – modernator Jul 14 '18 at 13:26
  • 1
    \$\begingroup\$ You don't want either a black or a white background, because the information you currently have stored as transparency is meant to be gloss, not translucent colour blending with a background. You can clone the layer, lock transparency, paint it white, and paste the result onto a black alpha channel to extract this alpha to its own separate map. Then go back to your original colour layer and duplicate/merge the layer repeatedly to bring it back up to full opacity. Plugins like Filter Factory will let you restore the opacity more directly. \$\endgroup\$ – DMGregory Jul 14 '18 at 13:40
  • \$\begingroup\$ I just cloned layers, locked transparency and paint it white. But how do I pasted these into black alpha channel? \$\endgroup\$ – modernator Jul 15 '18 at 8:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.