Skip to content

AlfredBr/Molecule-Visualizer

Repository files navigation

🧬 Molecule Visualizer (MolVis)

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

MolVis Screenshot

✨ Features

  • 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

πŸ–₯️ Interface

Panels

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

Categories

  • 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...)

πŸ› οΈ Requirements

Windows

  • 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

macOS

  • 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)

πŸš€ Building

Windows (CUDA + DirectX 11)

# Option 1: Use build script (recommended)
.\build.bat

# Option 2: Manual build
nmake

macOS (Metal + SDL2)

# 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.app

Troubleshooting 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

πŸ§ͺ Supported Elements

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

πŸ“ Project Structure

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

πŸ“„ License

MIT License β€” see LICENSE for details.

πŸ™ Acknowledgments

  • 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

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors