La référence API provient des commentaires de documentation Go du code source et est rédigée en anglais.
package texseam
import "github.com/nsgo-dev/game/pkg/tooling/texseam"Vue d’ensemble
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.
Index
- Constantes
- func Fix(img image.Image, opts FixOptions) *image.RGBA
- func Height(img image.Image, blur int, mode SampleMode) *image.Gray
- func Merge(original, edited image.Image, band int) *image.RGBA
- func Normal(height image.Image, strength float64, mode SampleMode, green GreenAxis) *image.NRGBA
- func Roughness(height image.Image, contrast float64) *image.Gray
- type FixOptions
- type GreenAxis
- type SampleMode
- type SeamReport
Constantes
const DefaultThreshold = 1.3DefaultThreshold is the wrap-edge to interior difference ratio at or below which Check reports a seamless tile.
Fonctions
func Fix(img image.Image, opts FixOptions) *image.RGBAFix 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.GrayHeight 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.RGBAMerge 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.NRGBANormal 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.GrayRoughness derives an inverted, contrast-stretched grayscale roughness map.
Types
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 uint8GreenAxis 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 uint8SampleMode 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) SeamReportCheck 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) SeamReportCheckWithThreshold is Check with an explicit ratio threshold.