Differentiable Rendering
Oct 17
Lecturer
Wei-Cheng Huang
Modular Primitives for High-Performance Differentiable Rendering (NVdiffrast)
Samuli Laine, Janne Hellsten, Tero Karras, Yeongho Seol, Jaakko Lehtinen, Timo Aila
ACM Transactions on Graphics 39(6) (proc. SIGGRAPH Asia 2020)
Lecture Adapted from NVdiffrast Presentation @ SIGGRAPH Asia 2020
Start with Rendering in General …
Why Differentiable Rendering?
Must be differentiable !
Two Main-Stream Rendering: Rasterization vs. Ray tracing
from: SIGGRAPH 2024 real-time ray tracing tutorial
from: CMU 15-462
Keenan Crane
Two Main-Stream Differentiable Rendering
Favor quality over speed
Favor speed over quality
Coverage (Visibility) Gradient Problem
Z discontinuity problem
XY discontinuity problem
from: PyTorch3D @ SIGGRAPH ASIA 2020 Course
Coverage (Visibility) Gradient Problem
Essentially: Moving a vertex has no 1st order effect on coverage
Common Tricks: blurring the geometry, make partial transparency, aggregate/ composite in an ad-hoc fashion
Problem: 1. Occlusions become fuzzy 2. must be shaded before composition
Shading with Blurred Triangles
Shade internally
Shade through memory
Composition of transparency and blur just causes overshading
This work
All differentiable and accelerated with CUDA
This work
All differentiable and accelerated with CUDA or hardware graphics pipeline
Vertex positions (homogeneous coordinates) in Clip Space
Triangular index buffer
(𝑢, 𝑣, 𝑧/𝑤, triangle ID) per pixel
Jacobian buffer 𝐽 = 𝜕{𝑢, 𝑣 }/𝜕{𝑥,𝑦}
Extra Notes:
Independent of shading, textures etc. (Modularity)
Accelerated using OpenGL hardware graphics pipeline (efficiency)
Backward pass gradient easy to get through chain rule (perspective mapping)
Dynamic mapping between world coordinates and discrete pixel coordinates.
Per-vertex attributes
Triangular index buffer
(𝑢, 𝑣) and Jacobian buffer 𝐽 = 𝜕{𝑢,𝑣}/𝜕{𝑥,𝑦} from rasterization
Interpolated attributes per pixel
Extra notes:
barycenter Jacobians is used for screen-space (attribute pixel) derivatives calculation using chain rule
Backward pass gradient also easy to get (interpolation)
Creating a mapping
between the pixels and the attributes
𝑢 = 𝑢(𝑥,𝑦),𝑣=𝑣(𝑥,𝑦), 𝑖th vertex by 𝐴𝑖 ,
𝐴 = 𝑢𝐴𝑖0 + 𝑣𝐴𝑖1 + (1 − 𝑢 − 𝑣)𝐴𝑖2
𝜕𝐴/𝜕{𝑥,𝑦} = [𝜕{𝑢,𝑣}/𝜕{𝑥,𝑦}][𝜕{𝐴}/𝜕{𝑢,𝑣}]
Per-pixel texture coordinates
Texture image (arbitrary # channels)
Attribute pixel derivatives 𝜕𝐴/𝜕{𝑥,𝑦}
Sampled texture per pixel
Standard operation in a shading system, Closely resemble attribute interpolation, differs by the multiscale nature, scale level determined by attribute pixel derivatives
Point sampled images, vertices, triangles
Antialiased image
Ket step, solve the coverage gradient problem in this step!
Insights:
Modify pixel colors based on geometry
Similar idea as Distance-to-Edge Antialiasing (DEAA) [Malan 2010]) and Geometric Post-Process Antialiasing (GPAA) [Persson 2011]
Estimate occlusion ratio based on geometry
Blend in color from neighboring pixel
Extra Notes:
Approximate occlusion ratio, linear function of the location of the crossing point—from zero at midpoint to 50% at pixel center
Essentially approximates the exact surface coverage per pixel [Jalobeanu et al. 2004] using an axis-aligned slab, only perfect for axis aligned geometry
Performance comparison
15 ms/ frame
5 s/ frame
Qualitative Experiments
visibility gradients provide useful information even for small triangles
Qualitative Experiments
Modular design and flexibility of the framework can handle complex rendering pipeline
Qualitative Experiments
Cube pose optimization: blurring and transparency before shading is not really necessary
SoftRas [Liu et. al 2019]: 63.57°
Avg error:
NVdiffrast: 48.52°
+Two stage optimization: 22.49°
+symmetry noise 2.61°
Applications: Facial Performance Capture
Formulate facial performance capture as an inverse rendering problem:
Find a global texture and per-frame mesh, so that rendering them produces input images
sequences from 9 cameras with camera positions
Base mesh
Applications: Facial Performance Capture
Single GPU, 100000 iterations, 1 hour to convergence, better than commercial (DI4D)
Archeologist
Chaitanya
Differentiable rendering
Past Works
Common Variants
High Quality
High Performance
Differentiable Monte Carlo RT through Edge Sampling (SIGGRAPH ’18)
Physically based
What is the gradient
When a triangle moves?
approximate integral with MC
Differentiable Monte Carlo RT through Edge Sampling
Not noise free
Edge sampling is hard
Performance - slow rendering
good gradients
OpenDR
Limited shading model
Approximate gradients
General purpose
fast
What is the gradient of a pixel for when the cylinder is rotated in plane
Neural Mesh Rendering (CVPR ’18)
Not scalable
Limited flexibility
Hallucinated gradients
What is the gradient at the pixel p w.r.t to the vertex x ?
Noise free
SoftRas (ICCV ’19)
each pixel
SoftRas
Good gradients
Noise free
Approximate rendering
Cannot scale well wrt parameters
What is the right blur?
Accuracy comparison wrt NVDiffRast
Comparison
Archeologist:
Impact and Future Work
Ozgur Kara
https://github.com/sicxu/Deep3DFaceRecon_pytorch
Fantasia3D: Disentangling Geometry and Appearance for High-quality Text-to-3D Content Creation
Extracting Triangular 3D Models, Materials, and Lighting From Images (CVPR 2022 Oral) (NVdiffRec)
Shape, Light, and Material Decomposition from Images using Monte Carlo Rendering and Denoising (Neurips 2022) (NVDiffRecMC)
Differentiable Rendering Packages
Private Investigator
Guang Yin
Timo Aila
Timo Aila joined NVIDIA Research in 2007 from Helsinki University of Technology, where he led the computer graphics research group. His expertise ranges from real-time rendering in computer games to to high-quality image synthesis, with contributions to the PantaRay rendering system used in Avatar, Tintin, and Hobbit. He also gained expertise in mobile graphics as the chief scientist of Hybrid Graphics, which was acquired by NVIDIA in 2006. Timo is currently working on machine learning, with a special focus on generative models such as StyleGAN. Previously he had a central role in NVIDIA's research efforts on ray tracing, including the design of the RTX hardware units.
Computer Graphics
[2000 - Now] Main topic: occlusion culling, ray tracing
Machine Learning
[2017 - Now] Main topic: Generative Adversarial Networks
GPU Hardware Design
[2000] [Real-time Graphics]
Master’s thesis ➡️ the first commercial occlusion culling library Umbra
[2000] [Real-time Graphics]
Master’s thesis ➡️ the first commercial occlusion culling library Umbra
[2009] [Ray Tracing]
In 2007, joined NVIDIA Research and led the computer graphics research group
How GPUs can be optimized for ray tracing
[2010] [Ray Tracing]
Simple!
Oh no…
Bounding Volume Hierarchies (BVH)
Used in Avatar, Tintin, and the Hobbit
[2016] [Machine Learning]
Computer Graphics
Machine Learning
[2017] [Machine Learning for Computer Graphics]
Lead to Deep learning super sampling (DLSS)?
[2017] [Machine Learning] [8676 citations]
[2019] [Machine Learning] [12062 citations]
Makes GAN practical
Widespread use in creative industries
[2020] [Computer Graphics for Machine Learning]
Computer Graphics
Machine Learning
GPU hardware design
Highly optimized differentiable rendering pipeline
Timo Aila
Broad and deep understanding of the whole system
Computer Graphics
Machine Learning
GPU Hardware Design
Diverse research directions provide a variety of tools to address bottlenecks across different domains.
Industrial Applications matter!
Critic
Harris Nisar
Raytracing vs. Rasterization
Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara – https://images.slideplayer.com/25/7723008/slides/slide_2.jpg
Raytracing vs. Rasterization
Raytracing and Global Illumination Intro. to Computer Graphics, CS180, Fall 2008 UC Santa Barbara – https://images.slideplayer.com/25/7723008/slides/slide_2.jpg
Resources
Renderer
Image
Rasterization at a high level
Rasterization
Step 1: World to Screen Space + Clipping
transforming 3D object vertices from object space to screen space
Limitations
Rasterization
Step 2: Triangles -> Pixels
Limitations
Z Buffer
Output
Scene
Scan-line Algorithm
Rasterization
Step 3: Shading
Limitations
https://miro.medium.com/v2/resize:fit:900/0*lOiF1XoVkXlWYvrB.jpg
https://learnopengl.com/Advanced-Lighting/Shadows/Shadow-Mapping
Discontinuities rendering pipeline
Geometric Post-process Anti-Aliasing (GPAA)
Graduate Student
Possible Improvements And Applications
Junkun Chen
https://docs.google.com/presentation/d/1FbA29d21cz8CczlFYq-xqqgplqQn2J1hi3mT0xdBd8Y/edit?usp=sharing
Idea of Improvements
Idea 1: Apply with advanced approaches from 3DGS
Idea 1: Apply with advanced approaches from 3DGS
Idea 1: Apply with advanced approaches from 3DGS
Idea 1: Apply with advanced approaches from 3DGS
Idea 2: Geometry manipulation via Tetrahedra
Idea 2: Geometry manipulation via Tetrahedra
Idea for Application: Progressive Scene editing
Works that demonstrates a similar idea
Industrial Practitioner
Mei Han
Smart XR Glasses: iGlasses
Glasses
More Wearable, More Efficient, More Realistic
Left Right
iGlasses your personal life assistant
Interactive 3D Avatar
Virtual Friend
EVE
(Nature Select)
Otome Game
Love and Deepspace
(Papergames)
Real-time Dialogue
DAN Mode
(ChatGPT)
Electronic Pet
RoVR
(Ridgeline Labs)
Interactive 3D Avatar
VASA-1
Xu, S., Chen, G., Guo, Y. X., Yang, J., Li, C., Zang, Z., ... & Guo, B. (2024). Vasa-1: Lifelike audio-driven talking faces generated in real time. arXiv preprint arXiv:2404.10667
Guo, J., Zhang, D., Liu, X., Zhong, Z., Zhang, Y., Wan, P., & Zhang, D. (2024). Liveportrait: Efficient portrait animation with stitching and retargeting control. arXiv preprint arXiv:2407.03168..
LivePortrait
Vivid Memory Engrams
Baby’s first step
Key points of knowledge
Unforgettable moments
Differentiable Rendering 4Science
[1] Ichbiah, S., Delbary, F., & Turlier, H. (2023). Differentiable rendering for 3d fluorescence microscopy. arXiv preprint arXiv:2303.10440.
[2] Sego, T. J., Sluka, J. P., Sauro, H. M., & Glazier, J. A. (2023). Tissue forge: interactive biological and biophysics simulation environment. PLOS Computational Biology, 19(10), e1010768.
[3] Shi, L., Li, B., Hašan, M., Sunkavalli, K., Boubekeur, T., Mech, R., & Matusik, W. (2020). Match: Differentiable material graphs for procedural material capture. ACM Transactions on Graphics (TOG), 39(6), 1-15.
MATch
convert photographs of material samples into procedural material model
Tissue Forge
Interactive biological and biophysics simulation environment
3D fluorescence microscopy
Hacker 1: Bundle Adjustment using Pytorch3d
Yufeng Liu
Bundle Adjustment by Differentiable Rendering
In this project I implemented bundle adjustment in Pytorch3D
Objective:
Experiments:
Simple Mesh
Set up:
Implementation Overview:
Deformation is applied to input mesh
The predicted cameras render a set of images
Calculate average loss across all rendered images
Loss consists of the following parts:
I used Adam optimizer to do back propagation
Update deformation and cameras
Views of predicted cameras
Views of groundtruth
cameras
Complex Mesh
Views of predicted cameras
Views of groundtruth
cameras
Real Images?
Need to do more
Hacker 2: Minimal Implementation of Soft Rasterizer
Christopher Conway
Liu S. et al, “Soft Rasterizer: A Differentiable Renderer for Image-based 3D Reasoning”, CVPR 2019
Soft Rasterizer: A Differentiable Renderer for Image-based 3D Reasoning
Liu S. et al, “Soft Rasterizer: A Differentiable Renderer for Image-based 3D Reasoning”, CVPR 2019
Minimal Implementation for Rectangular Primitive
Initial Primitive
Target Mask
Rendered Rectangle
Implementation Overview:
Rendering Animation: