0
\$\begingroup\$

I am currently trying to implement a shader to a sprite of mine, but the transparency is completely removed when the texture goes through a Sample Texture 2D node.

The sprite under the Sample Texture 2D node.

The sprite Import settings

enter image description here

The sprite on a image viewer.

enter image description here

\$\endgroup\$
7
  • 1
    \$\begingroup\$ What do you see if you take the Alpha (A) pin and output it somewhere? That's the pin that carries the transparency information, and it might just not be shown in the RGB preview below. \$\endgroup\$
    – DMGregory
    Jul 8 at 17:52
  • \$\begingroup\$ I applied the A pin to a Negate node and it returned all black, meaning that no Alpha is being received on the shader? Though when using non-shader materials the transparency works fine. Something that I noticed is that the 'extra pixels' are just the outline pixels but stretched out to border of the image. \$\endgroup\$
    – Kaka Gamer
    Jul 8 at 17:58
  • \$\begingroup\$ Try piping it to an "Add" node but add zero, rather than negating it. 1 negated is -1, which also shows up as black, so a negate node is a very bad choice for when you want to inspect data in the range 0 to 1. 😉 \$\endgroup\$
    – DMGregory
    Jul 8 at 18:05
  • \$\begingroup\$ Ok, so, the alpha is actually returning properly, being white on colored pixels and black on empty ones. I tried fixing it through shader manipulation, making the A absolute, and combining with the rgb channels, but apparently it just goes back to the original texture. \$\endgroup\$
    – Kaka Gamer
    Jul 8 at 18:16
  • 1
    \$\begingroup\$ You're not stupid, you're learning. Want to post your solution as an answer below, to help future readers learn how to do this too? \$\endgroup\$
    – DMGregory
    Jul 8 at 18:43
0
\$\begingroup\$

I had forgotten to connect the Alpha Channel to the Output of the Shader.

enter image description here

\$\endgroup\$
1
  • \$\begingroup\$ Can you get a screenshot that shows the texture sampling node too, so a reader can see how you routed the output pins to the fragment node? \$\endgroup\$
    – DMGregory
    Jul 8 at 18:49

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.