KOVIAHN Posted August 12, 2021 Share Posted August 12, 2021 (edited) 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 August 12, 2021 by KOVIAHN Link to comment
sweetluna Posted August 12, 2021 Share Posted August 12, 2021 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. May RenderDoc/Nsight Graphics/Intel GPA bless you Link to comment
KOVIAHN Posted August 13, 2021 Author Share Posted August 13, 2021 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. 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
sweetluna Posted August 13, 2021 Share Posted August 13, 2021 Hi, For 2.13 this works fine, but in 2.14 one more flag is needed, since the lightmapper is not designed for using it outside of the editor. Try adding staticMesh->setShowInEditorEnabled(true); at the end of mesh creation. This should work May RenderDoc/Nsight Graphics/Intel GPA bless you Link to comment
KOVIAHN Posted August 17, 2021 Author Share Posted August 17, 2021 Dear Sweetluna. Thank you very much. It works :) Link to comment
Recommended Posts