পাঠ ২৩ · ২৮-এর মধ্যে · মডিউল ৪
Home / AI Courses / Generative AI / 3D generation

3D generation — NeRF ও Gaussian Splatting

3D generation — NeRF, Gaussian Splatting, modern stack
৭ মিনিট পড়া উচ্চ · Advanced Volume rendering

এই পাঠে যা শিখবেন

  • NeRF কী — MLP-এ 3D scene encode-এর মূল idea
  • Volume rendering — কীভাবে 3D ফিল্ড থেকে 2D ছবি
  • 3D Gaussian Splatting — explicit primitives, real-time
  • Text-to-3D pipeline (SDS loss) এবং practical use case

১ · 3D scene-কে কীভাবে represent করি

কম্পিউটার গ্রাফিক্সে চিরকাল scene = mesh (triangle) + texture। কিন্তু photo থেকে detailed 3D mesh বের করা কঠিন। ২০২০-এ Mildenhall et al. একদম ভিন্ন idea দিল — scene হবে একটি function।

$$F_\Theta : (x, y, z, \theta, \phi) \;\to\; (r, g, b, \sigma)$$

Input: 3D position + viewing direction। Output: color + density। এই function-ই MLP — parameters $\Theta$।

২ · Volume rendering — function থেকে ছবি

একটি pixel-এর color পেতে — সেই pixel থেকে camera-এর through একটি rayRay (light ray)একটি সরলরেখা — camera থেকে scene-এ। প্রতিটি pixel = একটি ray। NeRF এই ray বরাবর সংখ্যক sample point নেয়। shoot করুন। Ray বরাবর ৬৪-১২৮ point sample। প্রতিটি point-এ MLP query → color & density। Compositing equation:

$$C(\mathbf{r}) = \sum_{i} T_i \, (1 - e^{-\sigma_i \delta_i}) \, \mathbf{c}_i, \quad T_i = \exp\!\left(-\sum_{j

$T_i$ = transmittance (কতটা light পেছনের point থেকে front-এ পৌঁছায়)। Equation differentiable — তাই photo-গুলো থেকে $\Theta$ optimize gradient descent দিয়ে।

NeRF training

Input: ১০০-৩০০ photo বিভিন্ন angle থেকে + camera pose (COLMAP)।
Loss: rendered pixel ↔ ground truth pixel — MSE।
Train: ১২ ঘণ্টা একটি GPU।
Inference: novel viewpoint থেকে high-quality render।

৩ · NeRF-এর সমস্যা ও Instant-NGP

  • Slow training: per scene ১২ ঘণ্টা।
  • Slow render: 1080p frame ~৩০ second।
  • No editing: implicit representation — object move করা কঠিন।

Instant-NGP (Müller, NVIDIA 2022): multi-resolution hash grid + tiny MLP — ৫ second-এ train, real-time render। NeRF-এর Game changer।

৪ · 3D Gaussian Splatting (Kerbl 2023) — explicit comeback

২০২৩-এ INRIA-র দল completely different approach দিল। Implicit MLP ছেড়ে — millions of 3D anisotropic Gaussian dot। প্রতিটি Gaussian:

  • Position $\mu \in \mathbb{R}^3$।
  • Covariance $\Sigma \in \mathbb{R}^{3 \times 3}$ (shape, orientation)।
  • Color $\mathbf{c}$ (spherical harmonics — view-dependent)।
  • Opacity $\alpha$।

Render: 3D Gaussians → 2D image plane-এ project (splat) → alpha-blend। সম্পূর্ণ rasterization — GPU-তে অত্যন্ত efficient।

NeRF = একটি hidden function — "এই point-এ কী?"। Gaussian Splatting = লক্ষ লক্ষ paint-blob — "এই scene blobs-এর collection"। Implicit বনাম explicit।

৫ · Text-to-3D — diffusion-এর ব্যবহার

  • DreamFusion (Poole 2022): SDS loss — pretrained 2D diffusion (Imagen) দিয়ে NeRF supervise।
  • Magic3D (NVIDIA 2022): coarse + fine stage; mesh export।
  • Shap-E (OpenAI 2023): implicit function direct generate; ১৩ second।
  • InstantMesh, TripoSR, Stable Fast 3D (২০২৪): single image → 3D mesh in seconds।
  • Genie (Luma 2024): text-to-Gaussian-Splat।
NeRF বনাম Gaussian Splatting 🧠 NeRF — implicit MLP F_Θ : (x, y, z, θ, φ) → (r, g, b, σ) 8-layer MLP, 256 hidden camera → sample N points along ray Volume render — alpha composite C = Σ T_i (1-exp(-σ_i δ_i)) c_i ⚠ Slow render — 30s/frame N MLP forward per pixel Compact (~5MB), high quality, slow ✨ 3D Gaussian Splatting millions of (μ, Σ, c, α) blobs explicit primitives, no MLP → project to 2D → α-blend Differentiable rasterization tile-based GPU sort + blend ⚡ Real-time — 100+ fps Bigger (~500MB), real-time, editable
দু'টি 3D paradigm — implicit MLP (NeRF) বনাম explicit Gaussian primitives। Modern stack প্রায়ই Gaussian Splatting বাছছে real-time-এর জন্য।

৬ · Practical use cases

  • E-commerce: Daraz product 3D preview — ১০-২০ photo থেকে।
  • Heritage: Sundarbans, Sixty Dome Mosque digital twin।
  • Real estate: বাড়ি ১০ photo → walkthrough video।
  • Film VFX: set extension, virtual production।
  • AR: Apple Vision Pro, Quest 3 — Gaussian splat real-time।
  • Robotics: simulation environment — sim2real।
  • Games: asset generation pipeline (Genie, Meshy)।

৭ · 3D Gaussian Splatting দিয়ে hands-on

Python · gsplat
# Colab: pip install -q nerfstudio
# Or: pip install gsplat torch torchvision

# Step 1: Capture / collect ~50 photos of an object (dhamrai brass figurine)
# Step 2: Run COLMAP for camera poses (handled by nerfstudio)
# Step 3: Train Gaussian Splatting

# nerfstudio CLI (Colab terminal):
# ns-process-data images --data ./photos --output-dir ./processed
# ns-train splatfacto --data ./processed --max-num-iterations 30000

# Result: a .ply file with millions of Gaussians
# Viewer: https://playcanvas.com/super-splat/ or splat.js

    

৮ · Text-to-3D — InstantMesh

Python · diffusers + InstantMesh
from diffusers import StableDiffusionPipeline
import torch

# Step 1: text → image
sd = StableDiffusionPipeline.from_pretrained(
    "stabilityai/stable-diffusion-2-1",
    torch_dtype=torch.float16,
).to("cuda")

prompt = "A clay terracotta horse statue from Bishnupur, Bangladesh, "\
         "centered, white background, full body, photorealistic"
image = sd(prompt, num_inference_steps=30).images[0]
image.save("horse_2d.png")

# Step 2: image → 3D mesh (via InstantMesh / TripoSR / Stable Fast 3D)
# These have separate repos; conceptual usage:
# from triposr import TripoSR
# tsr = TripoSR.from_pretrained("stabilityai/TripoSR")
# mesh = tsr(image)
# mesh.export("horse_3d.glb")
print("✅ pipeline outline complete")

    
Single-image-to-3D model এখনো occluded side-এ "guess" করে — back side often wrong। Multi-view input দিলে quality dramatically ভাল।

ভাবনার প্রশ্ন

প্র ০১ NeRF vs Gaussian Splatting — কোনটা "winner" ২০২৫-এ? কেন কোম্পানিগুলো (Luma, Polycam, Niantic) Gaussian-এ shift করছে?

২০২০-২৩ NeRF era; ২০২৩-২৫ Gaussian Splatting era। Industry-র shift ছিল decisive — কারণ গভীর।

NeRF-এর strengths:

  • Storage ~৫-১০ MB per scene।
  • Smooth implicit surface — view interpolation নরম।
  • Mathematical elegance — single MLP।

NeRF-এর weakness:

  • Render ৩০ second/frame — VR/AR অযোগ্য।
  • Editing impossible — black box function।
  • Training-এ ১২ ঘণ্টা (Instant-NGP-এ ৫ মিনিট, কিন্তু render still slow)।

Gaussian Splatting wins:

  • ৩০-১০০+ fps real-time render — VR-এ critical।
  • Explicit — Gaussian-গুলো পৃথক, edit সম্ভব।
  • Training ২০ মিনিট (NeRF-এর ১২ ঘণ্টার বদলে)।
  • Sparse view-এ better — কম photo, ভালো result।

Gaussian-এর downside:

  • File size ৫০০ MB-1 GB — mobile/web heavy।
  • Reflection, transparency wobbly।
  • "Dot artifact" — closeup-এ প্রতিটি Gaussian visible।

Industry adoption:

  • Luma AI: NeRF থেকে full Gaussian-এ migrate।
  • Polycam: ২০২৪-এ Gaussian default।
  • Niantic Spatial: Visual Positioning System Gaussian-এ।
  • Apple Vision Pro: Object Capture Gaussian-friendly format।
  • Unity, Unreal: Gaussian renderer plugin available।

Modern hybrid:

  • 2DGS, 4DGS — anisotropic + temporal extension।
  • Mip-Splatting — anti-aliasing improvement।
  • Hierarchical / LoD — mobile-friendly compression।
  • Gaussian Frosting, GaussianAvatar — character generation।

মূল উপলব্ধি: "Implicit elegance" বনাম "explicit speed" — production-এ speed almost always wins। Future-এ হয়ত hybrid (mesh + Gaussian + neural texture)। কিন্তু ২০২৫-এ Gaussian dominant।

প্র ০২ Sundarbans-এর একটি digital twin বানাতে চান — heritage preservation। কী data, কী tech, কী challenge?

Heritage preservation-এ digital twin — fire, flood, war-এ ক্ষতি হলেও experience surviving। UNESCO-র সাম্প্রতিক push।

Sundarbans-এর unique challenge:

  • ~১০,০০০ km² area — entire scope impossible।
  • Tidal change — same spot ২ ঘণ্টায় ভিন্ন।
  • Vegetation dense — occlusion-heavy।
  • Wildlife (tiger, deer, dolphin) — moving subjects।
  • Logistics — boat-only access।

Data acquisition:

  • Drone (UAV): DJI Mavic 3 — RGB + LiDAR (some models)।
  • 360° camera: Insta360 X4 — boat-mount, river path।
  • Smartphone walkaround: selected boardwalk locations।
  • Satellite (Maxar, Planet): wide context।
  • Bathymetry: sonar — water depth।

Tech stack:

  • Photogrammetry (Pix4D, RealityCapture): mesh + texture। Conventional।
  • NeRF / Gaussian Splat: dense regions — village, mangrove canopy।
  • Procedural generation: repeated trees algorithm, leaf-level detail SpeedTree।
  • Hybrid approach: Gaussian for dense areas, photogrammetric mesh for terrain।

Challenges:

  • Scale: petabyte-scale data; cloud storage।
  • Tidal sync: low + high tide capture; temporal modeling।
  • Vegetation: wind-induced motion → multi-view inconsistency।
  • Permission: Forest Department, BD Tourism approvals।
  • Animal welfare: drone disturbance laws।
  • Cyclone: field campaign window narrow (Nov-Feb)।

Valuable use cases:

  • Climate change impact monitoring — sea level rise simulation।
  • Tourist VR/AR — accessible without ecological pressure।
  • Conservation training — ranger scenario।
  • Research — tiger habitat 3D study।
  • Education — schools, museums।

Examples to learn from:

  • CyArk — global heritage scanning।
  • Google Arts & Culture — Borobudur, Pyramids।
  • "Digital Mosul" — Iraq post-ISIS reconstruction।
  • Bangladesh-এ Liberation War Museum-এর precedent।

Funding: UNDP, UNESCO, Bangladesh ICT Division, ADB grant — collaborative model recommend।

মূল উপলব্ধি: Tech-এর challenge গভীর কিন্তু solvable। আসল prize — climate-vulnerable heritage-এর "memory snapshot"। ১০ বছর পর Sundarbans বদলাবে — আজকের scan তখন priceless।

প্র ০৩ Text-to-3D (Shap-E, DreamFusion, SDS loss) — কেন এত কঠিন? "Janus problem" কী? কেন 3D image-এর চেয়ে slower progress?

Text-to-image ২০২২-এ "solved" feel দিল; text-to-3D এখনো ২০২৫-এ early stage। কারণ গভীর।

(১) Data scarcity:

  • Image-text pairs Web-এ billions (LAION-5B)।
  • 3D-text pairs ~১M (Objaverse-XL)।
  • Quality variable — most are simple game assets।
  • Photorealistic + textured 3D + caption — rare।

(২) Representation ambiguity:

  • Image canonical: pixel grid।
  • 3D: mesh? voxel? point cloud? NeRF? Gaussian? — সব lossy/inefficient।
  • Topology (genus, manifold) discrete — gradient-friendly নয়।

(৩) Computation explosion:

  • 3D = 2D + depth × resolution।
  • 1024³ voxel = 1 billion entry — train impossible।

(৪) DreamFusion-এর SDS loss:

  • Frozen 2D diffusion দিয়ে 3D supervise।
  • Loss noisy — slow convergence (hours per asset)।
  • Mode collapse — average view, no detail।

(৫) Janus problem:

  • Front view "dog face" generate; back view-ও "dog face" — দু'মুখী Janus।
  • 2D model-এ "dog" prompt = front view-এ ৯০% bias।
  • 3D rotation-এ inconsistent।
  • Fix: view-aware prompting ("back view of"), MVDream multi-view diffusion, 3D-aware fine-tune।

(৬) Multi-view consistency:

  • 2D diffusion প্রতি view independent generate।
  • Texture, geometry view-জুড়ে different।
  • Modern fix: Zero-1-to-3, MVDream, SyncDreamer — explicitly multi-view trained।

২০২৪-২৫ progress:

  • InstantMesh, TripoSR, Stable Fast 3D: single-image → mesh seconds-এ।
  • Genie 2 (DeepMind 2024): world model — interactive 3D environment।
  • CLAY (২০২৪): 3D-native diffusion।
  • Hunyuan3D (২০২৪): Tencent open-source SOTA।

Looking ahead:

  • Native 3D foundation model coming (Sora-of-3D)।
  • Robotics + 3D foundation model union।
  • Real-time text-to-Gaussian-Splat ২০২৫ end এর মধ্যে দেখা যেতে পারে।

মূল উপলব্ধি: 3D image-এর "20 mile longer road" — data + representation + supervision তিনটাই hard। কিন্তু prize বিশাল — robotics, AR, gaming সব এর উপর।

প্র ০৪ একটি Bangladeshi e-commerce (Daraz, Pickaboo) তাদের product-গুলো 3D-এ দেখাতে চায়। কীভাবে scale করবেন? কোন category-তে ROI সর্বোচ্চ?

3D product view conversion ৩০-৪০% বাড়ায় (Shopify data, IKEA, Wayfair)। কিন্তু ২ million SKU-তে scale challenge।

ROI ranking by category:

  • Highest ROI: Furniture (sofa, bed) — size critical, return rate high। 3D-এ ৪০% return reduction। Daraz home category-তে priority।
  • High: Footwear, fashion accessory (bag, watch)। Tactile sense replicate।
  • Medium: Electronics (phone, laptop) — spec-driven, 3D nice-to-have।
  • Low: Books, groceries, fast-moving consumer goods।
  • Special: Sari, lehenga — drape, fabric texture critical। 3D + cloth simulation।

Capture pipeline:

  • Tier 1 (top 1000 SKU): Photogrammetry rig — ৬৪ DSLR turntable, ১৫-২০ minutes per item। RealityCapture render।
  • Tier 2 (top 10K): Smartphone-only Polycam / Luma — vendor self-service।
  • Tier 3 (long tail): AI single-image-to-3D (TripoSR, Stable Fast 3D) — instant, lower quality।

Tech stack:

  • Capture: Polycam app (Bangladesh smartphone-friendly)।
  • Storage: glTF 2.0 (web standard) + Gaussian Splat for premium।
  • Web viewer: model-viewer (Google), Babylon.js।
  • AR: WebXR / iOS Quick Look / Android Scene Viewer।

Bangladesh-specific challenges:

  • Bandwidth: 50 MB GLB ৩G-এ painful। Compression critical (Draco, KTX2)।
  • Mobile-first: Bangladesh ৯৫% e-commerce mobile। AR Quick Look ভাল।
  • Vendor onboarding: small seller না জানে। Tutorial Bangla-তে essential।
  • Sari/textile: fabric photogrammetry-এ tricky। Special protocol।

Phased rollout:

  • Month 1-3: Top 100 furniture SKU pro photogrammetry। A/B test conversion।
  • Month 4-6: Polycam app + vendor training।
  • Month 7-12: AI 3D for long tail; AR feature mobile app।

Cost estimate:

  • Pro photogrammetry: ৫০০-১০০০ TK per SKU।
  • AI 3D: ১০-৫০ TK।
  • Storage/CDN: BDT ০.৫০ per GB-month।
  • Total Year 1: ১-২ কোটি TK for ১০০K SKU।

Competitive moat: First-mover Bangladesh-এ। Daraz Lazada (Alibaba)-এর tech share করতে পারে। Pickaboo niche electronics-এ specialize।

মূল উপলব্ধি: 3D product feature gimmick নয় — measurable ROI। Phased + AI-augmented rollout-এ Bangladesh e-commerce ২০২৬-এ leap-frog সম্ভব।

অনুশীলন

  1. হিসাব: NeRF-এ ১৯২০×১০৮০ render — প্রতি pixel ১২৮ MLP forward। MLP = ৮ layer, ২৫৬ hidden। প্রায় কত FLOP per frame?

    Pixels: $1920 \times 1080 = 2.07M$। প্রতি pixel ১২৮ sample × ৮ layer × ($256 \times 256$) ≈ ৬৭M FLOP। Total ≈ ১৪০ TFLOP per frame। RTX 4090 (~৮৩ TFLOP fp32) — ১.৫-২ second। Real-time-এ অসম্ভব। Gaussian Splat-এ এক rasterize pass — তাই ১০০ fps।

  2. Hands-on: Polycam app বা Luma AI দিয়ে আপনার বাড়ির একটি ছোট object ৩০-৫০ photo capture করে scan করুন।

    Tips: smooth orbit, consistent lighting, no transparent/reflective object, ৬০-৯০% overlap, background contrast। Scan-এ এক drag-drop GLB / Gaussian Splat পাবেন।

  3. ভাবুন: বাংলাদেশের কোন ৩টি cultural artifact 3D digital twin-এ priority পাওয়া উচিত? কেন?
    • Sixty Dome Mosque (Bagerhat): UNESCO heritage; tidal salt corrosion threat।
    • Mahasthangarh ruins: oldest known city; ongoing erosion।
    • Sonargaon Panam Nagar: colonial architecture; preservation funding limited।

    Selection criteria: heritage value + threat level + accessibility।

আরও পড়ুন

Free Gaussian Splat viewer: PlayCanvas SuperSplat — browser-এ .ply/.splat file open ও edit।
পূর্ববর্তী পাঠ
পাঠ ২২ · Video generation