Files
aego/modules/render2d/lighting_components.go
sanspie 50be5c04bc
ci-platforms / darwin amd64 smoke (push) Skipped
GitHub / linux amd64 native GitHub-hosted native CI: success
ci-platforms / windows amd64 smoke (push) Skipped
GitHub / windows amd64 native GitHub-hosted native CI: success
GitHub / darwin arm64 native GitHub-hosted native CI: success
GitHub / darwin amd64 native GitHub-hosted native CI: success
ci / checks (push) Failing after 1h21m34s
ci / native-authoring (push) Skipped
ci-platforms / darwin arm64 smoke (push) Skipped
github-native / gitea-pending (push) Skipped
github-native / darwin amd64 native (push) Skipped
github-native / linux amd64 native (push) Skipped
github-native / windows amd64 native (push) Skipped
github-native / darwin arm64 native (push) Skipped
github-native / gitea-result (push) Skipped
ci / build (amd64, linux, ubuntu-24.04) (push) Successful in 12m4s
ci / release (push) Skipped
Stage 12.5: Art Workspace and asset authoring
Add dockable Art tools, animation and previews, guarded asset workflows,
and the Web Asset Studio built on the shared Art Core. Expand English and
Russian documentation, interactive Try scenes, examples and editor icons.

Add audio waveform navigation, source analysis, guarded previews and a
browser Worker mixer. Preserve source changes and recovery with bounded
checks, and strengthen native, browser and interoperability CI.

Prepare version 0.12.5 and manually built native artifact candidates.
Fix the production site image demo build dependency.
Reuse immutable scene indices when capturing keyframes.
Wait for real Persist save/load completion in component tests.
Stabilize browser Game View captures outside pointer hover.
Aseprite interchange and persistent Audio EDL recovery remain limited;
the artifact workflow does not publish releases or change stable.
2026-11-15 10:37:50 +03:00

88 lines
3.7 KiB
Go

package render2d
import (
"slices"
"aego/asset"
"aego/core/mathx"
"aego/render/lighting"
"aego/scene"
)
type Light2D struct {
Type lighting.Type `aego:"type"`
Color mathx.Color `aego:"color"`
Intensity float32 `aego:"intensity,min=0"`
Range float32 `aego:"range,min=0.001"`
Height float32 `aego:"height,min=0"`
InnerAngle float32 `aego:"innerAngle,min=0,max=3.1415927"`
OuterAngle float32 `aego:"outerAngle,min=0,max=3.1415927"`
Elevation float32 `aego:"elevation,min=0.001,max=1.5707964"`
Falloff float32 `aego:"falloff,min=0"`
Cookie asset.Ref[asset.Texture] `aego:"cookie,asset=texture,omitempty"`
Layers int64 `aego:"layers"`
ShadowCasterMask int64 `aego:"shadowCasterMask"`
Shadows bool `aego:"shadows"`
ShadowSoftness float32 `aego:"shadowSoftness,min=0"`
Priority int32 `aego:"priority"`
}
type OccluderSource uint8
const (
OccluderPolygon OccluderSource = iota
OccluderShapeProvider
OccluderSpriteAlpha
)
type LightOccluder2D struct {
Source OccluderSource `aego:"source"`
Polygon []mathx.Vec2 `aego:"polygon"`
Closed bool `aego:"closed"`
CullMode lighting.CullMode `aego:"cullMode"`
Layers int64 `aego:"layers"`
ShapeNode scene.NodeRef `aego:"shapeNode,omitempty"`
Shape string `aego:"shape,omitempty"`
}
func cloneLightOccluder(dst, src *LightOccluder2D) {
*dst = *src
dst.Polygon = slices.Clone(src.Polygon)
}
type LightingEnvironment2D struct {
Camera scene.NodeRef `aego:"camera,omitempty"`
AmbientColor mathx.Color `aego:"ambientColor"`
AmbientIntensity float32 `aego:"ambientIntensity,min=0"`
ColorMode lighting.ColorMode `aego:"colorMode"`
Exposure float32 `aego:"exposure,min=0.001"`
ShadowResolution int32 `aego:"shadowResolution,min=64,max=2048"`
MaxShadowedLights int32 `aego:"maxShadowedLights,min=0,max=16"`
}
func DefaultLight2D() Light2D {
return Light2D{Type: lighting.Point, Color: mathx.Color{R: 1, G: 1, B: 1, A: 1}, Intensity: 1, Range: 5, Height: 1,
InnerAngle: mathx.Pi / 8, OuterAngle: mathx.Pi / 4, Elevation: mathx.Pi / 4, Falloff: 2, Layers: -1, ShadowCasterMask: -1}
}
func DefaultLightOccluder2D() LightOccluder2D {
return LightOccluder2D{Closed: true, Layers: -1, Polygon: []mathx.Vec2{{X: -.5, Y: -.5}, {X: .5, Y: -.5}, {X: .5, Y: .5}, {X: -.5, Y: .5}}}
}
func DefaultLightingEnvironment2D() LightingEnvironment2D {
e := lighting.DefaultEnvironment()
return LightingEnvironment2D{AmbientColor: e.Ambient, AmbientIntensity: e.AmbientIntensity, ColorMode: e.ColorMode, Exposure: e.Exposure,
ShadowResolution: int32(e.ShadowResolution), MaxShadowedLights: int32(e.MaxShadowedLights)}
}
func (l *Light2D) descriptor() lighting.Light {
return lighting.Light{Type: l.Type, Direction: mathx.Vec2{X: 1}, Color: l.Color, Intensity: l.Intensity, Range: l.Range, Height: l.Height,
InnerAngle: l.InnerAngle, OuterAngle: l.OuterAngle, Elevation: l.Elevation, Falloff: l.Falloff, Layers: uint64(l.Layers),
ShadowCasterMask: uint64(l.ShadowCasterMask), Shadows: l.Shadows, ShadowSoftness: l.ShadowSoftness, Priority: l.Priority}
}
func (e *LightingEnvironment2D) descriptor() lighting.Environment {
return lighting.Environment{Ambient: e.AmbientColor, AmbientIntensity: e.AmbientIntensity, ColorMode: e.ColorMode,
Exposure: e.Exposure, ShadowResolution: int(e.ShadowResolution), MaxShadowedLights: int(e.MaxShadowedLights)}
}