A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://github.com/ands/seamoptimizer below:

ands/seamoptimizer: A C/C++ single-file library that minimizes the hard transition errors of disjoint edges in lightmaps.

A C/C++ single-file library that minimizes the hard transition errors of disjoint edges in lightmaps. It is based on a idea presented by Michał Iwanicki in the talk Lighting Technology of "The Last Of Us". A 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. This can improve the visual appearance at these discontinuities or "seams".

To paste the implementation into your project, insert the following lines:

#define SEAMOPTIMIZER_IMPLEMENTATION
#include "seamoptimizer.h"

Before optimizing a very bad UV mapping (each triangle edge is a seam): After optimizing the seams of the bad UV mapping: The seams are not all completely gone, but, especially on the walls, there is a very noticeable improvement.

The following example finds and optimizes all the seams for some mesh geometry on a lightmap.

// only optimize seams between triangles that are on the same plane
// (where dot(A.normal, B.normal) > cosNormalThreshold):
const float cosNormalThreshold = 0.99f;

// how "important" the original color values are:
const float lambda = 0.1f;


printf("Searching for separate seams...\n");
so_seam_t *seams = so_seams_find(
	(float*)mesh->positions, (float*)mesh->texcoords, mesh->vertexCount,
	cosNormalThreshold,
	lightmap->data, lightmap->width, lightmap->height, lightmap->channelCount);


printf("Optimizing seams...\n");
for (so_seam_t *seam = seams; seam; seam = so_seam_next(seam))
{
	// NOTE: seams can also be optimized in parallel on separate threads!
	if (!so_seam_optimize(seam, lightmap->data, lightmap->width, lightmap->height, lightmap->channelCount, lambda))
		printf("Could not optimize a seam (Cholesky decomposition failed).\n");
}

printf("Done!\n");
so_seams_free(seams);

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4