Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
9ba9a13
[Patch] Fixed area light math
untoldengine Jun 13, 2026
fb4f654
[Patch] Clamped spotlight parameters
untoldengine Jun 13, 2026
23b56b7
[Patch] Clamped point lights parameters
untoldengine Jun 13, 2026
827fe4a
[Patch] Fixed cascade shadows
untoldengine Jun 14, 2026
38afbb5
[Patch] Import-export light from Blender
untoldengine Jun 14, 2026
576cda3
[Patch] New API for directional light
untoldengine Jun 14, 2026
87e1300
[Chores] Formatted files
untoldengine Jun 14, 2026
f934519
[Test] Updated rendering tests
untoldengine Jun 14, 2026
921836a
[Test] Updated reference images
untoldengine Jun 14, 2026
f61dc94
[Patch] Color correction fix
untoldengine Jun 15, 2026
1e6ecd3
[Patch] Fixed issue with dir light not getting set
untoldengine Jun 15, 2026
d8bf64e
[Patch] Added scene author lights and camera to tiles
untoldengine Jun 15, 2026
03d9fdf
[Demo] set paths to load in sandbox
untoldengine Jun 15, 2026
9ba83f0
[Chores] Formatted files
untoldengine Jun 15, 2026
d53f419
[Test] Added test coverage for export/import light/camera
untoldengine Jun 15, 2026
aeabd95
[Patch] make runtime camera lookup deterministic when multiple Camera…
untoldengine Jun 16, 2026
e5ce728
[Demo] Add DemoGame local scene authored import toggle
untoldengine Jun 16, 2026
6dd5923
[Patch] Include lights and cameras in Blender add-on exports
untoldengine Jun 16, 2026
b557f8c
[Patch] added function to load authored scene
untoldengine Jun 16, 2026
e688c9b
[Patch] Fixed area light import math
untoldengine Jun 16, 2026
e650a81
[Patch] Fixed area light direction
untoldengine Jun 17, 2026
80c88d1
[Docs] Updated documentation
untoldengine Jun 18, 2026
809c18b
[Patch] Fixed roughness and metallic export
untoldengine Jun 18, 2026
b08b957
[Chores] Formatted files
untoldengine Jun 18, 2026
4ec3854
[Patch] Add user custom scene channels and prefix mapping
untoldengine Jun 18, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sources/CShaderTypes/ShaderTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,7 @@ typedef struct{

typedef struct{
simd_float4 attenuation;
// Emission direction from the spot light into the scene.
simd_float3 direction;
simd_float3 position;
simd_float3 color;
Expand All @@ -66,6 +67,7 @@ typedef struct{
typedef struct{
simd_float3 position;
simd_float3 color;
// LTC polygon/front normal used to choose rectangle winding in the area-light shader.
simd_float3 forward;
simd_float3 right;
simd_float3 up;
Expand Down Expand Up @@ -299,6 +301,7 @@ typedef enum RenderTargets{
typedef struct{
simd_float4 baseColor;
simd_int4 hasTexture; //x=hasbasecolor,y=hasroughmap, z=hasmetalmap
simd_int4 textureChannels; //x=roughness channel, y=metallic channel; 0=r,1=g,2=b,3=a
simd_float4 edgeTint;
simd_float3 emmissive;
float roughness;
Expand Down
6 changes: 6 additions & 0 deletions Sources/DemoGame/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,12 @@
demoState.onLoadTiledScene = { [weak self] sceneID, url, completion in
self?.gameScene.loadTileScene(sceneID: sceneID, url: url, completion: completion)
}
demoState.onLoadSceneAuthoredFile = { [weak self] path, completion in
self?.gameScene.loadSceneAuthoredFile(path: path, completion: completion)
}
demoState.onLoadSceneAuthoredURL = { [weak self] url, completion in
self?.gameScene.loadSceneAuthoredURL(url: url, completion: completion)
}
demoState.onBatchingChanged = { [weak self] enabled in
self?.gameScene.setBatching(enabled)
}
Expand Down
11 changes: 11 additions & 0 deletions Sources/DemoGame/DemoHUD.swift
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,11 @@
Spacer(minLength: 0)
}

Toggle("Scene Authored", isOn: $state.localSceneAuthoredEnabled)
.toggleStyle(.checkbox)
.padding(.leading, 100)
.disabled(state.isLoading)

Divider()

sectionLabel("CONTROLS")
Expand Down Expand Up @@ -539,6 +544,9 @@
if success {
state.selectedPostFXPreset = .neutral
state.applySelectedPostFXPreset()
if state.localSceneAuthoredEnabled {
state.onLoadSceneAuthoredFile?(path) { _ in }
}
}
finishLocalImport(url: url, accessing: accessing, success: success, streamingEnabled: false)
}
Expand All @@ -558,6 +566,9 @@
if success {
state.selectedPostFXPreset = .neutral
state.applySelectedPostFXPreset()
if state.localSceneAuthoredEnabled {
state.onLoadSceneAuthoredURL?(url) { _ in }
}
}
finishLocalImport(url: url, accessing: accessing, success: success, streamingEnabled: success)
}
Expand Down
4 changes: 4 additions & 0 deletions Sources/DemoGame/DemoState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,8 @@
remoteScenes.first { $0.id == selectedRemoteSceneID }
}

var localSceneAuthoredEnabled: Bool = false

// MARK: - Features

var batchingEnabled: Bool = false {
Expand Down Expand Up @@ -229,6 +231,8 @@

var onLoadFile: ((String, @escaping @Sendable (Bool) -> Void) -> Void)?
var onLoadTiledScene: ((String, URL, @escaping @Sendable (Bool) -> Void) -> Void)?
var onLoadSceneAuthoredFile: ((String, @escaping @Sendable (Bool) -> Void) -> Void)?
var onLoadSceneAuthoredURL: ((URL, @escaping @Sendable (Bool) -> Void) -> Void)?
var onBatchingChanged: ((Bool) -> Void)?
var onStreamingChanged: ((Bool, Double, Double) -> Void)?
var onLodDebugChanged: ((Bool) -> Void)?
Expand Down
27 changes: 24 additions & 3 deletions Sources/DemoGame/GameScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,8 @@
let light = createEntity()
setEntityName(entityId: light, name: "Directional Light")
createDirLight(entityId: light)

setDirectionalLight(.active(light))
setCamera(.active(gameCamera))

setRendering(.environment(.ibl(true)))
Expand All @@ -84,14 +86,21 @@
extension GameScene {
/// Loads a USDZ file as an always-resident asset, replacing whatever was previously loaded.
/// The previously loaded entity is destroyed; the scene camera and light are preserved.
func loadFile(path: String, completion: @escaping @Sendable (Bool) -> Void) {
func loadFile(
path: String,
completion: @escaping @Sendable (Bool) -> Void
) {
prepareForMeshLoad { [weak self] in
guard let self else { return }

let entity = createEntity()
setEntityName(entityId: entity, name: path)

setEntityMeshAsync(entityId: entity, filename: path, withExtension: "untold") { [weak self] success in
setEntityMeshAsync(
entityId: entity,
filename: path,
withExtension: "untold"
) { [weak self] success in
guard let self else { return }
loadedEntity = success ? entity : nil
loadedContent = success ? .mesh(entity) : .none
Expand All @@ -106,7 +115,11 @@
}

/// Loads a tiled scene from a local or remote manifest URL.
func loadTileScene(sceneID: String, url: URL, completion: @escaping @Sendable (Bool) -> Void) {
func loadTileScene(
sceneID: String,
url: URL,
completion: @escaping @Sendable (Bool) -> Void
) {
// Destroy any previously loaded tiled scene before registering a new one.
if case let .tiledScene(oldRoot) = loadedContent {
destroyEntity(entityId: oldRoot)
Expand All @@ -132,6 +145,14 @@
}
}

func loadSceneAuthoredFile(path: String, completion: @escaping @Sendable (Bool) -> Void) {
loadSceneAuthored(filename: path, withExtension: "untold", completion: completion)
}

func loadSceneAuthoredURL(url: URL, completion: @escaping @Sendable (Bool) -> Void) {
loadSceneAuthored(url: url, completion: completion)
}

private func prepareForMeshLoad(completion: @escaping () -> Void) {
clearSceneBatches()
setGeometryStreaming(.enabled(false))
Expand Down
37 changes: 22 additions & 15 deletions Sources/Sandbox/GameScene.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,26 @@
// Uncomment to render a simple mesh.
/*
let entity = createEntity()
setEntityMeshAsync(entityId: entity, filename: "/path/to/mesh", withExtension: "untold") { success in

setEntityMeshAsync(entityId: entity, filename: "/path/to/file", withExtension: "untold") { success in
setEntityName(entityId: entity, name: "redplayer")

//load animation
setEntityAnimations(entityId: entity, filename: "/path/to/animation", withExtension: "untold", name: "running")

changeAnimation(entityId: entity, name: "running")

setSceneReady(true)

if success {
loadSceneAuthored(filename: "/path/to/file", withExtension: "untold")
}
setSceneReady(success)
}
*/
*/
/*
let sceneRoot = createEntity()
setEntityStreamScene(
entityId: sceneRoot,
url: URL(fileURLWithPath: "/path/to/local/json")
) { success in
if success {
loadSceneAuthored(url: URL(fileURLWithPath: "/path/to/local/json"))
}
setSceneReady(success)
}
*/

// Uncomment to render a streamed scene
/*
Expand All @@ -62,12 +69,12 @@
let camera = createEntity()
setEntityName(entityId: camera, name: "Main Camera")
createGameCamera(entityId: camera)
CameraSystem.shared.activeCamera = camera
setCamera(.active(camera))
setOrbitOffset(entityId: camera, uTargetOffset: Constants.orbitTargetOffset)

let light = createEntity()
setEntityName(entityId: light, name: "Directional Light")
createDirLight(entityId: light)
// let light = createEntity()
// setEntityName(entityId: light, name: "Directional Light")
// createDirLight(entityId: light)
}

func update(deltaTime _: Float) {
Expand Down
152 changes: 152 additions & 0 deletions Sources/UntoldEngine/AssetFormat/UntoldBinaryCodable.swift
Original file line number Diff line number Diff line change
Expand Up @@ -331,6 +331,158 @@ extension UntoldTextureRefRecordV1: UntoldBinaryEncodable, UntoldBinaryDecodable
}
}

extension UntoldLightRecordV1: UntoldBinaryEncodable, UntoldBinaryDecodable {
public func encode(to writer: UntoldBinaryWriter) {
writer.writeUInt32LE(entityId)
writer.writeUInt32LE(nameOffset)
writer.writeUInt32LE(lightType.rawValue)
writer.writeUInt32LE(flags)
writer.writeFloat32LE(color.x)
writer.writeFloat32LE(color.y)
writer.writeFloat32LE(color.z)
writer.writeFloat32LE(intensity)
writer.writeFloat32LE(position.x)
writer.writeFloat32LE(position.y)
writer.writeFloat32LE(position.z)
writer.writeFloat32LE(radius)
writer.writeFloat32LE(direction.x)
writer.writeFloat32LE(direction.y)
writer.writeFloat32LE(direction.z)
writer.writeFloat32LE(falloff)
writer.writeFloat32LE(right.x)
writer.writeFloat32LE(right.y)
writer.writeFloat32LE(right.z)
writer.writeFloat32LE(innerCone)
writer.writeFloat32LE(up.x)
writer.writeFloat32LE(up.y)
writer.writeFloat32LE(up.z)
writer.writeFloat32LE(outerCone)
writer.writeFloat32LE(areaSize.x)
writer.writeFloat32LE(areaSize.y)
writer.writeFloat32LE(sourcePower)
writer.writeFloat32LE(sourceExposure)
writer.writeMatrix4x4LE(localTransform)
}

public static func decode(from reader: UntoldBinaryReader) throws -> UntoldLightRecordV1 {
let entityId = try reader.readUInt32LE()
let nameOffset = try reader.readUInt32LE()
let lightTypeRaw = try reader.readUInt32LE()
guard let lightType = UntoldLightType(rawValue: lightTypeRaw) else {
throw UntoldValidationError.unsupportedEnumValue
}

return try UntoldLightRecordV1(
entityId: entityId,
nameOffset: nameOffset,
lightType: lightType,
flags: reader.readUInt32LE(),
color: SIMD3<Float>(
reader.readFloat32LE(),
reader.readFloat32LE(),
reader.readFloat32LE()
),
intensity: reader.readFloat32LE(),
position: SIMD3<Float>(
reader.readFloat32LE(),
reader.readFloat32LE(),
reader.readFloat32LE()
),
radius: reader.readFloat32LE(),
direction: SIMD3<Float>(
reader.readFloat32LE(),
reader.readFloat32LE(),
reader.readFloat32LE()
),
falloff: reader.readFloat32LE(),
right: SIMD3<Float>(
reader.readFloat32LE(),
reader.readFloat32LE(),
reader.readFloat32LE()
),
innerCone: reader.readFloat32LE(),
up: SIMD3<Float>(
reader.readFloat32LE(),
reader.readFloat32LE(),
reader.readFloat32LE()
),
outerCone: reader.readFloat32LE(),
areaSize: SIMD2<Float>(
reader.readFloat32LE(),
reader.readFloat32LE()
),
sourcePower: reader.readFloat32LE(),
sourceExposure: reader.readFloat32LE(),
localTransform: reader.readMatrix4x4LE()
)
}
}

extension UntoldCameraRecordV1: UntoldBinaryEncodable, UntoldBinaryDecodable {
public func encode(to writer: UntoldBinaryWriter) {
writer.writeUInt32LE(entityId)
writer.writeUInt32LE(nameOffset)
writer.writeUInt32LE(flags)
writer.writeUInt32LE(reserved0)
writer.writeFloat32LE(position.x)
writer.writeFloat32LE(position.y)
writer.writeFloat32LE(position.z)
writer.writeFloat32LE(fovYDegrees)
writer.writeFloat32LE(forward.x)
writer.writeFloat32LE(forward.y)
writer.writeFloat32LE(forward.z)
writer.writeFloat32LE(nearClip)
writer.writeFloat32LE(up.x)
writer.writeFloat32LE(up.y)
writer.writeFloat32LE(up.z)
writer.writeFloat32LE(farClip)
writer.writeFloat32LE(right.x)
writer.writeFloat32LE(right.y)
writer.writeFloat32LE(right.z)
writer.writeFloat32LE(aspectRatio)
writer.writeMatrix4x4LE(localTransform)
}

public static func decode(from reader: UntoldBinaryReader) throws -> UntoldCameraRecordV1 {
let entityId = try reader.readUInt32LE()
let nameOffset = try reader.readUInt32LE()
let flags = try reader.readUInt32LE()
let reserved0 = try reader.readUInt32LE()
var record = try UntoldCameraRecordV1(
entityId: entityId,
nameOffset: nameOffset,
flags: flags,
position: SIMD3<Float>(
reader.readFloat32LE(),
reader.readFloat32LE(),
reader.readFloat32LE()
),
fovYDegrees: reader.readFloat32LE(),
forward: SIMD3<Float>(
reader.readFloat32LE(),
reader.readFloat32LE(),
reader.readFloat32LE()
),
nearClip: reader.readFloat32LE(),
up: SIMD3<Float>(
reader.readFloat32LE(),
reader.readFloat32LE(),
reader.readFloat32LE()
),
farClip: reader.readFloat32LE(),
right: SIMD3<Float>(
reader.readFloat32LE(),
reader.readFloat32LE(),
reader.readFloat32LE()
),
aspectRatio: reader.readFloat32LE(),
localTransform: reader.readMatrix4x4LE()
)
record.reserved0 = reserved0
return record
}
}

extension UntoldSkeletonRecordV1: UntoldBinaryEncodable, UntoldBinaryDecodable {
public func encode(to writer: UntoldBinaryWriter) {
writer.writeUInt32LE(entityId)
Expand Down
Loading
Loading