Page MenuHome

Baking pixel-perfect maps is extremely inaccurate
Closed, ResolvedPublic

Description

System Information
Operating system: Windows-7-6.1.7601-SP1 64 Bits
Graphics card: GeForce GTX 660 Ti/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 442.59

Blender Version
Broken: version: 2.83 (sub 9), branch: master, commit date: 2020-03-15 22:43, hash: rBf06a6e92bc5e

Short description of error



Islands are not null sized. They aligned to pixel centers.
And i still can`t bake em all. Try to bake with this file.
Such baking need fpr pixel-art and poly-art baking.

Event Timeline

It seems that this is how it is designed.

The rule is, a given pixel only belongs to one polygon. Very tiny polygons (less than 1 pixel) are completely ignored by rasterization, unless they cross pixel boundaries. This way the produced pixels don't overlap, but they can still fill the texture without holes, assuming the correct mesh topology. Tiny islands, on the other hand, are only visible "by chance". Perhaps the algorithm could be extended to treat island edges differently: they would be always fully rasterized, ignoring the usual polygon rules? Not sure if this is the correct way. More complex definitely.

Changing

my0=ceil(minv[1])

to

my0=floor(minv[1]);

in zbuf_add_to_span() and removing

sn1++;

in zspan_scanconvert() nearly "fixes" the problem (and of course breaks something else, because it is not selective).

Anyway, you don't absolutely need it to achieve the effect. Instead of producing exact pixel values directly, bake to bigger texture (so your bake polygons are well above 1 pixel in size), and then produce your pixel texture from this bigger bitmap.

@Szymon Ulatowski (szulat) sadly, even relatively big island, that crossing three pixel boundaries, still not give a chance to bake it.
okay, i will try to get pixel texture from bigger result? but I am not sure, result will be proper and solid.

I tested the file and the behavior seemed to be as expected.
Some triangles are not overlapping the middle of the pixel, so the resulting color is Alpha.
This is the expected when you decrease the resolution of a texture.
https://en.wikipedia.org/wiki/Texture_filtering

Did I misunderstand the problem?

Germano Cavalcante (mano-wii) changed the task status from Needs Triage to Needs Information from User.Wed, Mar 25, 7:04 PM
Vyacheslav (hitrpr) added a comment.EditedMon, Mar 30, 6:44 AM

@Germano Cavalcante (mano-wii)
Oh, thanks!
So tris can be small but should cover the centers of pixels.
Yes, that solves the problem.
It is more like I misunderstood how it should work.

Vyacheslav (hitrpr) closed this task as Resolved.Mon, Mar 30, 6:49 AM