0
\$\begingroup\$

I've recently (11 hours ago, to be precise😅) started to work with shaders and it's going pretty well. I've created a simple shader to create an outline and I tested it on a simple object to see how it works and here's the result:

  • the original object (in photoshop)

original obj

  • the object in unity with shader

shaded obj

As you can see, one of the blue pixels is nearly gone but I haven't found the reason. here's my shader (there are some other objects in preview which are not relevant to the current question):

shader setting

I'm also not sure why the left and right borders are thicker than the top and bottom borders.

As this is my first question about shaders, I may not have included every needed piece of information, so feel free to ask anything you need.

Edit: I've just found out this error in Pixel Perfect Camera component, may be related to the issue:

pixel perfect camera

I tried to replace the component with "pixel perfect camera (experimental)" and the error was gone but the result didn't change.

UPDATE:

I was trying to figure out why this is happening and found something interesting. When I make the outline's color transparent, the single pixel can be shown again but has a slightly darker color as shown in the picture:

darker pixel

I've also found out why the left and right borders were thicker. It was because of the size of the original file, if the file is in a square shape (25x25 for instance) there wouldn't be any problems. Though the only fix for this issue is changing the size of assets which is not convenient so any other solution is welcomed

\$\endgroup\$
7
  • \$\begingroup\$ Mysterious. I suspect it might be happening in the "removing extra colors" step, where you multiply by the alpha, but the preview is tiny and I can't see it the pixel looks right in there. Also, maybe it's a texture filtering thing? Seems plausible that the value of the alpha might be getting interpolated with the neighbouring pixels, since the weird one happens to be the one surrounded by empty pixels. \$\endgroup\$
    – PepeOjeda
    Commented Jun 29, 2022 at 8:40
  • \$\begingroup\$ That "removing extra colors" was in the tutorial video too so I don't think the problem is caused by that. And I have no idea what texture filtering is. Do you need any zoomed-in screen shot of a part of the shader? \$\endgroup\$
    – Arian_ki
    Commented Jun 29, 2022 at 10:32
  • \$\begingroup\$ Texture Filtering is basically what determines the color that is returned by sampling a texture. If you don't want to get too far down the rabbit hole, you can just think of it as interpolating the values of nearby pixels when you sample a point that is not exactly at the center of the pixel. In any case, in Unity you can choose different types of filtering (bilinear, trilinear, point) in the import options of the texture image. For pixel art you should use point filtering, otherwise the interpolation will soften the edges of the pixels. \$\endgroup\$
    – PepeOjeda
    Commented Jun 29, 2022 at 10:40
  • \$\begingroup\$ Oh, thanks for explanation. But that won't help me as all of my assets have been set to "point" from the start \$\endgroup\$
    – Arian_ki
    Commented Jun 29, 2022 at 10:49
  • \$\begingroup\$ @PepeOjeda By the way, I found an error that probably has something to do with the issue. Check the question \$\endgroup\$
    – Arian_ki
    Commented Jun 29, 2022 at 11:05

0

You must log in to answer this question.

Browse other questions tagged .