Help us shape the future of Go! Take the 2026 Go Developer Survey

worldreflection

package
v0.0.20 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 9 Imported by: 0

README

Saved reflection cubemaps

world/reflection-cubemaps@1 packages immutable static cubemaps for a fixed, renderer-ready chunk level. @world/reflection-cubemaps contains a KRC1 bundle with explicit sector/solid bindings, independent capture origins and projection bounds, and six lossless 128 × 128 RGBA faces per environment. The horizontal strip orders faces +X, -X, +Y, -Y, +Z, -Z and preserves graphics bottom-up rows.

InputDigest binds the original root metadata and every original payload, including catalog hashes of chunk geometry and baked lighting. It excludes only the reflection entry itself. A consumer calls Decode and ValidateSource before accepting the bundle. A changed level requires a fresh capture.

The format allows at most 256 environments, 256 sector bindings and 1024 solid bindings. Each binding is -1 or references a present environment. Bounds must be finite, contain the capture origin strictly, and span at most 65536 units on each axis. Images must be complete RGBA/sRGB QOI strips. The full encoded bundle fits the level entry's 8 MiB bound; decoded pixels total at most 96 MiB and count against the consumer's aggregate texture budget before allocation.

Decode borrows admitted image bytes from its input. Callers must retain the input and keep it immutable. No game code or renderer dependency is required to validate the public artifact. The engine owns capture and GPU projection; the CLI owns invoking offline capture and packaging matching cached output.

Documentation

Overview

Package worldreflection defines saved static parallax-corrected environments.

Index

Constants

View Source
const (
	Feature         = "world/reflection-cubemaps@1"
	EntryName       = "@world/reflection-cubemaps"
	Producer        = "karty-static-cubemap@1"
	FaceSize        = 128
	Faces           = 6
	MaxProbes       = world.MaxSectors
	MaxEncodedSize  = level.MaxEntrySize
	ImageBytes      = FaceSize * FaceSize * Faces * 4
	MaxDecodedBytes = MaxProbes * ImageBytes
)

Variables

View Source
var ErrCubemaps = errors.New("saved reflection cubemaps are invalid")

Functions

func Encode

func Encode(bundle Bundle) ([]byte, error)

func InputDigest

func InputDigest(envelope level.Envelope) string

InputDigest binds every original level payload and metadata, transitively including immutable child hashes and their baked lighting through the catalog. Only this package's own payload is omitted, avoiding a self-referential hash.

Types

type Bundle

type Bundle struct {
	InputSHA256     string
	Producer        string
	Sectors, Solids []int // -1 means no environment; otherwise an explicit probe ID.
	Probes          []Probe
}

func Decode

func Decode(data []byte) (Bundle, error)

func (*Bundle) Validate

func (bundle *Bundle) Validate() error

func (*Bundle) ValidateSource

func (bundle *Bundle) ValidateSource(envelope level.Envelope, document *world.Document) error

type Probe

type Probe struct {
	ID                int
	Origin, Low, High [3]float32
	Image             []byte // Straight RGBA QOI, six faces in +X,-X,+Y,-Y,+Z,-Z order.
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL