philipturner / molecular-renderer

CAD program for molecular nanotechnology
MIT License
61 stars 6 forks source link

error: no such module 'Metal' #11

Open ResourceHog opened 3 months ago

ResourceHog commented 3 months ago

When building on windows I get this error:

Nanosystems\molecular-renderer\Sources\MolecularRenderer\MRAccelBuilder+Build.swift:8:8: error: no such module 'Metal' import Metal

Any idea where I can find this dependency?

philipturner commented 3 months ago

Right now, the renderer module is macOS-only. There hasn't been anybody on Linux/Windows interested in the project yet. My current suggestion is to export static XYZ files to an alternative renderer, like VMD or SAMSON.

I have a discrete GPU that I just got running under Windows 10. I'm serializing simulation frames and sending them to my Mac for rendering right now. It would be possible to eventually create a native Windows app for rendering.

ResourceHog commented 3 months ago

What's the serialized format?

ResourceHog commented 3 months ago

What do you think it would take to instead use a cross platform hardware acceleration library like Vulkan or OpenGL ?

ResourceHog commented 3 months ago

I suppose there would also be a need for a cross platform alternative to swiftUI.

philipturner commented 3 months ago

What's the serialized format?

Uncompressed raw binary data. A 16-byte word containing:

x coordinate (Float32, 4 bytes)
y coordinate (Float32, 4 bytes)
z coordinate (Float32, 4 bytes)
atomic number (UInt8, 1 byte)
3 bytes padding

This is how the HDL stores stuff in memory. Encoding and decoding should be very easy in languages with pointer arithmetic (C, Rust, Swift, etc.). I once used a text format with lossless compression, but learned that's way too much work for the small benefit it provides.

I also have a 128 GB USB stick with ~500 MB/s bandwidth, so large file transfers can happen fast.

philipturner commented 3 months ago

I suppose there would also be a need for a cross platform alternative to swiftUI.

We just need a proper effort to use the native Windows APIs for UI/UX. There's a Swift toolchain that can use native Windows APIs, even demoing a DirectX 3D renderer. A challenging task is hacking into the Vsync API, to perfectly synchronize the renderer's frame counter with the screen refresh rate. That necessitates direct usage of the lowest-level native APIs, as opposed to a game engine that abstracts this from the developer.

What do you think it would take to instead use a cross platform hardware acceleration library like Vulcan or OpenGL

Vulkan, but with Microsoft HLSL compiled into SPIR-V. The other shading languages don't have sufficiently advanced syntax. Then, one would need to hook it up to AMD FidelityFX upscaling, enabling high-quality ray tracing.

https://github.com/philipturner/molecular-renderer/tree/main/Sources/MolecularRenderer

philipturner commented 3 months ago

A start would be a minimal Windows C++/D3D app that intersects each pixel ray with every sphere in the scene. Figure out how to synchronize with integer multiples of the frame refresh period. Then, create an interface with Swift code and consider high-quality ray tracing effects.