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

Getting Face Materials from Packed Mesh #110

Open
AdamExley opened this issue Dec 20, 2022 · 0 comments
Open

Getting Face Materials from Packed Mesh #110

AdamExley opened this issue Dec 20, 2022 · 0 comments

Comments

@AdamExley
Copy link

I have a standard .obj mesh that has a couple materials.

The mesh's charts are correctly computed and packed according to material, but every resulting chart is assigned material index 0, regardless of the material that the chart is composed of.

Digging into the source code, this is deliberately done in PackCharts, but only when ctx->uvMeshInstances is empty; for uv meshes, the output materials are assigned correctly.

Here's what I'm referring to:
xatlas.cpp:9787

		for (uint32_t f = 0; f < outputChart->faceCount; f++)
			outputChart->faceArray[f] = chart->mapFaceToSourceFace(f);
	}
	outputChart->material = 0;
	meshChartIndex++;
	chartIndex++;
	firstVertex += chart->originalVertexCount();

Versus:
xatlas.cpp:9845

		outputChart->material = chart->material;
		for (uint32_t f = 0; f < outputChart->faceCount; f++)
			outputChart->faceArray[f] = chart->faces[f];
		chartIndex++;

Is there a reason for this behavior?

I understand that that UV mesh counterpart uses internal::pack::Chart, which has material data whereas I couldn't find easy access to any material data in the case for normal meshes.

The only way I have been able to avoid this is by changing line 9787 as follows, and referencing the material of the mesh faces in my meshDecl in the external code I am using.

outputChart->material = 0; // Old

outputChart->material = chart->mapFaceToSourceFace(0); // New
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

1 participant