{"id":13731469,"url":"https://github.com/ands/seamoptimizer","last_synced_at":"2025-04-24T04:13:39.525Z","repository":{"id":43557060,"uuid":"80344198","full_name":"ands/seamoptimizer","owner":"ands","description":"A C/C++ single-file library that minimizes the hard transition errors of disjoint edges in lightmaps.","archived":false,"fork":false,"pushed_at":"2023-01-31T11:50:17.000Z","size":4276,"stargazers_count":240,"open_issues_count":2,"forks_count":21,"subscribers_count":12,"default_branch":"master","last_synced_at":"2025-04-24T04:13:29.622Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/ands.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-01-29T12:13:47.000Z","updated_at":"2025-02-01T07:36:24.000Z","dependencies_parsed_at":"2025-01-09T18:48:22.132Z","dependency_job_id":null,"html_url":"https://github.com/ands/seamoptimizer","commit_stats":{"total_commits":14,"total_committers":1,"mean_commits":14.0,"dds":0.0,"last_synced_commit":"19b835c6e52d2100a8e6b58e19fe8da88d271368"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ands%2Fseamoptimizer","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ands%2Fseamoptimizer/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ands%2Fseamoptimizer/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ands%2Fseamoptimizer/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ands","download_url":"https://codeload.github.com/ands/seamoptimizer/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250560054,"owners_count":21450173,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-03T02:01:30.882Z","updated_at":"2025-04-24T04:13:39.481Z","avatar_url":"https://github.com/ands.png","language":"C","readme":"# seamoptimizer\nA C/C++ single-file library that minimizes the hard transition errors of disjoint edges in lightmaps.\nIt is based on a idea presented by Michał Iwanicki in the talk [Lighting Technology of \"The Last Of Us\"](http://miciwan.com/SIGGRAPH2013/Lighting%20Technology%20of%20The%20Last%20Of%20Us.pdf).\nA least squares solver is used to find a minimal error solution to the problem of sampling along the edges between triangles that are mapped with disjoint lightmap regions.\nThis can improve the visual appearance at these discontinuities or \"seams\".\n\n\nTo paste the implementation into your project, insert the following lines:\n```\n#define SEAMOPTIMIZER_IMPLEMENTATION\n#include \"seamoptimizer.h\"\n```\n\nBefore optimizing a very bad UV mapping (each triangle edge is a seam):\n![Sean Optimizer Before](https://github.com/ands/seamoptimizer/raw/master/example_images/stairs_triangles_not_optimized.png)\nAfter optimizing the seams of the bad UV mapping:\n![Sean Optimizer After](https://github.com/ands/seamoptimizer/raw/master/example_images/stairs_triangles_optimized.png)\nThe seams are not all completely gone, but, especially on the walls, there is a very noticeable improvement.\n\n# Example Usage\nThe following example finds and optimizes all the seams for some mesh geometry on a lightmap.\n```\n// only optimize seams between triangles that are on the same plane\n// (where dot(A.normal, B.normal) \u003e cosNormalThreshold):\nconst float cosNormalThreshold = 0.99f;\n\n// how \"important\" the original color values are:\nconst float lambda = 0.1f;\n\n\nprintf(\"Searching for separate seams...\\n\");\nso_seam_t *seams = so_seams_find(\n\t(float*)mesh-\u003epositions, (float*)mesh-\u003etexcoords, mesh-\u003evertexCount,\n\tcosNormalThreshold,\n\tlightmap-\u003edata, lightmap-\u003ewidth, lightmap-\u003eheight, lightmap-\u003echannelCount);\n\n\nprintf(\"Optimizing seams...\\n\");\nfor (so_seam_t *seam = seams; seam; seam = so_seam_next(seam))\n{\n\t// NOTE: seams can also be optimized in parallel on separate threads!\n\tif (!so_seam_optimize(seam, lightmap-\u003edata, lightmap-\u003ewidth, lightmap-\u003eheight, lightmap-\u003echannelCount, lambda))\n\t\tprintf(\"Could not optimize a seam (Cholesky decomposition failed).\\n\");\n}\n\nprintf(\"Done!\\n\");\nso_seams_free(seams);\n```\n\n# Thanks\n- To Michał Iwanicki for helping me with the transformation of the problem into a problem that can be solved by a least-squares solver\n- To Dominik Lazarek for pointing me to Michał's presentation\n","funding_links":[],"categories":["ComputerGraphics \u0026\u0026 Shadingv","Maths"],"sub_categories":["Google Analytics"],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fands%2Fseamoptimizer","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fands%2Fseamoptimizer","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fands%2Fseamoptimizer/lists"}