# Getting UVs and colors to work with dynamic mesh using FDynamicMesh3

**URL:** <https://forums.unrealengine.com/t/getting-uvs-and-colors-to-work-with-dynamic-mesh-using-fdynamicmesh3/761209>\
**Category:** World Creation\
**Tags:** unreal-engine, Rendering, CPP, question\
**Created:** [February 1, 2023, 8:16am UTC](https://forums.unrealengine.com/t/getting-uvs-and-colors-to-work-with-dynamic-mesh-using-fdynamicmesh3/761209 "2023-02-01T08:16:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ManicMaker1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ManicMaker1](https://forums.unrealengine.com/u/ManicMaker1)\
**Post date:** [February 1, 2023, 8:16am UTC](https://forums.unrealengine.com/t/getting-uvs-and-colors-to-work-with-dynamic-mesh-using-fdynamicmesh3/761209/1 "2023-02-01T08:16:37Z")

</div>

I’ve been working with FDynamicMesh3 for a while now but have just recently got around to working closely with the UVs and colors of the mesh I’ve created. My issue is that no matter what I do, I can’t get the UVs or colors to work. (As I understand it, the color problem should sort itself out if I can solve the UV problem.)

The mesh I’ve created is a flat (2D) circle. [Sample: grey tiles are my mesh](https://imgur.com/hg2d1tb). I’ve verified that the UV and color buffers in the FDynamicMesh3 object contain the expected values alongside the normal data, but the only indication I have that anything is working is that it’s getting the vertices and triangle data and generating the mesh, but it’s not doing anything with the UV/color/normals.

I read recently someone had managed to get everything to work by using some functions from the FDynamicMeshAttributeSet family (CopyVertexUVsToOverlay and CopyVertexNormalsToOverlay) , but I’ve had no such success. I wrapped the FDynamicMesh3 in a DynamicMeshAttributeSet and tried the functions indicated and there was no change.

If I drag the actor class with my mesh generating code into the editor viewport and use the Modelling mode → AutoUV setting, it takes a few seconds to think and then the checkerboard pattern tells me that the UVs are set and working (but still won’t show my colors).

The only things I can say about my situation that are objectively true:

- The FDynamicMesh3 data is being successfully placed in the container
- The vertex and triangle data is being used successfully to render the basic mesh
- Vertex and triangle data was working both when I was only using FDynamicMesh3, and also since I wrapped it in the FDynamicMeshAttributeSet object.
- Nothing I have tried programatically, including the recommended functions, has ever worked to produce the outcome I’m expecting (mesh covered in a kaleidoscope of colors).

I need a way to get them to work programatically and would love if any of you have managed to get this to work and could drop a tip or two.

Thanks very much in advance.

---

<div class="post-metadata">

**Author:** ![sqdcn](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@sqdcn](https://forums.unrealengine.com/u/sqdcn)\
**Post date:** [November 9, 2023, 3:20am UTC](https://forums.unrealengine.com/t/getting-uvs-and-colors-to-work-with-dynamic-mesh-using-fdynamicmesh3/761209/2 "2023-11-09T03:20:10Z")

</div>

After some digging around, [this post](https://forums.unrealengine.com/t/from-proceduralmesh-to-dynamicmesh/661279/3) what ended up solving it for me:

I am doing these (not sure if all of them are necessary)

```auto
	FDynamicMesh3 newMesh;
	newMesh.EnableAttributes();
	newMesh.EnableVertexUVs(FVector2f::Zero());
 
// generate vertices with UV logics ....

	UE::Geometry::CopyVertexUVsToOverlay(newMesh, *newMesh.Attributes()->PrimaryUV());

```

Voila!

---

<div class="post-metadata">

**Author:** ![ManicMaker1](https://d3kjluh73b9h9o.cloudfront.net/original/4X/2/8/5/28502927f1d97ba1051b3b47ccfe17233bf41ef0.png) [@ManicMaker1](https://forums.unrealengine.com/u/ManicMaker1)\
**Post date:** [December 16, 2023, 4:47pm UTC](https://forums.unrealengine.com/t/getting-uvs-and-colors-to-work-with-dynamic-mesh-using-fdynamicmesh3/761209/3 "2023-12-16T16:47:08Z")

</div>

Hey, thanks for your post! Sorry it took so long to respond. I have a few other things to test before I can try your solution but if it works I’ll make sure to come back and mark it properly.

Thanks again!

---

<div class="post-metadata">

**Author:** ![system](https://d3kjluh73b9h9o.cloudfront.net/original/4X/7/1/3/713c9d3f58553f0de89543d76a8a3a2779dc9fa4.png) [@system](https://forums.unrealengine.com/u/system)\
**Post date:** [May 18, 2024, 3:56pm UTC](https://forums.unrealengine.com/t/getting-uvs-and-colors-to-work-with-dynamic-mesh-using-fdynamicmesh3/761209/4 "2024-05-18T15:56:30Z")

</div>

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
