Documentation
¶
Overview ¶
Package render3d owns meshes, camera settings, lights, deformation, shadows, post-processing, and the 3D extract/prepare/sort/draw pipeline. Register binds its typed camera component to the common scene camera and input runtime.
Index ¶
- func DrawSystem(name string) ecs.SystemConfig
- func ExtractSystem(name string) ecs.SystemConfig
- func PrepareSystem(name string) ecs.SystemConfig
- func QueueMaterialUploads(queue *graphics.UploadQueue, world *ecs.World, entity ecs.Entity)
- func Register(world *ecs.World)
- func SortSystem(name string) ecs.SystemConfig
- func UpdateDeformationsSystem(name string) ecs.SystemConfig
- type AmbientLight
- type AreaLight
- type AreaLightShape
- type Camera
- type Deformation
- type DirectionalLight
- type Environment
- type FogMode
- type FogSettings
- type GroundPlane
- type Material
- type Mesh
- type NoAmbientOcclusion
- type NoScreenReflection
- type NoShadow
- type PointLight
- type PunctualShadowSettings
- type Quality
- type SSAOSettings
- type SSRSettings
- type ShadowSettings
- type SpotLight
- type SpotLightShape
- type ViewLighting
- type World
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DrawSystem ¶
func DrawSystem(name string) ecs.SystemConfig
func ExtractSystem ¶
func ExtractSystem(name string) ecs.SystemConfig
func PrepareSystem ¶
func PrepareSystem(name string) ecs.SystemConfig
PrepareSystem prepares GPU resources and queues main-view meshes into opaque and transparent phases in the same traversal.
func QueueMaterialUploads ¶
QueueMaterialUploads resolves registered generic materials and submesh slots with the same readers as rendering, without acquiring GPU handles.
func Register ¶
Register enables 3D camera extraction and submission in this world. Repeated registration reuses the renderer, material readers, and camera binding.
func SortSystem ¶
func SortSystem(name string) ecs.SystemConfig
func UpdateDeformationsSystem ¶
func UpdateDeformationsSystem(name string) ecs.SystemConfig
UpdateDeformationsSystem resolves optional joint and rigid node entities into model-space matrices before ExtractSystem runs.
Types ¶
type AmbientLight ¶
func NewAmbientLight ¶
func NewAmbientLight() *AmbientLight
type AreaLight ¶
type AreaLight struct {
Unit graphics.LightUnit
Shape AreaLightShape
Color graphics.ColorRGBA
Intensity float32
Range float32
Width float32
Height float32
Radius float32
}
AreaLight uses nits internally. Rectangle/disc emit towards local -Z; tube emits in all directions along local X. Width is tube length; Radius is disc radius. Dimensions are independent of the entity's transform scale.
func NewAreaLight ¶
func NewAreaLight() AreaLight
func (AreaLight) ProjectedArea ¶
type AreaLightShape ¶
type AreaLightShape string
const ( AreaRectangle AreaLightShape = "rectangle" AreaDisc AreaLightShape = "disc" AreaTube AreaLightShape = "tube" )
type Camera ¶
type Camera struct {
Target *render.RenderTarget
ToneMapping graphics.ToneMapping
Quality Quality
Exposure graphics.Exposure
Fog FogSettings
SSAO SSAOSettings
SSR SSRSettings
DepthClear float32
FXAA bool
ViewMode render.RenderViewMode
}
Camera adds 3D output and lighting settings to the common scene.Camera. Register enables extraction and input routing for this component.
type Deformation ¶
type Deformation struct {
MorphWeights []float32
JointEntities []ecs.Entity
InverseBind []mgl32.Mat4
JointMatrices []mgl32.Mat4
// NodeMatrices maps baked rigid geometry from its initial model space to
// its animated model space. Skinned submeshes use JointMatrices instead.
NodeEntities []ecs.Entity
NodeInverseBind []mgl32.Mat4
NodeMatrices []mgl32.Mat4
// contains filtered or unexported fields
}
Deformation stores reusable deformation state. CPU renderers reuse vertices here, while GPU-capable renderers upload the joint and morph data without constructing dynamic vertex geometry.
type DirectionalLight ¶
type DirectionalLight struct {
Shadows ShadowSettings
Color graphics.ColorRGBA
Illuminance float32
}
func NewDirectionalLight ¶
func NewDirectionalLight() DirectionalLight
func (DirectionalLight) Validate ¶
func (l DirectionalLight) Validate() error
type Environment ¶
type Environment struct {
Atlas *graphics.Texture
// Panorama displays the original RGBE image independently of the IBL atlas.
Panorama *graphics.Texture
// Sky replaces only the visible background; Atlas still supplies lighting.
Sky *graphics.SkyRadiance
Intensity float32
Rotation float32
Exposure float32
Encoding render.EnvironmentEncoding
Background bool
}
Environment is attached to a camera. Atlas contains eight lighting tiles; Panorama is an optional original-resolution background. Both are loaded as linear RGBA8 without mipmaps or premultiplication. Exposure applies to lit output; Rotation applies to both panorama and atlas.
type FogSettings ¶
type FogSettings struct {
Mode FogMode
Color graphics.ColorRGBA
Brightness float32
Start float32
End float32
Density float32
Enabled bool
}
FogSettings blends scene radiance toward an sRGB color scaled by Brightness in nits before exposure. Distances are meters; Density is inverse meters. Sky, UI and custom fragment stages retain their own atmosphere behavior.
func NewFogSettings ¶
func NewFogSettings() FogSettings
func (FogSettings) Validate ¶
func (s FogSettings) Validate() error
type GroundPlane ¶
GroundPlane adds a shadow-receiving ground to one view. It is excluded from picking and shadow casting. Size <= 0 disables it.
type Material ¶
type Material[T graphics.Material3D] struct { // Materials uses the indices in Mesh.Submeshes. Material supplies the // material for unpartitioned geometry or a slot without an entry. Material *T Materials []T }
Material binds typed material data to a mesh and its optional submeshes.
type NoAmbientOcclusion ¶
type NoAmbientOcclusion struct{}
NoAmbientOcclusion excludes first-person meshes and effects from the depth prepass and from receiving screen-space ambient occlusion.
type NoScreenReflection ¶
type NoScreenReflection struct{}
NoScreenReflection disables receiving SSR, while keeping the mesh visible to other reflectors. Transparent and custom materials never receive SSR.
type NoShadow ¶
type NoShadow struct{}
NoShadow excludes first-person meshes and effects from both shadow casting and receiving. Ordinary meshes cast and receive shadows by default.
type PointLight ¶
type PointLight struct {
Unit graphics.LightUnit
Shadows PunctualShadowSettings
Color graphics.ColorRGBA
Intensity float32
LuxDistance float32
Range float32
Radius float32
}
PointLight is an isotropic source. Range, Radius and LuxDistance are meters.
func NewPointLight ¶
func NewPointLight() PointLight
func (PointLight) Candela ¶
func (l PointLight) Candela() float32
func (PointLight) Validate ¶
func (l PointLight) Validate() error
type PunctualShadowSettings ¶
type PunctualShadowSettings struct {
Resolution int
Near float32
Bias float32
NormalBias float32
Enabled bool
}
PunctualShadowSettings configures point and spot shadow projections in meters.
func NewPunctualShadowSettings ¶
func NewPunctualShadowSettings() PunctualShadowSettings
func (PunctualShadowSettings) Validate ¶
func (s PunctualShadowSettings) Validate(lightRange float32) error
type Quality ¶
type Quality string
Quality caps authored effects. It never enables an effect that the camera or light has disabled. A world resource supplies the default tier; a non-empty Camera.Quality overrides it for that camera.
type SSAOSettings ¶
type SSAOSettings struct {
Enabled bool
Radius float32
Bias float32
Strength float32
ResolutionScale float32
Samples int
}
SSAOSettings controls screen-space ambient occlusion for a single camera. Radius and Bias are world distances. ResolutionScale is 0.25–1; Samples selects an 8, 16 or 32 tap spiral. The zero value disables the prepass.
func NewSSAOSettings ¶
func NewSSAOSettings() SSAOSettings
func (SSAOSettings) Validate ¶
func (s SSAOSettings) Validate() error
type SSRSettings ¶
type SSRSettings struct {
Enabled bool
MaxDistance float32
Thickness float32
Strength float32
MaxRoughness float32
EdgeFade float32
Steps int
}
SSRSettings controls single-bounce screen-space reflections. Distances are in meters. Rough reflections fade into IBL; no temporal history is retained.
func NewSSRSettings ¶
func NewSSRSettings() SSRSettings
func (SSRSettings) Validate ¶
func (s SSRSettings) Validate() error
type ShadowSettings ¶
type ShadowSettings struct {
Resolution int
Cascades int
Radius float32
Depth float32
Bias float32
NormalBias float32
Distance float32
SplitLambda float32
CascadeBlend float32
Enabled bool
}
ShadowSettings configures directional shadows. A single map uses Radius; 2–4 cascades fit camera frustum slices out to Distance. Depth adds coverage for off-camera casters. Resolution is the requested size of each atlas tile.
func NewShadowSettings ¶
func NewShadowSettings() ShadowSettings
func (ShadowSettings) Validate ¶
func (s ShadowSettings) Validate() error
type SpotLight ¶
type SpotLight struct {
Shape SpotLightShape
Unit graphics.LightUnit
Shadows PunctualShadowSettings
Color graphics.ColorRGBA
Radius float32
Range float32
LuxDistance float32
Intensity float32
InnerConeAngle float32
OuterConeAngle float32
AspectRatio float32
Width float32
Height float32
Reflector bool
RangeAttenuation bool // box only; punctual lights always attenuate
}
SpotLight emits along local -Z. Cone angles are full angles in radians, matching HDRP's Inner/Outer Angle after converting degrees to radians.
func NewSpotLight ¶
func NewSpotLight() SpotLight
func (SpotLight) PhysicalIntensity ¶
func (SpotLight) PyramidTangents ¶
func (SpotLight) SolidAngle ¶
type SpotLightShape ¶
type SpotLightShape string
const ( SpotCone SpotLightShape = "cone" SpotPyramid SpotLightShape = "pyramid" SpotBox SpotLightShape = "box" )
type ViewLighting ¶
type ViewLighting struct {
Sun DirectionalLight
ShadowResolution int // zero keeps the light's resolution
Ambient AmbientLight
Direction mgl32.Vec3
Override bool
DisableShadows bool
}
ViewLighting optionally replaces scene lights for a single camera, without modifying entities in the scene. The zero value uses the scene's lights.
type World ¶
type World struct {
// contains filtered or unexported fields
}
World stores per-camera frame snapshots. Simulation components are read only during Extract; prepare, queue, sort, and draw use these snapshots.
func NewWorld ¶
func NewWorld() *World
NewWorld creates renderer-owned storage with the built-in standard material. Register installs this resource automatically when it is absent.
func (*World) Dispose ¶
Dispose releases render-owned view caches. Scene meshes and camera targets remain owned by their respective assets and callers.
func (*World) RegisterMaterial ¶
func (state *World) RegisterMaterial[T graphics.Material3D]()
RegisterMaterial enables extraction of Material[T] components. Like Bevy's MaterialPlugin<T>, each custom material type is registered once.