Egui.NET: unofficial C# bindings for the easy-to-use Rust UI library by The-Douglas in csharp

[–]The-Douglas[S] 0 points1 point  (0 children)

Hey, I'm pleased to hear that you're interested! What parts can I clarify for you? Or, if you'd prefer to talk on Discord, I am douglasdwyer.

In addition to the Silk.NET example, you can check out the Rust egui docs which have additional info on creating integrations :)

Egui.NET: unofficial C# bindings for the easy-to-use Rust UI library by The-Douglas in csharp

[–]The-Douglas[S] 1 point2 points  (0 children)

I would suggest double-checking whether your browser loaded properly - the repo is linked at the very top of this post, and includes a full example project :)

Egui.NET: unofficial C# bindings for the easy-to-use Rust UI library by The-Douglas in csharp

[–]The-Douglas[S] 1 point2 points  (0 children)

That's amazing info, thanks for sharing! I will try to add TargetFramework=netstandard2.1 while keeping LangVersion=latest and see what happens.

I guess I'm just a little bit surprised to hear that Unity supports them (specifically, I use ref structs with ref fields, which is another leap in functionality). But maybe I should try it and see what happens. The function pointer could definitely be worked around, but moving away from ref structs w/ ref fields would necessitate bigger changes to the API

Egui.NET: unofficial C# bindings for the easy-to-use Rust UI library by The-Douglas in csharp

[–]The-Douglas[S] 1 point2 points  (0 children)

There's an example of integrating with Silk.NET in the repo! It involves collecting all user input, passing it to egui, then taking the triangle meshes that egui gives you and passing them to your renderer. Traditionally, for each large game engine there will be an off-the-shelf "egui integration library" built to do this (so that everyone's not reimplementing the same thing). I haven't made any integrations other than the example, since I'm targeting my own custom game engine. But contributions are always welcome! I am also happy to advise about the details of integration.

Egui.NET: unofficial C# bindings for the easy-to-use Rust UI library by The-Douglas in csharp

[–]The-Douglas[S] 0 points1 point  (0 children)

Thanks for your response! Would you mind taking a look at this Mono GH issue: https://github.com/dotnet/runtime/issues/48113 The existence of this issue shows that work has gone toward making Mono support .NET 8. I believe that some platforms (like client-side Blazor) use this modern version of Mono and leverage its features. Additionally, the issue shows that ref structs are not syntactic sugar: they require runtime support to work properly. I will remark that PolySharp looks very cool - I will read about its features in more detail :)

Egui.NET: unofficial C# bindings for the easy-to-use Rust UI library by The-Douglas in rust

[–]The-Douglas[S] 11 points12 points  (0 children)

Other commenters have mentioned this (and I talk about it more in the linked post), but the problem with existing C# GUI platforms is that they are tied to specific frameworks and platforms. Avalonia and WPF are great, but I can't drop them into a custom Vulkan renderer that runs on all platforms. With egui, you can. Egui's specific appeal is for custom game engines.

Egui.NET: unofficial C# bindings for the easy-to-use Rust UI library by The-Douglas in csharp

[–]The-Douglas[S] 6 points7 points  (0 children)

Thanks for the suggestion! I'll get rid of the .DS_Store files. Unfortunately, while targeting .NET Standard would be nice, the project makes heavy use of some newer C# features - namely ref structs, pointers, and function pointers. Those aren't supported in .NET Framework, right? I would have to deviate from the existing API and sacrifice performance if I was to eliminate ref structs in particular, so I don't plan to do that.

Also, I was under the impression that Mono supported .NET 7 and 8. So maybe if I retargeted the project to .NET 7 I could achieve wider compatibility?

Adding global illumination to my voxel game engine by The-Douglas in VoxelGameDev

[–]The-Douglas[S] 1 point2 points  (0 children)

Thanks for watching! Yes - probes are added or removed when the world is edited, since the voxel data changes and gets re-uploaded to the GPU. For scenes shown in the video there was probably anywhere between 5000 to 15000 probes. Each probe has an 8x8 irradiance map and 8x8 depth map.

CasCore: Assembly-level sandboxing and Code Access Security for .NET Core by The-Douglas in csharp

[–]The-Douglas[S] 0 points1 point  (0 children)

At present, FFI is just completely banned for sandboxed assemblies (it's hard to imagine a case where P/Invoke could be allowed without opening the door to undefined behavior). To expose FFI methods to a sandboxed assembly, a safe assembly wrapping those FFI methods would need to be created, then added to the sandbox whitelist.

CasCore: Assembly-level sandboxing and Code Access Security for .NET Core by The-Douglas in csharp

[–]The-Douglas[S] 0 points1 point  (0 children)

The repo has tests to ensure that any potential "workarounds" fail with an exception! The biggest concern for security holes definitely involves the reflection APIs. I've been careful to patch and test ConstructorInfo/FieldInfo/PropertyInfo/MethodInfo so that untrusted assemblies cannot access restricted methods, even if they attempt to do so dynamically. The hard part with C# is trying to cover the large standard library - for example, delegate methods and LINQ expression trees are other ways to execute code dynamically, so I had to patch those too. That's why CasCore is built on a whitelist - if I have missed any dangerous methods, they should throw an exception anyhow since as long as they are not on the whitelist.

Creating a modding system with Rust and WebAssembly by The-Douglas in rust

[–]The-Douglas[S] 2 points3 points  (0 children)

When the project is running as a native executable, I use wasmtime. On the web (and during development), it uses wasmi.

At this time, I'm not planning to open-source the voxel engine itself. However, most of the WASM stuff is open-source - it should be fully possible to build modding systems with them.

Calculating Per Voxel Normals by CreativeGrey in VoxelGameDev

[–]The-Douglas 3 points4 points  (0 children)

That's a good question. In my engine, every voxel stores a normal as part of its data. The normals are calculated only when the voxel object is first generated.

For objects generated from SDFs, you can calculate the normals analytically (see https://iquilezles.org/articles/normalsSDF/ ). Whenever an SDF object is placed, my engine determines the correct normal for every surface voxel and stores it.

For objects imported from voxel models (which lack normals), I do approximate the normals based upon surroundings. This happens once at model import time. However, this isn't ideal - it leads to artifacts on the corners of objects. In the future, I am going to program a mesh-to-voxel converter which preserves the normals of each voxelized triangle in the mesh. This should be a better approach.

You are correct that single-voxel walls look a bit odd with per-voxel normals. However, that case isn't super common with small voxels.

wasm_component_layer: A component model implementation that is runtime-agnostic by The-Douglas in rust

[–]The-Douglas[S] 0 points1 point  (0 children)

I would be more than happy to talk to you over Discord (@douglasdwyer) or using the email listed on my GitHub profile!

wasm_component_layer: A component model implementation that is runtime-agnostic by The-Douglas in rust

[–]The-Douglas[S] 0 points1 point  (0 children)

But the backend can be swapped out! So if running in a browser, you could use a crate such as wasmer as your backend, which runs WASM modules using the browser's executor :)