0
$\begingroup$

In my sprite UV i set it some UV to transparent in my pixel editor. These pixels appear black in the viewport.

When I search about it I found various answers but for old blender versions, and the menus aren't the same at all now.

view capture

$\endgroup$
  • $\begingroup$ You have an alpha (transparency-opacity) channel coming out of your PNG, but it isn't being used, and your Color is directed through a Toon BSDF, which I believe doesn't pass forward transparency information. Try adding a second, Transparent BSDF shader, and then mixing it with your Toon BSDF, using your Alpha channel from your PNG as the mix factor. Also, be sure that your material's Blend Mode is set to Alpha Clip. $\endgroup$ – NeverConvex Nov 8 at 16:51
  • $\begingroup$ The fast way is to use Import Images As Planes. $\endgroup$ – LeoNas Nov 8 at 17:07
0
$\begingroup$

Assuming you're using Eevee:

Per my comment, I think the problem is that your PNG's alpha channel (the second output in your Texture Input node) is not being used to do anything, and Toon BSDF interprets the fully Transparent pixels as black by default. Because of this, I get the same problem with this image of mine, where everything Black is actually Transparent (pixels with alpha=0):

enter image description here

We can fix this by setting Material->Blend Mode to Alpha clip (this assumes you have already set Context->Render Engine->Eevee), Context->Film->Transparent, and using a slightly more complicated shader, which uses our PNG's alpha channel to explicitly control the mix factor between a Transparent BSDF and the color information in our Toon BSDF:

enter image description here

Note that the math node could also be deleted if you switched the order of the inputs to the Mix Shader node.

$\endgroup$
  • $\begingroup$ Well thanks for the explanations, strangely it didn't resolve my black pixel issue as shown in this screenshot: imgur.com/0Sf3lkw But I did manage by removing the toon shader and using a normal one and combining the color and Alpha channel as in this capture: imgur.com/D0Ph4QE Thanks again :) $\endgroup$ – Eidern Nov 8 at 17:22
  • $\begingroup$ Oh, there's a small mistake in my second image -- the math node should be computing 1 - alpha, not 0.5 - alpha. I don't think that explains you still seeing pure black, though. Could you upload the .png you're using? I'll try to replicate the problem on my end. $\endgroup$ – NeverConvex Nov 8 at 17:25
  • 1
    $\begingroup$ Right : with a value > 1, the black color disappeared :) imgur.com/5zdQKGZ $\endgroup$ – Eidern Nov 8 at 17:33
  • $\begingroup$ Great! I believe what's going on is that the alpha values in the input image have been normalized to [0,1]. The math node is intended to take fully transparent pixels (alpha=0) and map them to the second mix-shader input (value=1-alpha=1), but with the math node incorrectly computing value=0.5-alpha, we instead get value=1-alpha=0.5, so transparent pixels get mapped to an even mixture of the Toon BSDF and the Transparent Shader, which is not what we had intended. $\endgroup$ – NeverConvex Nov 8 at 17:39

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.