diff options
author | Juan Linietsky <reduzio@gmail.com> | 2018-10-04 23:00:02 -0300 |
---|---|---|
committer | Juan Linietsky <reduzio@gmail.com> | 2018-10-05 19:00:32 -0300 |
commit | f12cb82e0f7b3348ab678322cf5e729b38861f1e (patch) | |
tree | ab9ccc69df906b8591e3f0b91c25266393304144 /modules | |
parent | a41cf404a9013db6aed56d6ed9b051c2a4948bff (diff) |
Fixes to baker, restored xatlas and fixed bake options.
Diffstat (limited to 'modules')
-rw-r--r-- | modules/thekla_unwrap/config.py | 3 | ||||
-rw-r--r-- | modules/xatlas_unwrap/config.py | 4 | ||||
-rw-r--r-- | modules/xatlas_unwrap/register_types.cpp | 18 |
3 files changed, 18 insertions, 7 deletions
diff --git a/modules/thekla_unwrap/config.py b/modules/thekla_unwrap/config.py index bd092bdc16..fad6095064 100644 --- a/modules/thekla_unwrap/config.py +++ b/modules/thekla_unwrap/config.py @@ -1,5 +1,6 @@ def can_build(env, platform): - return (env['tools'] and platform not in ["android", "ios"]) + #return (env['tools'] and platform not in ["android", "ios"]) + return False def configure(env): pass diff --git a/modules/xatlas_unwrap/config.py b/modules/xatlas_unwrap/config.py index 962d33280f..2dda5db7e0 100644 --- a/modules/xatlas_unwrap/config.py +++ b/modules/xatlas_unwrap/config.py @@ -1,6 +1,6 @@ def can_build(env, platform): - return False #xatlas is buggy - #return (env['tools'] and platform not in ["android", "ios"]) + #return False #xatlas is buggy + return (env['tools'] and platform not in ["android", "ios"]) def configure(env): pass diff --git a/modules/xatlas_unwrap/register_types.cpp b/modules/xatlas_unwrap/register_types.cpp index 9df16aac70..57eea4eda6 100644 --- a/modules/xatlas_unwrap/register_types.cpp +++ b/modules/xatlas_unwrap/register_types.cpp @@ -75,8 +75,9 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver xatlas::CharterOptions chart_options; xatlas::PackerOptions pack_options; + pack_options.method = xatlas::PackMethod::TexelArea; pack_options.texelArea = 1.0 / p_texel_size; - pack_options.quality = 4; + pack_options.quality = 3; xatlas::Atlas *atlas = xatlas::Create(); printf("adding mesh..\n"); @@ -93,7 +94,10 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver float w = *r_size_hint_x; float h = *r_size_hint_y; - printf("final texsize: %f,%f\n", w, h); + if (w == 0 || h == 0) { + return false; //could not bake + } + const xatlas::OutputMesh *const *output_meshes = xatlas::GetOutputMeshes(atlas); const xatlas::OutputMesh *output = output_meshes[0]; @@ -102,11 +106,17 @@ bool xatlas_mesh_lightmap_unwrap_callback(float p_texel_size, const float *p_ver *r_uv = (float *)malloc(sizeof(float) * output->vertexCount * 2); *r_index = (int *)malloc(sizeof(int) * output->indexCount); + float max_x = 0; + float max_y = 0; for (int i = 0; i < output->vertexCount; i++) { (*r_vertex)[i] = output->vertexArray[i].xref; - (*r_uv)[i * 2 + 0] = output->vertexArray[i].uv[0]; - (*r_uv)[i * 2 + 1] = output->vertexArray[i].uv[1]; + (*r_uv)[i * 2 + 0] = output->vertexArray[i].uv[0] / w; + (*r_uv)[i * 2 + 1] = output->vertexArray[i].uv[1] / h; + max_x = MAX(max_x, output->vertexArray[i].uv[0]); + max_y = MAX(max_y, output->vertexArray[i].uv[1]); } + + printf("final texsize: %f,%f - max %f,%f\n", w, h, max_x, max_y); *r_vertex_count = output->vertexCount; for (int i = 0; i < output->indexCount; i++) { |