Jump to content

[SOLVED] How to make Baked-Lightmap using user-defined mesh


photo

Recommended Posts

Hello. 

We are implementing a function that creates a lightmap of user-made drawing objects.
However, when creating a StaticeObjectMesh based on the mesh created in real time, the Lightmap is not created.
I made a simple sample source. Please comment on which part is the problem.

Thank you.

AppWorldLogic.cpp

Edited by KOVIAHN
Link to comment

Hi,

you have to unwrap your mesh's Nth UV channel. The N corresponds to the second argument in setSurfaceLightmapUVChannel function.
So if you called setSurfaceLightmapUVChannel(0, 0) this corresponds to first UV channel and can be added to the mesh like so:

	mesh->addVertex(Math::vec3(0.0f, 0.0f, 0.0f), 0);
	mesh->addTexCoord0(Math::vec2(0.0f, 0.0f), 0);

	mesh->addVertex(Math::vec3(0.0f, 0.0f, 1.0f), 0);
	mesh->addTexCoord0(Math::vec2(1.0f, 0.0f), 0);

	mesh->addVertex(Math::vec3(0.0f, 1.0f, 0.0f), 0);
	mesh->addTexCoord0(Math::vec2(0.0f, 1.0f), 0);

	mesh->addVertex(Math::vec3(0.0f, 1.0f, 1.0f), 0);
	mesh->addTexCoord0(Math::vec2(1.0f, 1.0f), 0);

Currently automatic UV unwrapping is not available through easy to use API and can be done only on FBX, GLTF, or CAD import using corresponding importer API.

Link to comment

Dear Sweetluna.

Thank you for your answer.

Referring to the above article, a LIGHTMAP channel was created in UV 1.
The structure of the mesh looks normal.

image.png.0b45ae040d0939f6401d292a6ad80d94.png

 

However  when I create a staticmesh with that mesh, the lightmap is still not created in VS2015.

But static object with the mesh in the editor, a lightmap is created.
I don't know which part is wrong.
Please help.

Thank you.

AppWorldLogic.cpp

Link to comment
  • silent changed the title to [SOLVED] How to make Baked-Lightmap using user-defined mesh
×
×
  • Create New...