Documentation
¶
Overview ¶
Package worldlightmap defines the independently versioned, build-generated static receiver layout. It has no renderer or private engine dependencies.
Index ¶
- Constants
- Variables
- func Encode(layout Layout, document *world.Document) ([]byte, error)
- func EncodePrebake(pair PrebakePair, layout Layout, document *world.Document) ([]byte, error)
- func GeometryDigest(document *world.Document) (string, error)
- func OfflineDenoiseMode(producer string) (string, error)
- func OfflineDenoiseProducer(mode string) (string, error)
- func OfflineRGBMRange(layout Layout, document *world.Document, bounces int) (float64, error)
- func OfflineSurfaceDigest(document *world.Document) (string, error)
- func Validate(layout *Layout, document *world.Document) error
- type Binding
- type Chart
- type Layout
- type OfflineBakeInputs
- type Options
- type Page
- type PrebakeManifest
- type PrebakePair
- type RuntimeBake
- type Surface
Constants ¶
const ( Schema = "karty.world-lightmaps@1" Algorithm = uint32(1) EntryName = "@world/lightmaps/layout" MetadataKey = "kartyWorldLightmaps" Feature = cartridge.FeatureWorldLightmapsV1 MaxEncodedSize = 8 * 1024 * 1024 MaxCharts = 8192 MaxTexels = 1024 * 1024 MaxBakeLights = 8 PointVisibilityEncoding = "point-visibility@1" DirectRNMEncoding = "direct-rnm3@1" )
const ( OfflinePrebakeAlgorithm = 2 OfflinePrebakeProducer = "cpu-rnm3-pathtrace@1" MaxOfflineSamples = 256 MaxOfflineBounces = 4 MaxDiffuseReflectance = .95 )
const ( PrebakeSchema = "karty.world-lightmap-prebake@1" PrebakeAlgorithm = 1 PrebakeEntryName = "@world/lightmaps/prebake" PrebakeImageEntryName = "@world/lightmaps/prebake-rnm3" PrebakeMetadataKey = "kartyWorldLightmapPrebake" PrebakeFeature = cartridge.FeatureWorldLightmapsPrebakedV1 MaxPrebakeManifestSize = 16 * 1024 MaxPrebakeImageSize = level.MaxEntrySize )
Variables ¶
var ErrLayout = errors.New("world lightmap layout is invalid")
Functions ¶
func EncodePrebake ¶
EncodePrebake returns a canonical manifest only after complete pair validation.
func GeometryDigest ¶
GeometryDigest includes stable semantic identity, boundary topology and elevation geometry. Actor state, lighting, materials and UVs do not affect it.
func OfflineDenoiseMode ¶ added in v0.0.9
OfflineDenoiseMode rejects unknown producer versions before image allocation.
func OfflineDenoiseProducer ¶ added in v0.0.9
OfflineDenoiseProducer versions the complete filter, including its preset. Empty and off preserve the original producer and its exact manifest bytes.
func OfflineRGBMRange ¶
OfflineRGBMRange reserves a conservative finite range for direct lighting plus bounded diffuse transport. Each bounce attenuates maximum radiance by MaxDiffuseReflectance; three coefficient lobes need the same factor as the direct producer. This is a storage bound, not a promised illumination level.
func OfflineSurfaceDigest ¶
OfflineSurfaceDigest binds material identities and authored projection data in addition to geometry. Actor state and artistic ambient are not transport inputs. The original albedo pixels are checked separately by the public CLI.
Types ¶
type Binding ¶
type Binding struct {
Kind string `json:"kind"`
Index int `json:"index"`
Edge int `json:"edge"`
Chart int `json:"chart"`
}
Binding associates a world surface with its receiver chart. Index addresses the world sector or solid array. Edge is -1 for caps, and addresses the directed wall or footprint edge otherwise. Chart -1 explicitly marks a wall with no opaque receiver. Array order is semantic discovery order.
type Chart ¶
type Chart struct {
ID int `json:"id"`
Page int `json:"page"`
Rect [4]int `json:"rect"`
ReceiverRect [4]int `json:"receiver_rect"`
Normal world.Vec3 `json:"normal"`
Tangent world.Vec3 `json:"tangent"`
Bitangent world.Vec3 `json:"bitangent"`
UPlane [4]float64 `json:"u_plane"`
VPlane [4]float64 `json:"v_plane"`
}
Chart describes a receiver's atlas placement and basis. Rectangles are [minimumX,minimumY,maximumX,maximumY] in page pixels, maximums exclusive. Plane values are normalized page coordinates.
type Layout ¶
type Layout struct {
Schema string `json:"schema"`
Algorithm uint32 `json:"algorithm"`
GeometrySHA256 string `json:"geometry_sha256"`
TexelsPerUnit float64 `json:"texels_per_unit"`
Padding int `json:"padding"`
Pages []Page `json:"pages"`
Charts []Chart `json:"charts"`
Bindings []Binding `json:"bindings"`
RuntimeBake *RuntimeBake `json:"runtime_bake,omitempty"`
}
func Compile ¶
Compile discovers and packs unique receiver coordinates without triangulating sectors or importing runtime code. Algorithm 1 merges only coplanar floors and ceilings across ordinary reciprocal portals, never across transformed or disconnected spaces. Walls and solid sides retain semantic chart identities.
type OfflineBakeInputs ¶
type OfflineBakeInputs struct {
Samples, Bounces int
Seed uint64
ReflectanceSHA256 string
RGBMRange float64
Denoise string // empty/off, low or medium; encoded in the producer identity
}
OfflineBakeInputs identifies the public deterministic CPU producer. Worker count is deliberately absent: changing parallelism must not change pixels.
type PrebakeManifest ¶
type PrebakeManifest struct {
Schema string `json:"schema"`
Algorithm int `json:"algorithm"`
Encoding string `json:"encoding"`
LayoutSHA256 string `json:"layout_sha256"`
BakeSHA256 string `json:"bake_sha256"`
ImageSHA256 string `json:"image_sha256"`
ImageBytes int `json:"image_bytes"`
Width int `json:"width"`
Height int `json:"height"`
RGBMRange float64 `json:"rgbm_range"`
Producer string `json:"producer,omitempty"`
Samples int `json:"samples,omitempty"`
Bounces int `json:"bounces,omitempty"`
Seed uint64 `json:"seed,omitempty"`
ReflectanceSHA256 string `json:"reflectance_sha256,omitempty"`
SurfaceSHA256 string `json:"surface_sha256,omitempty"`
}
PrebakeManifest binds one completed direct RNM image to exact layout and selected lighting inputs. Its canonical JSON is the public manifest entry.
type PrebakePair ¶
type PrebakePair struct {
Manifest PrebakeManifest
Image []byte
}
PrebakePair retains caller ownership of Image; consumers clone it before publication. It is not the wire format: levels carry two fixed data entries.
func DecodePrebake ¶
func DecodePrebake(encoded, image []byte, layout Layout, document *world.Document) (PrebakePair, error)
DecodePrebake rejects unknown, duplicate, missing, null, reordered and noncanonical fields before returning a validated pair. Image remains borrowed.
func NewOfflinePrebake ¶
func NewOfflinePrebake(layout Layout, document *world.Document, image []byte, inputs OfflineBakeInputs) (PrebakePair, error)
NewOfflinePrebake binds a combined direct/indirect image to transport inputs. Format validation verifies identity and QOI integrity, not solver quality. ReflectanceSHA256 commits original decoded albedo; the CLI verifies it against source before packaging. Hosts can verify surface identity, but do not possess those original source images and cannot independently rehash their pixels.
func NewPrebake ¶
NewPrebake validates a completed raw linear RGBM QOI atlas and derives its identity. It neither decodes pixels nor imports runtime or filesystem code.