GitHubComeçar

A referência da API é gerada a partir dos comentários de documentação Go no código-fonte e está escrita em inglês.

package texseam

import "github.com/nsgo-dev/game/pkg/tooling/texseam"

Visão geral

Package texseam is experimental: its API and documented formats may change in a minor release. See the API stability policy. checks and repairs image seams and derives tangent-space maps for textures used by the game renderer.

Índice

Constantes

const DefaultThreshold = 1.3

DefaultThreshold is the wrap-edge to interior difference ratio at or below which Check reports a seamless tile.

Funções

func Fix(img image.Image, opts FixOptions) *image.RGBA

Fix repairs wrap seams by matching opposite edges and feathering the change into the image. It preserves the input dimensions and color-independent deterministic output.

func Height(img image.Image, blur int, mode SampleMode) *image.Gray

Height converts an image to luminance height, applying a deterministic box blur with the requested radius before returning an 8-bit grayscale image. The blur samples past the edges with mode: Wrap keeps a seamless tile seamless, Clamp suits sprites.

func Merge(original, edited image.Image, band int) *image.RGBA

Merge keeps edited pixels only in a feathered vertical and horizontal band around the tile center. Pixels outside those bands remain byte-identical to original.

func Normal(height image.Image, strength float64, mode SampleMode, green GreenAxis) *image.NRGBA

Normal derives an RGBA8 tangent-space normal map from a height image using central differences. A flat area encodes as (128, 128, 255); green selects the sign of the green channel so the map matches lights2d (GreenDown) or render3d (GreenUp).

func Roughness(height image.Image, contrast float64) *image.Gray

Roughness derives an inverted, contrast-stretched grayscale roughness map.

Tipos

type FixOptions struct {
	Band int
}

FixOptions controls seam repair. Band is the number of pixels over which each edge is blended toward the opposite edge. Zero uses roughly one eighth of the smaller dimension, capped at 16 pixels.

type GreenAxis uint8

GreenAxis selects which image direction a positive green channel points to in a normal map.

const (
	// GreenDown points +G toward increasing image y (screen down), the convention lights2d.ShadeNormalMap decodes.
	GreenDown GreenAxis = iota
	// GreenUp points +G toward decreasing image y (up, -V), the glTF convention render3d's NormalTexture uses.
	GreenUp
)
type SampleMode uint8

SampleMode selects how Height and Normal sample pixels past the image edges.

const (
	// Wrap samples the opposite edge, for textures that repeat.
	Wrap SampleMode = iota
	// Clamp repeats the nearest edge pixel, for sprites and other images that do not repeat.
	Clamp
)
type SeamReport struct {
	WrapXRatio float64
	WrapYRatio float64
	InteriorX  float64
	InteriorY  float64
	Threshold  float64
	Pass       bool
}

SeamReport contains the wrap-edge and interior differences for both axes. Ratios at or below Threshold pass the tiling check.

func Check(img image.Image) SeamReport

Check measures the left/right and top/bottom wrap seams using the default threshold. Differences are normalized to the mean difference of interior neighbors on the same axis.

func CheckWithThreshold(img image.Image, threshold float64) SeamReport

CheckWithThreshold is Check with an explicit ratio threshold.