#Weird behaviour of a pixel art UV mapping shader

1 messages · Page 1 of 1 (latest)

fallow iron
#

I'm making a shader which takes the RG channels of a texture and uses them as UV to look up colors from an another texture. For some reason the end result ends up having these white gaps in it, suggesting the shader looking up wrong coordinates despite them working perfectly in a Blender preview.

#

here's textures used

wispy epoch
fallow iron
#

here is the Blender shader result

fallow iron
#

also tried converting color spaces between RGB and linear, didn't do anything helpful either

wispy epoch
#

That would have been my second guess. Does your shader in blender use linear color space too (and not sRGB)?

drowsy plover
#

Try to disable mip maps on the color texture.

fallow iron
#

they're not enabled

drowsy plover
#

🤔
sometimes the color sampling still does some gamma correction, you could try to put a color space conversion node between the sample output and uv input, and try linear -> sRGB or sRGB -> linear setting.

fallow iron
#

well that generally results in nonsense, but I'll try an offset

drowsy plover
fallow iron
drowsy plover
#

I was also going to suggest a half pixel offset after this 😅

fallow iron
#

the offset was honestly my firstest solution long ago (this is an old bug, I just left it for later)

drowsy plover
#

Hum, the white bleeding seems to come from where different body parts overlap.
IDK how you are making the UV texture, but if you are rendering it from blender, maybe it's anti-aliasing the 3D objects (kind of expected) and blends the arm and body UV for example.

#

Disabling any form of AA in the rendering might fix it.

fallow iron
#

it's hand drawn pixel art

#

the UV maps are made by hand-placing pixels that match UV coordinates in the lookup texture

#

there's no AA involved as far as I'm aware unless Unity is hiding it from me

drowsy plover
#

What does the shader nodes look like in blender ? nothing particular I guess ?
I'm a bit cluelees about why it would behave differently now :/

fallow iron
#

I gotta find the most recent file because I lost it 💀

drowsy plover
#

I'm almost there though

fallow iron
#

👀

drowsy plover
#

The UV texture importer needs to have "Non-Power of 2" disabled

#

It was messign up the values.

fallow iron
#

how do I do that

drowsy plover
fallow iron
#

I don't see that being a thing on 6.2

#

is that a new setting or am I missing a package?

drowsy plover
#

I'm on 6.3, but it's an old setting.
Can you screenshot the texture importer ?

#

I've also added a half pixel negative offset to the uvs.

fallow iron
#

as far as I remember, the only thing the blender shader did past the basic mapping was the offset, can't find the most recent file right now

#

oh

drowsy plover
#

Oh, the texture is imported as 2D and UI, this is why you don't have the Power of Two setting.

fallow iron
#

it's because it was in Sprite mode

drowsy plover
#

If found a "fix"

#

I applied a "dilatation" filter to the color texture to avoid the white pixels.
Maybe in blender the texture was on a transparent background and blender was filling the pixels itself 🤷

#

And here's the graph setup :

viscid pewter
#

Afaik blender indeed does color dilation with alpha transparency automatically

#

Or the sampling method is otherwise somehow different enough to cause one pixel fringing to appear differently

drowsy plover
#

I didn't get the exact same result as the reference blender screenshot, so I'm not sure this is 100% correct though, but it's the closest I got.

viscid pewter
#

Mipmap sampling is also different, and something you don't really have control over

fallow iron
#

neat, now to solve the problem caused by losing access to the spritesheet

#

since I was using that to animate

#

😅