summaries: This paper aims to improve the density distribution of generative radiance field models by generating relitable reflectance fields and using different lightings to shade them during training. The core idea is that artifacts will arise when the generated density distribution ("shape") is unnatural and is getting shaded by different lightings, which should be detected and resolved by a discriminator. Experiments verify that this shading regularization can yield naturally looking shapes induced by the generated radiance fields.  This paper proposes a GAN capable of generating a relightable radiance field when trained on an unlabeled dataset of face images. The relightable radiance field generator is conditioned on the 3D location and a latent code and outputs a volume density field (à la NeRF) and an "albedo" field (I strongly advise against the use of this word; see below) that allows explicit control of the light location. The training is conducted in the GAN style, where the training signal comes from only a discriminator loss. The intuition is that the generator is better off generating a meaningful 3D volume that, when rendered from a random camera view, generates a photorealistic face image that falls into the training data distribution, than generating some intricately-designed volume that gives faces of different identities when viewed from different angles.  The authors demonstrate that the model is able to learn 3D shapes in an unsupervised fashion from just 2D images. The work is mainly compared against pi-GAN, which is shown to suffer from what the authors call "color-shape ambiguities." For efficient rendering, the authors also propose an auxiliary network that predicts the surface location given the latent code and a viewing direction, such that the network can sample around the predicted surface to avoid expensive sampling of unoccupied space. This paper proposes a new method to train generative radiance fields that can achieve more accurate 3D shape reconstruction. The key idea is that instead of directly synthesizing the images from different viewpoints through volume ray tracing, which may suffer from color-shape ambiguity, it synthesizes albedo and normal and then renders the image with different lighting conditions. This new method requires the synthesized albedo and normal to be able to render realistic images under various lighting conditions, providing an extra regularization for shape reconstruction. To further improve the rendering speed, it uses an extra 2D CNN to predict a depth map from latent code and camera poses so that it only needs to sample near the surface in volume ray tracing. Experiments show that the proposed method greatly improves shape reconstruction with similar image synthesis quality compared to state-of-the-arts. The paper proposes a novel generative model for neural radiance field, where the key idea is to synthetically add shading effects based on random lighting configurations. Shading will make images unrealistic when the geometry is corrupted. Therefore, the system gets trained to generate accurate shapes in its implicit radiance field representation. The system makes convincing results both qualitatively and quantitatively.
abstractText: The advancement of generative radiance fields has pushed the boundary of 3Daware image synthesis. Motivated by the observation that a 3D object should look realistic from multiple viewpoints, these methods introduce a multi-view constraint as regularization to learn valid 3D radiance fields from 2D images. Despite the progress, they often fall short of capturing accurate 3D shapes due to the shapecolor ambiguity, limiting their applicability in downstream tasks. In this work, we address this ambiguity by proposing a novel shading-guided generative implicit model that is able to learn a starkly improved shape representation. Our key insight is that an accurate 3D shape should also yield a realistic rendering under different lighting conditions. This multi-lighting constraint is realized by modeling illumination explicitly and performing shading with various lighting conditions. Gradients are derived by feeding the synthesized images to a discriminator. To compensate for the additional computational burden of calculating surface normals, we further devise an efficient volume rendering strategy via surface tracking, reducing the training and inference time by 24% and 48%, respectively. Our experiments on multiple datasets show that the proposed approach achieves photorealistic 3D-aware image synthesis while capturing accurate underlying 3D shapes. We demonstrate improved performance of our approach on 3D shape reconstruction against existing methods, and show its applicability on image relighting. Our code will be released at https://github.com/XingangPan/ShadeGAN.
authors.name: Xingang Pan
authors.name: Xudong Xu
authors.name: Chen Change Loy
authors.name: Christian Theobalt
authors.name: Bo Dai
references.authors: T. Karras S. Laine T. Aila
references.title: A style-based generator architecture for generative adversarial networks
references.venue: CVPR, 2019.
references.authors: T. Karras S. Laine M. Aittala J. Hellsten J. Lehtinen T. Aila
references.title: Analyzing and improving the image quality of stylegan
references.venue: CVPR, 2020.
references.authors: A. Brock J. Donahue K. Simonyan
references.title: Large scale gan training for high fidelity natural image synthesis
references.venue: ICLR, 2019.
references.authors: E.R. Chan M. Monteiro P. Kellnhofer J. Wu G. Wetzstein
references.title: pi-gan: Periodic implicit generative adversarial networks for 3d-aware image synthesis
references.venue: CVPR, 2021.
references.authors: K. Schwarz Y. Liao M. Niemeyer A. Geiger
references.title: Graf: Generative radiance fields for 3d-aware image synthesis
references.venue: NeurIPS, 2020.
references.authors: B. Mildenhall P.P. Srinivasan M. Tancik J.T. Barron R. Ramamoorthi R. Ng
references.title: Nerf: Representing scenes as neural radiance fields for view synthesis
references.venue: ECCV, 2020.
references.authors: R.J. Woodham
references.title: Photometric method for determining surface orientation from multiple images
references.venue: Optical engineering, vol. 19, no. 1, p. 191139, 1980.
references.authors: L. Liu J. Gu K. Zaw Lin T.-S. Chua C. Theobalt
references.title: Neural sparse voxel fields
references.venue: NeurIPS, 2020.
references.authors: A. Yu R. Li M. Tancik H. Li R. Ng A. Kanazawa
references.title: PlenOctrees for real-time rendering of neural radiance fields
references.venue: arXiv, 2021.
references.authors: C. Reiser S. Peng Y. Liao A. Geiger
references.title: Kilonerf: Speeding up neural radiance fields with thousands of tiny mlps
references.venue: arXiv preprint arXiv:2103.13744, 2021.
references.authors: S.J. Garbin M. Kowalski M. Johnson J. Shotton J. Valentin
references.title: Fastnerf: High-fidelity neural rendering at 200fps
references.venue: arXiv preprint arXiv:2103.10380, 2021.
references.authors: T. Neff P. Stadlbauer M. Parger A. Kurz C.R.A. Chaitanya A. Kaplanyan M. Steinberger
references.title: Donerf: Towards real-time rendering of neural radiance fields using depth oracle networks
references.venue: arXiv preprint arXiv:2103.03231, 2021. 10
references.authors: P. Paysan R. Knothe B. Amberg S. Romdhani T. Vetter
references.title: A 3d face model for pose and illumination invariant face recognition
references.venue: 2009 Sixth IEEE International Conference on Advanced Video and Signal Based Surveillance, Ieee, 2009.
references.authors: M. Boss R. Braun V. Jampani J.T. Barron C. Liu H. Lensch
references.title: Nerd: Neural reflectance decomposition from image collections
references.venue: arXiv preprint arXiv:2012.03918, 2020.
references.authors: S. Bi Z. Xu P. Srinivasan B. Mildenhall K. Sunkavalli M. Hašan Y. Hold-Geoffroy D. Kriegman R. Ramamoorthi
references.title: Neural reflectance fields for appearance acquisition
references.venue: arXiv preprint arXiv:2008.03824, 2020.
references.authors: P.P. Srinivasan B. Deng X. Zhang M. Tancik B. Mildenhall J.T. Barron
references.title: Nerv: Neural reflectance and visibility fields for relighting and view synthesis
references.venue: CVPR, 2021.
references.authors: D.B. Lindell J.N. Martel G. Wetzstein
references.title: Autoint: Automatic integration for fast neural volume rendering
references.venue: arXiv preprint arXiv:2012.01714, 2020.
references.authors: I. Goodfellow J. Pouget-Abadie M. Mirza B. Xu D. Warde-Farley S. Ozair A. Courville Y. Bengio
references.title: Generative adversarial nets
references.venue: NIPS, 2014.
references.authors: J. Wu C. Zhang T. Xue B. Freeman J. Tenenbaum
references.title: Learning a probabilistic latent space of object shapes via 3d generative-adversarial modeling
references.venue: NIPS, 2016.
references.authors: H.A. Alhaija S.K. Mustikovela A. Geiger C. Rother
references.title: Geometric image synthesis
references.venue: ACCV, Springer, 2018.
references.authors: X. Chen D. Cohen-Or B. Chen N.J. Mitra
references.title: Towards a neural graphics pipeline for controllable image generation
references.venue: Computer Graphics Forum, vol. 40, no. 2, 2021.
references.authors: J.-Y. Zhu Z. Zhang C. Zhang J. Wu A. Torralba J. Tenenbaum B. Freeman
references.title: Visual object networks: Image generation with disentangled 3d representations
references.venue: NeurIPS, 2018.
references.authors: T. Nguyen-Phuoc C. Li L. Theis C. Richardt Y.-L. Yang
references.title: Hologan: Unsupervised learning of 3d representations from natural images
references.venue: ICCV, 2019.
references.authors: T. Nguyen-Phuoc C. Richardt L. Mai Y.-L. Yang N. Mitra
references.title: Blockgan: Learning 3d object-aware scene representations from unlabelled images
references.venue: NeurIPS, Nov 2020.
references.authors: Y. Liao K. Schwarz L. Mescheder A. Geiger
references.title: Towards unsupervised learning of generative models for 3d controllable image synthesis
references.venue: CVPR, 2020.
references.authors: P. Henzler N.J. Mitra T. Ritschel
references.title: Escaping plato’s cave: 3d shape from adversarial rendering
references.venue: ICCV, 2019.
references.authors: A. Szabó G. Meishvili P. Favaro
references.title: Unsupervised generative 3d shape learning from natural images
references.venue: arXiv preprint arXiv:1910.00287, 2019.
references.authors: M. Niemeyer A. Geiger
references.title: Giraffe: Representing scenes as compositional generative neural feature fields
references.venue: CVPR, 2021.
references.authors: A. Tewari M. Elgharib G. Bharaj F. Bernard H.-P. Seidel P. Pérez M. Zollhofer C. Theobalt
references.title: Stylerig: Rigging stylegan for 3d control over portrait images
references.venue: CVPR, 2020.
references.authors: T. Yenamandra A. Tewari F. Bernard H.-P. Seidel M. Elgharib D. Cremers C. Theobalt
references.title: i3dmm: Deep implicit 3d morphable model of human heads
references.venue: CVPR, 2021.
references.authors: S. Tulsiani N. Kulkarni A. Gupta
references.title: Implicit mesh reconstruction from unannotated image collections
references.venue: arXiv preprint arXiv:2007.08504, 2020.
references.authors: S. Goel A. Kanazawa J. Malik
references.title: Shape and viewpoint without keypoints
references.venue: ECCV, 2020.
references.authors: L. Tran X. Liu
references.title: Nonlinear 3d face morphable model
references.venue: CVPR, 2018.
references.authors: A. Kanazawa S. Tulsiani A.A. Efros J. Malik
references.title: Learning category-specific mesh reconstruction from image collections
references.venue: ECCV, 2018.
references.authors: A. Kanazawa M.J. Black D.W. Jacobs J. Malik
references.title: End-to-end recovery of human shape and pose
references.venue: CVPR, 2018.
references.authors: S. Sanyal T. Bolkart H. Feng M.J. Black
references.title: Learning to regress 3d face shape and expression from an image without 3d supervision
references.venue: CVPR, 2019.
references.authors: J. Shang T. Shen S. Li L. Zhou M. Zhen T. Fang L. Quan
references.title: Self-supervised monocular 3d face reconstruction by occlusion-aware multi-view geometry consistency
references.venue: ECCV, 2020. 11
references.authors: M. Sahasrabudhe Z. Shu E. Bartrum R. Alp Guler D. Samaras I. Kokkinos
references.title: Lifting autoencoders: Unsupervised learning of a fully-disentangled 3d morphable model using deep non-rigid structure from motion
references.venue: ICCV Workshops, 2019.
references.authors: S. Wu C. Rupprecht A. Vedaldi
references.title: Unsupervised learning of probably symmetric deformable 3d objects from images in the wild
references.venue: CVPR, 2020.
references.authors: X. Li S. Liu K. Kim S. De Mello V. Jampani M.-H. Yang J. Kautz
references.title: Self-supervised single-view 3d reconstruction via semantic consistency
references.venue: ECCV, 2020.
references.authors: X. Pan B. Dai Z. Liu C.C. Loy P. Luo
references.title: Do 2d gans know 3d shape? unsupervised 3d shape reconstruction from 2d image gans
references.venue: ICLR, 2021.
references.authors: L. Mescheder A. Geiger S. Nowozin
references.title: Which training methods for gans do actually converge
references.venue: ICML, 2018.
references.authors: Z. Liu P. Luo X. Wang X. Tang
references.title: Deep learning face attributes in the wild
references.venue: ICCV, 2015.
references.authors: W. Zhang J. Sun X. Tang
references.title: Cat head detection-how to effectively exploit shape and texture features
references.venue: ECCV, 2008.
references.authors: V. Sitzmann J. Martel A. Bergman D. Lindell G. Wetzstein
references.title: Implicit neural representations with periodic activation functions
references.venue: NeurIPS, 2020.
references.authors: M. Heusel H. Ramsauer T. Unterthiner B. Nessler S. Hochreiter
references.title: Gans trained by a two time-scale update rule converge to a local nash equilibrium
references.venue: NeurIPS, 2017.
references.authors: B.T. Phong
references.title: Illumination for computer generated pictures
references.venue: Communications of the ACM, vol. 18, no. 6, pp. 311–317, 1975.
references.authors: E. Perez F. Strub H. De Vries V. Dumoulin A. Courville
references.title: Film: Visual reasoning with a general conditioning layer
references.venue: AAAI, 2018.
references.authors: R. Liu J. Lehman P. Molino F.P. Such E. Frank A. Sergeev J. Yosinski
references.title: An intriguing failing of convolutional neural networks and the coordconv solution
references.venue: NeurIPS, 2018.
references.authors: K. He X. Zhang S. Ren J. Sun
references.title: Deep residual learning for image recognition
references.venue: CVPR, 2016.
references.authors: Y. Wu K. He
references.title: Group normalization
references.venue: ECCV, 2018.
references.authors: S. Ioffe C. Szegedy
references.title: Batch normalization: Accelerating deep network training by reducing internal covariate shift
references.venue: ICML, 2015.
references.authors: D.P. Kingma J. Ba
references.title: Adam: A method for stochastic optimization
references.venue: arXiv preprint arXiv:1412.6980, 2014.
references.authors: Y. Choi Y. Uh J. Yoo J.-W. Ha
references.title: Stargan v2: Diverse image synthesis for multiple domains
references.venue: CVPR, 2020. 12
sections.heading: 1 Introduction
sections.text: Advanced deep generative models, e.g., StyleGAN [1, 2] and BigGAN [3], have achieved great successes in natural image synthesis. While producing impressive results, these 2D representationbased models cannot synthesize novel views of an instance in a 3D-consistent manner. They also fall short of representing an explicit 3D object shape. To overcome such limitations, researchers have proposed new deep generative models that represent 3D scenes as neural radiance fields [4, 5]. Such 3D-aware generative models allow explicit control of viewpoint while preserving 3D consistency during image synthesis. Perhaps a more fascinating merit is that they have shown the great potential of learning 3D shapes in an unsupervised manner from just a collection of unconstrained 2D images. If we could train a 3D-aware generative model that learns accurate 3D object shapes, it would broaden various downstream applications such as 3D shape reconstruction and image relighting.
  Existing attempts for 3D-aware image synthesis [4, 5] tend to learn coarse 3D shapes that are inaccurate and noisy, as shown in Fig.1 (a). We found that such inaccuracy arises from an inevitable ambiguity inherent in the training strategy adopted by these methods. In particular, a form of
  35th Conference on Neural Information Processing Systems (NeurIPS 2021).
  regularization, which we refer to as "multi-view constraint", is used to enforce the 3D representation to look realistic from different viewpoints. The constraint is commonly implemented by first projecting the generator’s outputs (e.g., radiance fields [6]) to randomly sampled viewpoints, and then feeding them to a discriminator as fake images for training. While such a constraint enables these models to synthesize images in a 3D-aware manner, it suffers from the shape-color ambiguity, i.e., small variations of shape could lead to similar RGB images that look equally plausible to the discriminator, as the color of many objects is locally smooth. Consequently, inaccurate shapes are concealed under this constraint.
  In this work, we propose a novel shading-guided generative implicit model (ShadeGAN) to address the aforementioned ambiguity. In particular, ShadeGAN learns more accurate 3D shapes by explicitly modeling shading, i.e., the interaction of illumination and shape. We believe that an accurate 3D shape should look realistic not only from different viewpoints, but also under different lighting conditions, i.e., satisfying the "multi-lighting constraint". This idea shares similar intuition with photometric stereo [7], which shows that accurate surface normal could be recovered from images taken under different lighting conditions. Note that the multi-lighting constraint is feasible as real-world images used for training are often taken under various lighting conditions. To fulfill this constraint, ShadeGAN takes a relightable color field as the intermediate representation, which approximates the albedo but does not necessarily satisfy viewpoint independence. The color field is shaded under a randomly sampled lighting condition during rendering. Since image appearance via such a shading process is strongly dependent on surface normals, inaccurate 3D shape representations will be much more clearly revealed than in earlier shading-agnostic generative models. Hence, by satisfying the multi-lighting constraint, ShadeGAN is encouraged to infer more accurate 3D shapes as shown in Fig.1 (b).
  The above shading process requires the calculation of the normal direction via back-propagation through the generator, and such calculation needs to be repeated dozens of times for a pixel in volume rendering [4, 5], introducing additional computational overhead. Existing efficient volume rendering techniques [8, 9, 10, 11, 12] mainly target static scenes, and could not be directly applied to generative models due to their dynamic nature. Therefore, to improve the rendering speed of ShadeGAN, we formulate an efficient surface tracking network to estimate the rendered object surface conditioned on the latent code. This enables us to save rendering computations by just querying points near the predicted surface, leading to 24% and 48% reduction of training and inference time without affecting the quality of rendered images.
  Comprehensive experiments are conducted across multiple datasets to verify the effectiveness of ShadeGAN. The results show that our approach is capable of synthesizing photorealistic images while capturing more accurate underlying 3D shapes than previous generative methods. The learned
  distribution of 3D shapes enables various downstream tasks like 3D shape reconstruction, where our approach significantly outperforms other baselines on the BFM dataset [13]. Besides, modeling the shading process enables explicit control over lighting conditions, achieving image relighting effect. Our contributions can be summarized as follows: 1) We address the shape-color ambiguity in existing 3D-aware image synthesis methods with a shading-guided generative model that satisfies the proposed multi-lighting constraint. In this way, ShadeGAN is able to learn more accurate 3D shapes for better image synthesis. 2) We devise an efficient rendering technique via surface tracking, which significantly saves training and inference time for volume rendering-based generative models. 3) We show that ShadeGAN learns to disentangle shading and color that well approximates the albedo, achieving natural relighting effects in image synthesis.
sections.heading: 2 Related Work
sections.text: Neural volume rendering. Starting from the seminal work of neural radiance fields (NeRF) [6], neural volume rendering has gained much popularity in representing 3D scenes and synthesizing novel views. By integrating coordinate-based neural networks with volume rendering, NeRF performs high-fidelity view synthesis in a 3D consistent manner. Several attempts have been proposed to extend or improve NeRF. For instance, [14, 15, 16] further model illumination, and learn to disentangle reflectance with shading given well-aligned multi-view and multi-lighting images. Besides, many studies accelerate the rendering of static scenes from the perspective of spatial sparsity [8, 9], architectural design [10, 11], or efficient rendering [17, 12]. However, it is not trivial to apply these illumination and acceleration techniques to volume rendering-based generative models [5, 4], as they typically learn from unposed and unpaired images, and represent dynamic scenes that change with respect to the input latent codes.
  In this work, we take the first attempt to model illumination in volume rendering-based generative models, which serves as a regularization for accurate 3D shape learning. We further devise an efficient rendering technique for our approach, which shares similar insight with [12], but does not rely on ground truth depth for training and it is not limited to a small viewpoint range.
  Generative 3D-aware image synthesis. Generative adversarial networks (GANs) [18] are capable of generating photorealistic images of high-resolution, but lack explicit control over camera viewpoint. In order to enable them to synthesis images in a 3D-aware manner, many recent approaches investigate how 3D representations could be incorporated into GANs [19, 20, 21, 22, 23, 24, 25, 26, 27, 5, 4, 28, 29, 30]. While some works directly learn from 3D data [19, 20, 21, 22, 30], in this work we focus on approaches that only have access to unconstrained 2D images, which is a more practical setting. Several attempts [23, 24, 25] adopt 3D voxel features with learned neural rendering. These methods produce realistic 3D-aware synthesis, but the 3D voxels are not interpretable, i.e., they cannot be transferred to 3D shapes. By leveraging differentiable renderer, [26] and [27] learn interpretable 3D voxels and meshes respectively, but [26] suffers from limited visual quality due to low voxel resolution while the learned 3D shapes of [27] exhibit noticeable distortions. The success of NeRF has motivated researchers to use radiance fields as the intermediate 3D representation in GANs [5, 4, 28]. While achieving impressive 3D-aware image synthesis with multi-view consistency, the extracted 3D shapes of these approaches are often imprecise and noisy. Our main goal in this work is to address the inaccurate shape by explicitly modeling illumination in the rendering process. This innovation helps achieve better 3D-aware image synthesis with broader applications.
  Unsupervised 3D shape learning from 2D images. Our work is also related to unsupervised approaches that learn 3D object shapes from unconstrained, monocular view 2D images. While several approaches use external 3D shape templates or 2D key-points as weak supervisions to facilitate learning [31, 32, 33, 34, 35, 36, 37], in this work we consider the harder setting where only 2D images are available. To tackle this problem, most approaches adopt an “analysis-by-synthesis” paradigm [38, 39, 40]. Specifically, they design photo-geometric autoencoders to infer the 3D shape and viewpoint of each image with a reconstruction loss. While succeed in learning the 3D shapes for some object categories, these approaches typically rely on certain regularization to prevent trivial solutions, like the commonly used symmetry assumption on object shapes [39, 40, 31, 32]. Such assumption tends to produce symmetric results that may overlook the asymmetric aspects of objects. Recently, GAN2Shape [41] shows that it is possible to recover 3D shapes for images generated by 2D GANs. This method, however, requires inefficient instance-specific training, and recovers depth maps instead of full 3D representations.
  The proposed 3D-aware generative model also serves as a powerful approach for unsupervised 3D shape learning. Compared with aforementioned autoencoder-based methods, our GAN-based approach avoids the need to infer the viewpoint of each image, and does not rely on strong regularizations. In experiments, we demonstrate superior performance over recent state-of-the-art approaches Unsup3d [39] and GAN2Shape [41].
sections.heading: 3 Methodology
sections.text: We consider the problem of 3D-aware image synthesis by learning from a collection of unconstrained and unlabeled 2D images. We argue that modeling shading, i.e., the interaction of illumination and shape, in a generative implicit model enables unsupervised learning of more accurate 3D object shapes. In the following, we first provide some preliminaries on neural radiance fields (NeRF) [6], and then introduce our shading-guided generative implicit model.
sections.heading: 3.1 Preliminaries on Neural Radiance Fields
sections.text: As a deep implicit model, NeRF [6] uses an MLP network to represent a 3D scene as a radiance field. The MLP fθ : (x,d)→ (σ, c) takes a 3D coordinate x ∈ R3 and a viewing direction d ∈ S2 as inputs, and outputs a volume density σ ∈ R+ and a color c ∈ R3. To render an image under a given camera pose, each pixel color C of the image is obtained via volume rendering along its corresponding camera ray r(t) = o+ td with near and far bounds tn and tf as below:
  C(r) = ∫ tf tn T (t)σ(r(t))c(r(t),d)dt, where T (t) = exp(− ∫ t tn σ(r(s))ds). (1)
  In practice, this volume rendering is implemented with a discretized form using stratified and hierarchical sampling. As this rendering process is differentiable, NeRF could be directly optimized via posed images of a static scene. After training, NeRF allows the rendering of images under new camera poses, achieving high-quality novel view synthesis.
sections.heading: 3.2 Shading-Guided Generative Implicit Model
sections.text: In this work, we are interested in developing a generative implicit model that explicitly models the shading process for 3D-aware image synthesis. To achieve this, we make two extensions to the MLP network in NeRF. First, similar to most deep generative models, it is further conditioned on a latent code z sampled from a prior distribution N (0, I)d. Second, instead of directly outputting the color c, it outputs a relightable pre-cosine color term a ∈ R3, which is conceptually similar to albedo in the way that it could be shaded under a given lighting condition. While albedo is viewpoint-independent, in this work we do not strictly enforce such independence for a in order to account for dataset bias. Thus, our generator gθ : (x,d, z)→ (σ,a) takes a coordinate x, a viewing direction d, and a latent
  code z as inputs, and outputs a volume density σ and a pre-cosine color a. Note that here σ is independent of d, while the dependence of a on d is optional. To obtain the color C of a camera ray r(t) = o+ td with near and far bounds tn and tf , we calculate the final pre-cosine colorA via:
  A(r, z) = ∫ tf tn T (t, z)σ(r(t), z)a(r(t),d, z)dt, where T (t, z) = exp(− ∫ t tn σ(r(s), z)ds).
  (2)
  We also calculate the normal direction n with: n(r, z) = n̂(r, z)/‖n̂(r, z)‖2, where n̂(r, z) = − ∫ tf tn T (t, z)σ(r(t), z)∇r(t)σ(r(t), z)dt,
  (3)
  where ∇r(t)σ(r(t), z) is the derivative of volume density σ with respect to its input coordinate, which naturally captures the local normal direction, and could be calculated via back-propagation. Then the final color C is obtained via Lambertian shading as:
  C(r, z) = A(r, z)(ka + kdmax(0, l · n(r, z))), (4)
  where l ∈ S2 is the lighting direction, ka and kd are the ambient and diffuse coefficients. We provide more discussions on this shading formulation at the end of this subsection.
  Camera and Lighting Sampling. Eq.(2 - 4) describe the process of rendering a pixel color given a camera ray r(t) and a lighting condition µ = (l, ka, kd). Generating a full image Ig ∈ R3×H×W requires one to sample a camera pose ξ and a lighting condition µ in addition to the latent code z, i.e., Ig = Gθ(z, ξ,µ). In our setting, the camera pose ξ could be described by pitch and yaw angles, and is sampled from a prior Gaussian or uniform distribution pξ, as also done in previous works [4, 5]. Sampling the camera pose randomly during training would motivate the learned 3D scene to look realistic from different viewpoints. While this multi-view constraint is beneficial for learning a valid 3D representation, it is often insufficient to infer the accurate 3D object shape. Thus, in our approach, we further introduce a multi-lighting constraint by also randomly sampling a lighting condition µ from a prior distribution pµ. In practice, pµ could be estimated from the dataset using existing approaches like [39]. We also show in our experiments that a simple and manually tuned prior distribution could also produce reasonable results. As the shading process is sensitive to the normal direction due to the diffuse term kdmax(0, l · n(r, z)) in Eq.(4), this multi-lighting constraint would regularize the model to learn more accurate 3D shapes that produce natural shading, as shown in Fig.1 (b).
  Training. Our generative model follows the paradigm of GANs [18], where the generator is trained together with a discriminator D with parameters φ in an adversarial manner. During training, the generator generates fake images Ig = Gθ(z, ξ,µ) by sampling the latent code z, camera pose ξ and lighting condition µ from their corresponding prior distributions pz , pξ, and pµ. Let I denotes real images sampled from the data distribution pI . We train our model with a non-saturating GAN loss with R1 regularization [42]:
  L(θ, φ) = Ez∼pz,ξ∼pξ,µ∼pµ [ f ( Dφ(Gθ(z, ξ,µ)) )] + EI∼pD [ f(−Dφ(I)) + λ‖∇Dφ(I)‖2 ] ,
  (5) where f(u) = − log(1 + exp(−u)), and λ controls the strength of regularization. More implementation details are provided in the supplementary material.
  Discussion. Note that in Eq.(2 - 4), we perform shading after A and n are obtained via volume rendering. An alternative way is to perform shading at each local spatial point as c(r(t),d, z) = a(r(t),d, z)(ka + kdmax(0, l · n(r(t), z))), where n(r(t), z) = −∇r(t)σ(r(t), z)/‖∇r(t)σ(r(t), z)‖2 is the local normal. Then we could perform volume rendering using c(r(t), z) to get the final pixel color. In practice, we observe that this formulation obtains suboptimal results. An intuitive reason is that in this formulation, the normal direction is normalized at each local point, neglecting the magnitude of∇r(t)σ(r(t), z), which tends to be larger near the object surfaces. We provide more analysis in experiments and the supplementary material.
  The Lambertian shading we used is an approximation to the real illumination scenario. While serving as a good regularization for improving the learned 3D shape, it could possibly introduce an additional gap between the distribution of generated images and that of real images. To compensate
  for such risk, we could optionally let the predicted a be conditioned on the lighting condition, i.e., a = a(r(t),d,µ, z). Thus, in cases where the lighting condition deviates from the real data distribution, the generator could learn to adjust the value of a and reduce the aforementioned gap. We show the benefit of this design in the experiments.
sections.heading: 3.3 Efficient Volume Rendering via Surface Tracking
sections.text: Similar to NeRF, we implement volume rendering with a discretized integral, which typically requires to sample dozens of points along a camera ray, as shown in Fig. 3 (a). In our approach, we also need to perform back-propagation across the generator in Eq.(3) to get the normal direction for each point, which introduces additional computational cost. To achieve more efficient volume rendering, a natural idea is to exploit spatial sparsity. Usually, the weight T (t, z)σ(r(t), z) in volume rendering would concentrate on the object surface position during training. Thus, if we know the rough surface position before rendering, we could sample points near the surface to save computation. While for a static scene it is possible to store such spatial sparsity in a sparse voxel grid [8, 9], this technique cannot be directly applied to our generative model, as the 3D scene keeps changing with respect to the input latent code.
  To achieve more efficient volume rendering in our generative implicit model, we further propose a surface tracking network S that learns to mimic the surface position conditioned on the latent code. In particular, the volume rendering naturally allows the depth estimation of the object surface via:
  ts(r, z) = ∫ tf tn T (t, z)σ(r(t), z)t dt, (6)
  where T (t, z) is defined the same way as in Eq.(2). Thus, given a camera pose ξ and a latent code z, we could render the full depth map ts(z, ξ). As shown in Fig. 3 (b), we mimic ts(z, ξ) with the surface tracking network Sψ , which is a light-weighted convolutional neural network that takes z, ξ as inputs and outputs a depth map. The depth mimic loss is:
  L(ψ) = Ez∼pz,ξ∼pξ [‖Sψ(z, ξ)− ts(z, ξ)‖1 + Prec(Sψ(z, ξ), ts(d(z, ξ))] , (7) where Prec is the perceptual loss that motivates Sψ to better capture edges of the surface.
  During training, Sψ is optimized jointly with the generator and the discriminator. Thus, each time after we sample a latent code z and a camera pose ξ, we can get an initial guess of the depth map as Sψ(z, ξ). Then for a pixel with predicted depth s, we could perform volume rendering in Eq.(2,3,6) with near bound tn = s−∆i/2 and far bound tf = s+ ∆i/2, where ∆i is the interval for volume rendering that decreases as the training iteration i grows. Specifically, we start with a large interval ∆max and decrease to ∆min with an exponential schedule. As ∆i decreases, the number of points used for rendering m also decreases accordingly. Note that the computational cost of our efficient surface tracking network is marginal compared to the generator, as the former only needs a single forward pass to render an image while the latter will be queried for H ×W ×m times. Thus, the reduction of m would significantly accelerate the training and inference speed for ShadeGAN.
sections.heading: 4 Experiments
sections.text: In this section, we evaluate the proposed ShadeGAN on 3D-aware image synthesis. We also show that ShadeGAN learns much more accurate 3D shapes than previous methods, and in the meantime allows explicit control over lighting conditions. The datasets used include CelebA [43], BFM [13], and Cats [44], all of which contain only unconstrained 2D RGB images.
  Implementation. In terms of model architectures, we adopt a SIREN-based MLP [45] as the generator and a convolutional neural network as the discriminator following [4]. For the prior distribution of lighting conditions, we use Unsup3d [39] to estimate the lighting conditions of real data and subsequently fit a multivariate Gaussian distribution of µ = (l, ka, kd) as the prior. A hand-crafted prior distribution is also included in the ablation study. In quantitative study, we let the pre-cosine color a be conditioned on the lighting condition µ as well as the viewing direction d unless otherwise stated. In qualitative study, we observe that removing view conditioning achieves slightly better 3D shapes for CelebA and BFM datasets. Thus, we show results without view conditioning for these two datasets in the main paper, and put those with view conditioning in Fig. 4 of the supplementary material. Other implementation details are also provided in the supplementary.
  Figure 5: Generated face images and their 3D meshes.
  Normal AlbedoMeshImage
  (a) ShadeGAN
  (b) Local normal
  (c) Manual prior
  Figure 6: Qualitative ablation. See the main text for discussions.
  Comparison with baselines. We compare ShadeGAN with two state-of-the-art generative implicit models, namely GRAF [5] and pi-GAN [4]. Specifically, Fig. 4 includes both synthesized images as well as their corresponding 3D meshes, which are obtained by performing marching cubes on the volume density σ. While GRAF and pi-GAN could synthesize images with controllable poses, their learned 3D shapes are inaccurate and noisy. In contrast, our approach not only synthesizes photorealistic 3D-consistent images, but also learns much more accurate 3D shapes and surface normals, indicating the effectiveness of the proposed multi-lighting constraint as a regularization. More synthesized images and their corresponding shapes are included in Fig.5. Besides more accurate 3D shapes, ShadeGAN can also learn the albedo and diffuse shading components inherently. As shown in Fig. 4, although not perfect, ShadeGAN has managed to disentangle shading and albedo with satisfying quality, as such disentanglement is a natural solution to the multi-lighting constraint.
  The quality of learned 3D shapes is quantitatively evaluated on the BFM dataset. Specifically, we use each of the generative implicit models to generate 50k images and their corresponding depth maps. Image-depth pairs from each model are used as training data to train an additional convolutional neural network (CNN) that learns to predict the depth map of an input image. We then test each trained CNN on the BFM test set and compare its predictions to the ground-truth depth maps as a measurement of the quality of learned 3D shapes. Following [39], we report the scale-invariant depth error (SIDE) and mean angle deviation (MAD) metrics. The results are included in Tab. 1, where ShadeGAN significantly outperforms GRAF and pi-GAN. Besides, ShadeGAN also outperforms other advanced unsupervised 3D shape learning approaches including Unsup3d [39] and GAN2Shape [41], demonstrating its large potential in unsupervised 3D shapes learning. In terms of image quality, Tab. 1 includes the FID [46] scores of images synthesized by different models, where the FID score of ShadeGAN is slightly inferior to pi-GAN in BFM and CelebA. Intuitively, this is caused by the gap between our approximated shading (i.e. Lambertian shading) and the real illumination, which can be potentially avoided by adopting more realistic shading models and improving the lighting prior.
  In Tab. 2, we also show the quantitative results of different models on CelebA and Cats. To evaluate the learned shape, we use each generative implicit model to generate 2k front-view images and their corresponding depth maps. While these datasets do not have ground truth depth, we report MAD obtained by testing pretrained Unsup3d models [39] on these generated image-depth pairs as
  Table 3: Ablation study on the BFM dataset.
  No. Method FID ↓ SIDE ↓ MAD ↓ (1) ShadeGAN 17.7 0.607 14.52 (2) local shading 30.1 0.754 18.18 (3) w/o light 19.2 0.618 14.53 (4) w/o view 18.6 0.622 14.88 (5) manual prior 20.2 0.643 15.38 (6) +efficient 18.2 0.673 14.72
  Table 4: Training and inference time cost on CelebA. The efficient volume rendering significantly improves training and inference speed.
  Method Train (h) Inference (s) FID ShadeGAN 92.3 0.343 16.4 +efficient 70.2 0.179 16.2 pi-GAN 56.8 0.204 15.7 +efficient 46.9 0.114 15.9
  A lb
  ed o
  (a) w/o light condition (b) with light condition
  S h
  ad in
  g Im
  ag e
  (c) with specular
  Figure 8: Illumination-aware image synthesis. ShadeGAN allows explicit control over the lighting. The pre-cosine color (albedo) is independent of lighting in (a) and is conditioned on lighting in (b). We show results of adding a specular term in (c).
  a reference. As we can observe, results on CelebA and Cat are consistent with those on the BFM dataset.
  Ablation studies. We further study the effects of several design choices in ShadeGAN. First, we perform local points-specific shading as mentioned in the discussion of Sec. 3.2. As Tab. 3 No.(2) and Fig. 6 (b) show, the results of such a local shading strategy are notably worse than the original one, which indicates that taking the magnitude of∇xσ into account is beneficial. Besides, the results of Tab. 3 No.(3) and No.(4) imply that removing a’s dependence on the lighting µ or the viewpoint d could lead to a slight performance drop. The results of using a simple manually tuned lighting prior are provided in Tab. 3 No.(5) and Fig. 6 (c), which are only moderately worse than the results of using a data-driven prior, and the generated shapes are still significantly better than the ones produced by existing approaches.
  To verify the effectiveness of the proposed efficient volume rendering technique, we include its effects on image quality and training/inference time in Tab. 3 No.(6) and Tab. 4. It is observed that the efficient volume rendering has marginal effects on the performance, but significantly reduces the training and inference time by 24% and 48% for ShadeGAN. Moreover, in Fig. 7 we visualize the depth maps predicted by our surface tracking network and those obtained via volume rendering. It is shown that under varying identities and camera poses, the surface tracking network could consistently predict depth values that are quite close to the real surface positions, so that we can sample points near the predicted surface for rendering without sacrificing image quality.
  Illumination-aware image synthesis. As ShadeGAN models the shading process, it by design allows explicit control over the lighting condition. We provide such illumination-aware image synthesis results in Fig.8, where ShadeGAN generates promising images under different lighting directions. We also show that in cases where the predicted a is conditioned on the lighting condition µ, a would slightly change w.r.t. the lighting condition, e.g., it would be brighter in areas having a overly dim shading in order to make the final image more natural. Besides, we could optionally add a specular term ksmax(0,h · n)p in Eq. 4 (i.e., Blinn-Phong shading [47], where h is the bisector of the angle between the viewpoint and the lighting direction) to create specular highlight effects, as shown in Fig.8 (c).
  GAN inversion. ShadeGAN could also be used to reconstruct a given target image by performing GAN inversion. As shown in Fig. 9 such inversion allows us to obtain several factors of the image, including the 3D shape, surface normal, approximated albedo, and shading. Besides, we can further perform view synthesis and relighting by changing the viewpoint and lighting condition. The implementation of GAN inversion is provided in the supplementary material.
  Discussions. As the Lambertian shading we used is an approximation to the real illumination, the albedo learned by ShadeGAN is not perfectly disentangled. Our approach does not consider the spatially-varying material properties of objects as well. In the future, we intend to incorporate more sophisticated shading models to learn better disentangled generative reflectance fields.
sections.heading: 5 Conclusion
sections.text: In this work, we present ShadeGAN, a new generative implicit model for shape-accurate 3D-aware image synthesis. We have shown that the multi-lighting constraint, achieved in ShadeGAN by explicit illumination modeling, significantly helps learning accurate 3D shapes from 2D images. ShadeGAN also allows us to control the lighting condition during image synthesis, achieving natural image relighting effects. To reduce the computational cost, we have further devised a light-weighted surface tracking network, which enables an efficient volume rendering technique for generative implicit models, achieving significant acceleration on both training and inference speed. A generative model with shape-accurate 3D representation could broaden its applications in vision and graphics, and our work has taken a solid step towards this goal.
  Acknowledgment. We would like to thank Eric R. Chan for sharing the codebase of pi-GAN. This study is supported under the ERC Consolidator Grant 4DRepLy (770784). This study is also supported under the RIE2020 Industry Alignment Fund – Industry Collaboration Projects (IAF-ICP) Funding Initiative, as well as cash and in-kind contribution from the industry partner(s).
title: A Shading-Guided Generative Implicit Model for Shape-Accurate 3D-Aware Image Synthesis