Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 0 additions & 5 deletions .github/workflows/package-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,6 @@ jobs:
with:
dotnet-version: "10.0.x"

- name: Setup Rust
uses: dtolnay/rust-toolchain@stable

- name: Setup MSVC
uses: ilammy/msvc-dev-cmd@v1

Expand Down Expand Up @@ -116,8 +113,6 @@ jobs:

- name: Build editor
run: nix develop --command bash -c "
rustup toolchain install stable --no-self-update &&
rustup default stable &&
cmake -B build/package -G Ninja
-DCMAKE_C_COMPILER=clang
-DCMAKE_CXX_COMPILER=clang++
Expand Down
31 changes: 31 additions & 0 deletions cmake/vcpkg-ports/nvidia-dlss/nvidia-dlss-config.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
get_filename_component(_nvidia_dlss_prefix "${CMAKE_CURRENT_LIST_DIR}/../.." ABSOLUTE)

if(NOT TARGET nvidia::dlss)
# The NGX loader is a static library, the Super Resolution runtime is loaded by it at run time and never linked
add_library(nvidia::dlss STATIC IMPORTED)
set_target_properties(nvidia::dlss PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${_nvidia_dlss_prefix}/include/ngx"
IMPORTED_CONFIGURATIONS "RELEASE;DEBUG"
MAP_IMPORTED_CONFIG_RELWITHDEBINFO "RELEASE"
MAP_IMPORTED_CONFIG_MINSIZEREL "RELEASE"
)
if(WIN32)
set_target_properties(nvidia::dlss PROPERTIES
IMPORTED_LOCATION_RELEASE "${_nvidia_dlss_prefix}/lib/nvsdk_ngx_d.lib"
IMPORTED_LOCATION_DEBUG "${_nvidia_dlss_prefix}/debug/lib/nvsdk_ngx_d_dbg.lib"
)
else()
set_target_properties(nvidia::dlss PROPERTIES
IMPORTED_LOCATION_RELEASE "${_nvidia_dlss_prefix}/lib/libnvsdk_ngx.a"
IMPORTED_LOCATION_DEBUG "${_nvidia_dlss_prefix}/debug/lib/libnvsdk_ngx.a"
INTERFACE_LINK_LIBRARIES "${CMAKE_DL_LIBS}"
)
endif()
endif()

if(WIN32)
set(NVIDIA_DLSS_RUNTIME_DLL "${_nvidia_dlss_prefix}/bin/nvngx_dlss.dll")
else()
file(GLOB NVIDIA_DLSS_RUNTIME_DLL "${_nvidia_dlss_prefix}/lib/libnvidia-ngx-dlss.so.*")
endif()
unset(_nvidia_dlss_prefix)
70 changes: 70 additions & 0 deletions cmake/vcpkg-ports/nvidia-dlss/portfile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# Binary SDK, every file comes straight from the tagged NVIDIA/DLSS tree and is pinned by its hash
set(_dlss_files
include/nvsdk_ngx.h 007f56bdddd85d8fdc1da81022137afb302bb1c0dba63b5e36f044b63f4d10858bff5f21d80e0d46d156ed34847cca92ec4830deb6ee1424091fbd1a5f4336ed
include/nvsdk_ngx_defs.h 605bbd1465c356516ce02903775306ba61d65a08ec4ba21823dd55486ab71bd75cc15680562946990ba1cc4a7ac1ba78a00c46e8951c9cd3b7565fb4e6f3ee3f
include/nvsdk_ngx_defs_dlssd.h 31d1ba8c8c3abd4601ef34d38f84648ca822226be3fd12e730a7625899f5ce4b137da1b1f90710d17109c886c1868f1d9d51f2498d31df1f508c9b2fda6c06ba
include/nvsdk_ngx_defs_dlssg.h 14ab4cf01c33c52b22f7fb01710913ef40803e47629e2e6af0093f1134ad94dcc4c5ad9d3c85cd81d16d387d9b115937906edbeacfc72f98e3c318e6737b9154
include/nvsdk_ngx_defs_vk.h 288f450317a64fa92e47e8e54b4981506d1bad6854d41d5b742aabf7536ad9d6240c62faab895b8b2763ce917762899cf267e3f2b1db12b4b5e7bd0364bf4919
include/nvsdk_ngx_helpers.h 19f9f8c078ed310606aba35405b6b14f3ae4fa2f8c22dfecef3ff193a0498a2ce27a977a6e95287f17447886dea174a1bbfa3f9a9b766943f7bd7dd59ed0c64f
include/nvsdk_ngx_helpers_cuda.h 79b5f682f89f9937ee5598b13cfe957afb459c3c1e48879376806c5fe2c0c82e8d78b6b49765cbc69ad871acf62bc2e563984f21770e21541eef07775b582119
include/nvsdk_ngx_helpers_d3d.h 274724bf280738a3b3857028c9cea137a92035f14feb2038f9620287d91ba7c0164bf08502b53d60c871c64be6842cbf45618cf925276a698c26dfc88e01c266
include/nvsdk_ngx_helpers_dlssd.h f845cdfcea7f0b635ae628cf697ea9c3032f4e8fb9ce87f52b3a057fb0303b18ca00733599aa393edb451cf9faf3ddf335bb90bc5571c3d641d5163692310289
include/nvsdk_ngx_helpers_dlssd_cuda.h 2339c07310350ba5f6a53332d98078b648571e6850d0b7605c3723c9e3d68be75dd153de1d6b2db168d7aa0b0c38b7a55fc17bc42f79ec96e6cd8f36a2eb9e71
include/nvsdk_ngx_helpers_dlssd_d3d.h db7371481d2f8577fe3e2696eb9d904d7ce7b42dd10ff4523fb4f58f722d22baf1e27d447b13d01761d72f969435508611171e1bfad4200edfbe38c7d65870da
include/nvsdk_ngx_helpers_dlssd_vk.h 338c82cb435304c66585cf3fccd98279d7bf997156b35ff6e8cc95eed6a5ff8a68c0a6b475e7d452811a5649a5fc43776b4029584bb48db48fd1f0ec6f6b4070
include/nvsdk_ngx_helpers_dlssg.h 59d049ad2ecb8c7ce7573624118871ae709fab3c4944941b5273810ebe715aed0e66cc9d44eec5c3c9238d9d95249e4727407859818ba7e5b821ef851fab3fd7
include/nvsdk_ngx_helpers_dlssg_d3d.h c549728b24ccea6865e20bde54ca2fb0d2f486a1e941c27fe7516450ab15de1bd7d5d0a675fc2b4d90e37178dbea2d25b9bca76e25f19afe7a6374e20eeef77a
include/nvsdk_ngx_helpers_dlssg_vk.h 00db89e091cf8203e702089611ffe8474359b3125f481523ab3d2a813f105756f1014dcff26aa507519bd7640368adae793dac8fe42ac532a043c9df4a926239
include/nvsdk_ngx_helpers_vk.h 8051906d9baec8440cfeed0c6b2380cb269622b0a5ece8376e661e22531ade91ae807b4810081cdf4e56dd4aaab1c7a44e0f2eb004be5ef7f572eca10a68307a
include/nvsdk_ngx_loader.h a4661533cccad7db70d589741c0e3c4a8e318c15e9dab5f88cc763f51ae8b959117b11f417d26f1b4b334a25cbeffaf2db24ed0a43b9264b50b42fe1fdcf0302
include/nvsdk_ngx_params.h f8b58c7e42f1948d17de5dad5c25d8341b5cf5dcb160de06de48fa2ef12ae98171e2aba8e3bd7a8e3b5321937c15f9edce7dd6aafc4dbd3588c946247322d2a4
include/nvsdk_ngx_params_dlssd.h d9ddbdbe0ba2f3624daf41dcf3185400ee034e7e0a057df4f9080b63bfd8ce074ef0024f34a80aa4b8c15d163fdbeeabca3da319be681dd06e27311cab2c2a53
include/nvsdk_ngx_params_dlssg.h b446b2594b478cc31fa0d542ee00d83969690075c9c75e8341fc85a3bdad6cad252d52ccaa4ae34f4d673e16f6316bed6ceb69dea1f0085745cd4f758d563dc4
include/nvsdk_ngx_standalone_common.h 7bd34e71dd346650d9194e3792fa0a95a5bef1fb1b514b678abebadbd4385a8ee6bcec75963ef66151dd4ec45220793dcc09bb984dd4af03fdf10abe4da71ac0
include/nvsdk_ngx_standalone_cuda.h 7cefa9dd4c35c8e6ef6213ae90deecd3fe180d5482dac35800bc7c853f76a188841baff1c2e48343590bd6cc0d544337046601ce67b9146883ec28eb33310167
include/nvsdk_ngx_vk.h 610fd37c9d059f939a1d9899662d9c8bf6f9b7059a22efdff78c4ef13466e211c51abef13f8098cb6b8c357a9574de617a1ca41bbe0a30107543d414e6eccecc
LICENSE.txt 72f5b66daad2df8b49098857adc8705dae17b60fcbefb3f8625fd252aa1e5b82dd92cb9824dd052976c73f5a0d7437ca54e593b8e9a9010758aba8887f853390
)
if(VCPKG_TARGET_IS_WINDOWS)
list(APPEND _dlss_files
lib/Windows_x86_64/x64/nvsdk_ngx_d.lib 0809baf904b4246e2ecc35ffc4a5a88155f9c74722427a6b02d0fa85c5a4f24e9d9f759863e6fc3c7038927a14e003215f50215cda4dfbc7b4edb513e5bf58df
lib/Windows_x86_64/x64/nvsdk_ngx_d_dbg.lib 781cbe38adffc42b47b31a047d73e9de7e77242a2ad0d50a787335920985b2b3160f025c509bb9a31750f6094aecb0dd80607e12ed3029ed9bc7e79b33ef4d3b
lib/Windows_x86_64/rel/nvngx_dlss.dll 0e1fbd01ef2374f68e6ff8728f8b394279e58670c02d1f2aadbc8927db97476eb7bc8dca2a3dfd17d13789e6b5ef101850dec836a7fda3e67d379d4a34dfae7d
)
else()
list(APPEND _dlss_files
lib/Linux_x86_64/libnvsdk_ngx.a ed292252d5a7f905f63b85ada671827300cf28d0cc18c6ae7679261289907518500cb5167991e90972cc1f412745dcd674281afaab60b4253095f0939ed1ce4a
lib/Linux_x86_64/rel/libnvidia-ngx-dlss.so.${VERSION} e95c833c790c656d93392d08938616596776581da6b2e88426b75bec1fccba24ea838d3ba472fea22ab2405726a2dba63e2b1b6badc577068df4b388dcb9b7c5
)
endif()

while(_dlss_files)
list(POP_FRONT _dlss_files _path _sha512)
get_filename_component(_leaf "${_path}" NAME)
string(REPLACE "/" "-" _name "${_path}")
vcpkg_download_distfile("_dlss_${_leaf}"
URLS "https://raw.githubusercontent.com/NVIDIA/DLSS/v${VERSION}/${_path}"
FILENAME "nvidia-dlss-${VERSION}-${_name}"
SHA512 ${_sha512}
)
if(_path MATCHES "^include/")
file(INSTALL "${_dlss_${_leaf}}" DESTINATION "${CURRENT_PACKAGES_DIR}/include/ngx" RENAME "${_leaf}")
endif()
endwhile()

if(VCPKG_TARGET_IS_WINDOWS)
file(INSTALL "${_dlss_nvsdk_ngx_d.lib}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib" RENAME "nvsdk_ngx_d.lib")
file(INSTALL "${_dlss_nvsdk_ngx_d_dbg.lib}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib" RENAME "nvsdk_ngx_d_dbg.lib")
# NVIDIA ships only a release runtime, NGX loads it at run time in every configuration
file(INSTALL "${_dlss_nvngx_dlss.dll}" DESTINATION "${CURRENT_PACKAGES_DIR}/bin" RENAME "nvngx_dlss.dll")
file(INSTALL "${_dlss_nvngx_dlss.dll}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/bin" RENAME "nvngx_dlss.dll")
else()
# One static loader for both configurations, the runtime keeps NVIDIA's versioned file name because NGX looks for it
file(INSTALL "${_dlss_libnvsdk_ngx.a}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib" RENAME "libnvsdk_ngx.a")
file(INSTALL "${_dlss_libnvsdk_ngx.a}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib" RENAME "libnvsdk_ngx.a")
file(INSTALL "${_dlss_libnvidia-ngx-dlss.so.${VERSION}}" DESTINATION "${CURRENT_PACKAGES_DIR}/lib" RENAME "libnvidia-ngx-dlss.so.${VERSION}")
file(INSTALL "${_dlss_libnvidia-ngx-dlss.so.${VERSION}}" DESTINATION "${CURRENT_PACKAGES_DIR}/debug/lib" RENAME "libnvidia-ngx-dlss.so.${VERSION}")
endif()

file(INSTALL "${CMAKE_CURRENT_LIST_DIR}/nvidia-dlss-config.cmake" DESTINATION "${CURRENT_PACKAGES_DIR}/share/${PORT}")
vcpkg_install_copyright(FILE_LIST "${_dlss_LICENSE.txt}")
8 changes: 8 additions & 0 deletions cmake/vcpkg-ports/nvidia-dlss/vcpkg.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"name": "nvidia-dlss",
"version-string": "310.9.16",
"description": "NVIDIA DLSS SDK (NGX headers, static loader library and the Super Resolution runtime) from github.com/NVIDIA/DLSS",
"homepage": "https://github.com/NVIDIA/DLSS",
"license": null,
"supports": "(windows | linux) & x64"
}
2 changes: 2 additions & 0 deletions editor/Assets/Importers/KtxWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,8 @@ private static string BuildArgs(TextureImporter.Settings s, string destPath, str
break;
case TextureCompression.None:
default:
// An RGB source would stay 24 bit, which the engine refuses to upload
sb.Append("--target_type RGBA ");
break;
}

Expand Down
2 changes: 2 additions & 0 deletions editor/Assets/Types/EnvironmentMapAsset.cs
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
using System.Collections.Generic;
using Lucide.Avalonia;

namespace editor.Assets.Types;

public sealed class EnvironmentMapAsset : BaseAsset {
public override string Type => "environment_map";
public override IReadOnlyList<string> CppTypeNames => ["EnvironmentMap"];
public override string Extension => ".hdr";
public override string DisplayName => "Environment Map";
public override string ChipText => "HDRI";
Expand Down
31 changes: 31 additions & 0 deletions editor/Assets/Types/PostProcessProfileAsset.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
using Lucide.Avalonia;

namespace editor.Assets.Types;

public class PostProcessProfileAsset : BaseAsset {
public override string Type => "post_process_profile";
public override string Extension => ".tpp";
public override string DisplayName => "Post Process Profile";
public override string ChipText => "POST";
public override string ChipColor => "Orange";
public override LucideIconKind Icon => LucideIconKind.Sun;
public override bool CanBeCreated => true;
public override string Category => "Visual";
public override bool HasThumbnail => false;
public override bool CanBeEdited => true;
public override string EditorTool => "GenericEditor";
public override string SchemaPath => "core://schemas/post_process.schema.json";

public override IReadOnlyList<string> CppTypeNames => ["PostProcessProfile"];

public override Task CreateAsync(string path) {
const string schemaUid = "PostProcSc4";
File.WriteAllText(path,
$"# Toast post process profile\n" +
$"schema = \"{schemaUid}\"\n");
return Task.CompletedTask;
}
}
167 changes: 167 additions & 0 deletions editor/Components/Elements/ColorWheel.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,167 @@
//
// ColorWheel.cs
// 27 Nov 2026
//

using System;
using System.Diagnostics;
using Avalonia;
using Avalonia.Controls;
using Avalonia.Data;
using Avalonia.Input;
using Avalonia.Media;

namespace editor.Components.Elements;

/// Grading wheel for a tint stored as white plus a brightness free offset, the way the engine reads lift, gamma and gain
public class ColorWheel : Control {
/// Chroma at the rim, in Rec.709 Cb/Cr units
private const double RimChroma = 0.3;

private const int RingSegments = 180;
private const double FineFactor = 0.1;

/// Dot travel per pixel of pointer travel
private const double DragFactor = 0.2;

public static readonly StyledProperty<float> RProperty =
AvaloniaProperty.Register<ColorWheel, float>(nameof(R), 1f, defaultBindingMode: BindingMode.TwoWay);

public static readonly StyledProperty<float> GProperty =
AvaloniaProperty.Register<ColorWheel, float>(nameof(G), 1f, defaultBindingMode: BindingMode.TwoWay);

public static readonly StyledProperty<float> BProperty =
AvaloniaProperty.Register<ColorWheel, float>(nameof(B), 1f, defaultBindingMode: BindingMode.TwoWay);

private Point m_lastPointer;
private bool m_dragging;

static ColorWheel() {
AffectsRender<ColorWheel>(RProperty, GProperty, BProperty);
Debug.Assert(RoundTrips(0.1, -0.2) && RoundTrips(-0.3, 0.0) && RoundTrips(0.0, 0.25));
}

public ColorWheel() {
Cursor = new Cursor(StandardCursorType.Hand);
ToolTip.SetTip(this, "Drag to tint, Shift for fine, double click to reset");
}

public float R { get => GetValue(RProperty); set => SetValue(RProperty, value); }
public float G { get => GetValue(GProperty); set => SetValue(GProperty, value); }
public float B { get => GetValue(BProperty); set => SetValue(BProperty, value); }

/// Tint for chroma (cb, cr): white plus the Y = 0 YCbCr colour, so its Rec.709 luminance is exactly 1
public static (float R, float G, float B) TintFromChroma(double cb, double cr) {
return ((float)(1.0 + 1.5748 * cr), (float)(1.0 - 0.1873 * cb - 0.4681 * cr), (float)(1.0 + 1.8556 * cb));
}

/// Inverse of TintFromChroma; brightness a tint carries is ignored, as the engine ignores it
public static (double Cb, double Cr) ChromaFromTint(float r, float g, float b) {
var luma = 0.2126 * r + 0.7152 * g + 0.0722 * b;
return ((b - luma) / 1.8556, (r - luma) / 1.5748);
}

private static bool RoundTrips(double cb, double cr) {
var (r, g, b) = TintFromChroma(cb, cr);
var (cb2, cr2) = ChromaFromTint(r, g, b);
return Math.Abs(cb - cb2) < 1e-3 && Math.Abs(cr - cr2) < 1e-3;
}

protected override Size MeasureOverride(Size availableSize) {
var side = double.IsInfinity(availableSize.Width) ? 120 : Math.Min(availableSize.Width, 160);
return new Size(side, side);
}

public override void Render(DrawingContext context) {
var radius = Math.Min(Bounds.Width, Bounds.Height) / 2 - 2;
if (radius <= 4) return;
var center = new Point(Bounds.Width / 2, Bounds.Height / 2);
var ringInner = radius * 0.9;

context.DrawEllipse(new SolidColorBrush(EditorColorPalette.Resolve("Bg1")), null, center, radius, radius);

// Each segment shows the colour a dot in that direction gives, so the ring cannot disagree with the mapping
var thickness = 2 * Math.PI * radius / RingSegments * 1.6;
for (var i = 0; i < RingSegments; i++) {
var angle = 2 * Math.PI * i / RingSegments;
var (dx, dy) = (Math.Cos(angle), -Math.Sin(angle));
var pen = new Pen(new SolidColorBrush(DisplayColor(dx, -dy, 2.0)), thickness);
context.DrawLine(pen, center + new Vector(dx, dy) * ringInner, center + new Vector(dx, dy) * radius);
}

var cross = new Pen(new SolidColorBrush(Color.FromArgb(50, 255, 255, 255)));
context.DrawLine(cross, center - new Vector(ringInner, 0), center + new Vector(ringInner, 0));
context.DrawLine(cross, center - new Vector(0, ringInner), center + new Vector(0, ringInner));

var (cb, cr) = ChromaFromTint(R, G, B);
var dot = center + new Vector(cb, -cr) * (ringInner / RimChroma);
context.DrawLine(new Pen(new SolidColorBrush(Color.FromArgb(120, 255, 255, 255))), center, dot);
context.DrawEllipse(
new SolidColorBrush(DisplayColor(cb / RimChroma, cr / RimChroma, 1.0)), new Pen(Brushes.White, 1.5), dot, 5, 5);
}

/// Exaggerated so a small tint still reads on screen
private static Color DisplayColor(double cb, double cr, double strength) {
var (r, g, b) = TintFromChroma(cb * RimChroma * strength, cr * RimChroma * strength);
static byte Channel(float v) {
return (byte)Math.Clamp((v - 0.35) * 255 / 1.3, 0, 255);
}

return Color.FromRgb(Channel(r), Channel(g), Channel(b));
}

protected override void OnPointerPressed(PointerPressedEventArgs e) {
base.OnPointerPressed(e);
if (!e.GetCurrentPoint(this).Properties.IsLeftButtonPressed) return;
if (e.ClickCount == 2) {
Reset();
e.Handled = true;
return;
}

m_dragging = true;
m_lastPointer = e.GetPosition(this);
e.Pointer.Capture(this);
e.Handled = true;
}

protected override void OnPointerMoved(PointerEventArgs e) {
base.OnPointerMoved(e);
if (!m_dragging) return;
var position = e.GetPosition(this);
var delta = position - m_lastPointer;
m_lastPointer = position;

var radius = Math.Min(Bounds.Width, Bounds.Height) / 2 * 0.9;
if (radius <= 0) return;
var scale = RimChroma / radius * DragFactor * (e.KeyModifiers.HasFlag(KeyModifiers.Shift) ? FineFactor : 1.0);
var (cb, cr) = ChromaFromTint(R, G, B);
cb += delta.X * scale;
cr -= delta.Y * scale;

var length = Math.Sqrt(cb * cb + cr * cr);
if (length > RimChroma) {
cb *= RimChroma / length;
cr *= RimChroma / length;
}

(R, G, B) = TintFromChroma(cb, cr);
e.Handled = true;
}

protected override void OnPointerReleased(PointerReleasedEventArgs e) {
base.OnPointerReleased(e);
if (!m_dragging) return;
m_dragging = false;
e.Pointer.Capture(null);
}

protected override void OnPointerCaptureLost(PointerCaptureLostEventArgs e) {
base.OnPointerCaptureLost(e);
m_dragging = false;
}

public void Reset() {
(R, G, B) = (1f, 1f, 1f);
}
}
Loading
Loading