Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handle alpha in textures? #19

Closed
fire opened this issue Jun 26, 2019 · 14 comments
Closed

Handle alpha in textures? #19

fire opened this issue Jun 26, 2019 · 14 comments

Comments

@fire
Copy link

fire commented Jun 26, 2019

When combining texture charts values, does xatlas handle alphas in the 4th channel?

@fire
Copy link
Author

fire commented Jun 26, 2019

Seems like I can modify https://github.com/jpcy/xatlas/blob/master/extra/example_uvmesh.cpp#L83 to handle the 4 8-bit colors and 4 float colors.

@jpcy
Copy link
Owner

jpcy commented Jun 26, 2019

Apart from the repack example (which is incomplete), the other example output images are just for visualization. The rasterization used to generate them isn't precise, so I don't recommend using them for anything.

@fire
Copy link
Author

fire commented Jun 26, 2019

My goal is to take multiple meshes make them use 1 texture and uv space. Then, merge the meshes.

Is this not suitable?

@jpcy
Copy link
Owner

jpcy commented Jun 26, 2019

The repack example here does that, but it doesn't handle bilinear filtering yet.

@fire
Copy link
Author

fire commented Jun 26, 2019

Why would it need to handle bilinear filtering?

@fire
Copy link
Author

fire commented Jun 26, 2019

I have access to:

INTERPOLATE_NEAREST
INTERPOLATE_BILINEAR
INTERPOLATE_CUBIC
INTERPOLATE_TRILINEAR
INTERPOLATE_LANCZOS

@jpcy
Copy link
Owner

jpcy commented Jun 26, 2019

Because bilinear filtering samples neighboring texels. The repack example copies texture data by conservatively rasterizing charts in the new UV space. A source texel on the edge of a texture may end up in the middle of the atlas and bilinear filtering would lerp with neighboring black texels.

@fire
Copy link
Author

fire commented Jun 27, 2019

If we made the original texture twice as big using a filter like LANCZOS and would it have the same effect?

Or the other way around shrinking by half...

@fire
Copy link
Author

fire commented Jun 27, 2019

Going back to the theory. Sorry for my misunderstandings.

@fire
Copy link
Author

fire commented Jun 27, 2019

Why can't we pad the charts with suitable pixels? https://github.com/jpcy/xatlas/blob/master/xatlas.h#L204

@fire
Copy link
Author

fire commented Jun 27, 2019

I have access to a function that takes a square size of image data and resizes it.

template <int CC, class T>
static void _scale_lanczos(const uint8_t *__restrict p_src, uint8_t *__restrict p_dst, uint32_t p_src_width, uint32_t p_src_height, uint32_t p_dst_width, uint32_t p_dst_height)

You create a bounding rectangle here https://github.com/jpcy/xatlas/blob/master/extra/example_repack.cpp#L359.

Not sure where to go.

@ghost
Copy link

ghost commented Jun 28, 2019

@fire you can check AliceVision on github to see how it handles bilinear filtering. It uses geogram which uses xatlas. Here, this is how you do it. I'm going to implement it for example_repack in a week or so.

jpcy added a commit that referenced this issue Jun 29, 2019
jpcy added a commit that referenced this issue Jun 30, 2019
… texture. If that fails, average surrounding texels color in source texture. If that fails, average using the atlas texture. #18 #19
@jpcy
Copy link
Owner

jpcy commented Jul 1, 2019

There shouldn't be any artifacts with bilinear filtering now.

Comparing input to output, they don't quite match and there's some distortion in the texture data. I think something is off by half a texel.

@fire
Copy link
Author

fire commented Jul 14, 2019

Trying the revised code today.

@fire fire closed this as completed Jul 16, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants