GPU-Accelerated Molecular Visualization for Windows and macOS
MolVis is a real-time 3D molecular visualization application powered by GPU compute shaders and Dear ImGui. It renders beautiful ball-and-stick molecular models with realistic atomic colors, metallic shading, and interactive controls.
- Windows: NVIDIA CUDA + DirectX 11
- macOS: Apple Metal + SDL2
- Real-time GPU Rendering β CUDA-powered parallel ray-sphere intersection for smooth performance
- Dear ImGui Interface β Modern, responsive GUI with dockable panels
- 296 Molecule Library β From simple gases to exotic structures like Buckminsterfullerene (Cββ), including skincare ingredients
- 17 Categories β Commercial pharmaceuticals, controlled substances, amino acids, sugars, skincare acids, exotic structures, and more
- CPK Color Convention β Industry-standard atomic coloring (Carbon=gray, Oxygen=red, Nitrogen=blue, etc.)
- Ball-and-Stick Models β Clear visualization of molecular structure with single, double, and triple bonds
- Interactive Controls β Rotation speed, direction, position offset, zoomβall from the GUI
- Metallic Shading β Specular highlights and realistic lighting for depth perception
| Panel | Description |
|---|---|
| Molecule Selector | Browse 296 molecules by category or search by name |
| Molecule Viewport | Interactive 3D model of the selected molecule |
| View Controls | Adjust rotation speed, direction, and position offset |
| Performance | Real-time FPS and GPU statistics |
- Simple Molecules (HβO, COβ, NHβ...)
- Organic Compounds (Benzene, Ethanol, Caffeine...)
- Amino Acids (all 20 standard + Hydroxyproline)
- Sugars & Carbohydrates (Glucose, Fructose, Ribose...)
- Vitamins (A, B complex, C, D, E, K)
- Neurotransmitters (Dopamine, Serotonin, GABA, Acetylcholine...)
- Hormones (Testosterone, Estradiol, Cortisol...)
- Pharmaceuticals (Aspirin, Ibuprofen, Warfarin, Lisinopril...)
- Controlled Substances (Heroin, Cocaine, LSD, MDMA, Ketamine...)
- Household Chemicals (NaOH, NaCl, Bleach, MSG...)
- Acids (Acetic, Sulfuric, Glycolic, Salicylic, Citric...)
- Plastics & Polymers (PET, Polystyrene, Nylon-6...)
- Lipids & Fatty Acids (Oleic, Palmitic, Linoleic...)
- Metal Compounds (Ferrocene, Cisplatin, Rust...)
- Energy Molecules (ATP, ADP, NADH, DNA/RNA nucleobases...)
- Flavors & Fragrances (Vanillin, Limonene, Menthol...)
- Other (Cββ, Cubane, exotic structures...)
- OS: Windows 10/11
- GPU: NVIDIA GPU with CUDA support (Compute Capability 5.0+)
- CUDA Toolkit: 12.0 or newer
- Compiler: Visual Studio 2019/2022/2025 with C++ workload
- OS: macOS 11.0 (Big Sur) or newer
- Hardware: Any Mac with Metal support (Intel or Apple Silicon)
- Build Tools: Xcode Command Line Tools
- Dependencies: CMake, SDL2 (via Homebrew)
# Option 1: Use build script (recommended)
.\build.bat
# Option 2: Manual build
nmake# 1. Install Xcode Command Line Tools (if not already installed)
xcode-select --install
# 2. Accept Xcode license and download Metal toolchain (first time only)
sudo xcodebuild -license accept
xcodebuild -downloadComponent MetalToolchain
xcodebuild -runFirstLaunch
# 3. Install dependencies via Homebrew
brew install cmake sdl2
# 4. Build
./build_mac.sh
# 5. Run
open build_mac/bin/MolVis.appTroubleshooting macOS Build:
- If you see "metal compiler not found", run
xcodebuild -downloadComponent MetalToolchain - If CMake can't find SDL2, ensure Homebrew is in your PATH:
eval "$(/opt/homebrew/bin/brew shellenv)" - For Apple Silicon Macs, Homebrew installs to
/opt/homebrew. For Intel Macs, it's/usr/local
20 elements with CPK coloring:
| Element | Color | Element | Color |
|---|---|---|---|
| Hydrogen (H) | White | Sodium (Na) | Purple |
| Carbon (C) | Dark Gray | Silicon (Si) | Tan |
| Nitrogen (N) | Blue | Boron (B) | Salmon |
| Oxygen (O) | Red | Iron (Fe) | Orange |
| Phosphorus (P) | Orange | Copper (Cu) | Copper |
| Sulfur (S) | Yellow | Aluminum (Al) | Silver |
| Chlorine (Cl) | Green | Titanium (Ti) | Gray |
| Bromine (Br) | Dark Red | Platinum (Pt) | Silver |
| Fluorine (F) | Light Green | Rhenium (Re) | Metallic Gray |
| Iodine (I) | Purple | Xenon (Xe) | Cyan |
MolVis/
βββ src/
β βββ gui/
β β βββ main_windows.cpp # Windows entry point (Win32 + DX11 + ImGui)
β β βββ main_mac.mm # macOS entry point (SDL2 + Metal + ImGui)
β β βββ windowicon.h # Window icon data
β βββ renderer/
β β βββ cuda_renderer.h # Windows renderer interface
β β βββ cuda_renderer.cu # CUDA ray-tracing kernels
β β βββ metal_renderer.h # macOS renderer interface
β β βββ metal_renderer.mm # Metal implementation
β β βββ renderer_interface.h # Platform-agnostic interface
β β βββ shaders/
β β βββ MoleculeShaders.metal # Metal compute shaders
β βββ molecule/
β βββ molecule_types.h # Platform-agnostic data structures
β βββ molecule_db.h # Molecule database API
β βββ molecule_db.cpp # 296 molecule definitions (~16K lines)
βββ platform/
β βββ macos/
β βββ Info.plist # macOS app bundle metadata
β βββ AppIcon.icns # macOS app icon
βββ third_party/
β βββ imgui/ # Dear ImGui (all backends)
βββ CMakeLists.txt # Cross-platform build (CMake)
βββ Makefile # Windows build (nmake)
βββ build.bat # Windows build script
βββ build_mac.sh # macOS build script
βββ resource.rc # Windows app icon and version info
βββ app.ico # Windows app icon
MIT License β see LICENSE for details.
- CPK coloring β Corey, Pauling, and Koltun convention
- Dear ImGui β Omar Cornut's immediate-mode GUI
- NVIDIA CUDA β GPU computing platform
Made with π CUDA, Metal, and Claude Opus 4.5
