Baking pixel-perfect maps is extremely inaccurate #74823

Closed
opened 2020-03-16 19:24:42 +01:00 by Vyacheslav Kobozev · 9 comments

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: f06a6e92bc

Short description of error
32712616.jpg
untitled1.blend
2020-03-16_21-22-35.mp4

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.

**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: `f06a6e92bc` **Short description of error** ![32712616.jpg](https://archive.blender.org/developer/F8410667/32712616.jpg) [untitled1.blend](https://archive.blender.org/developer/F8410669/untitled1.blend) [2020-03-16_21-22-35.mp4](https://archive.blender.org/developer/F8410678/2020-03-16_21-22-35.mp4) 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.

Added subscriber: @Vyach

Added subscriber: @Vyach

Added subscriber: @szulat

Added subscriber: @szulat

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.

**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.

@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.

@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.

Added subscriber: @mano-wii

Added subscriber: @mano-wii

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?

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?

Changed status from 'Needs Triage' to: 'Needs User Info'

Changed status from 'Needs Triage' to: 'Needs User Info'

@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.
33550643.jpg

@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. ![33550643.jpg](https://archive.blender.org/developer/F8436311/33550643.jpg)

Changed status from 'Needs User Info' to: 'Resolved'

Changed status from 'Needs User Info' to: 'Resolved'
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
3 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#74823
No description provided.