Bases: object
Encapsulates Spherical Gaussians lighting parameters.
Instantiate parameters. Will expand amplitude and sharpness if simple numbers are provided.
amplitude (float or Iterable or torch.Tensor) – The amplitudes of the spherical Gaussians representing the incoming radiance, combining the strength and color of the light sources, of range \([0, inf]\), of shape \((\text{num_sg}, 3)\).
direction (Iterable or torch.Tensor) – The directions of the spherical Gaussians representing the incoming radiance, as a unit vector, of shape \((\text{num_sg}, 3)\).
sharpness (float or Iterable or torch.Tensor) – The sharpness of the spherical Gaussians representing the incoming radiance, of range \([0, inf]\), of shape \((\text{num_sg},)\).
Returns a SgLightingParameters corresponding to suns.
direction – The directions of the suns, of shape \((\text{num_suns}, 3)\).
Return: (SgLightingParameters): the spherical Gaussians matching the suns.
Computes an approximate integral of a spherical gaussian over the entire sphere.
The error vs the non-approximate version decreases as sharpness increases.
amplitude (torch.Tensor) – The amplitude of the spherical gaussian.
sharpness (torch.Tensor) – The sharpness of the spherical gaussian.
The integral of same shape than amplitude.
(torch.tensor)
Returns an approximation of the clamped cosine lobe represented as a spherical gaussian.
This is to be used with normal of surfaces to apply Lambert’s cosine law.
direction (torch.tensor) – The direction of the desired lobe, of last dimension 3
The amplitude of the spherical gaussian, of same shape as direction
The input direction
The sharpness of the spherical gaussian, of shape direction.shape[:-1]
(torch.tensor, torch.Tensor, torch.Tensor)
Project directions, represented as cartesian coordinates, onto the spherical harmonic coefficients of degree 3.
directions (torch.Tensor or list of int) – The directions as cartesian coordinates, of any shape but of last dimension 3.
of shape direction.shape[:-1] and last dimension 9.
Computes the outgoing radiance from multiple spherical gaussians representing incoming radiance, using a Lambertian diffuse BRDF.
Note
The irradiance is computed using a fitted approximation polynomial,
this approximation were provided by Stephen Hill. See sg_irradiance_fitted().
amplitude (torch.Tensor) – The amplitudes of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg}, 3)\).
direction (torch.Tensor) – The directions of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg}, 3)\).
sharpness (torch.Tensor) – The sharpness of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg},)\).
normal (torch.Tensor) – The normal of the surface points where the radiance is to be estimated, of shape \((\text{num_points}, 3)\).
albedo (torch.Tensor) – The albedo (RGB color) of the surface points where the radiance is to be estimated, of shape \((\text{num_points}, 3)\).
The diffuse radiance, of shape \((\text{num_points}, 3)\).
Computes the outgoing radiance from multiple spherical gaussians representing incoming radiance, using a Lambertian diffuse BRDF.
This is the diffuse reflectance used in DIB-R++: Learning to Predict Lighting and Material with a Hybrid Differentiable Renderer NeurIPS 2021.
amplitude (torch.Tensor) – The amplitudes of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg}, 3)\).
direction (torch.Tensor) – The directions of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg}, 3)\).
sharpness (torch.Tensor) – The sharpness of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg},)\).
normal (torch.Tensor) – The normal of the surface points where the radiance is to be estimated, of shape \((\text{num_points}, 3)\).
albedo (torch.Tensor) – The albedo of the surface points where the radiance is to be estimated, of shape \((\text{num_points}, 3)\).
The diffuse radiance, of shape \((\text{num_points}, 3)\).
Converts azimuth and elevation angles to a direction vector, assuming y-up orientation.
azimuth (float or torch.Tensor) – angle in radians
elevation (float or torch.Tensor) – angle in radians
(torch.Tensor)
Returns spherical gaussians approximation of the Trowbridge-Reitz (GGX) distribution used in the Cook-Torrance specular BRDF.
Use a single lobe to approximate the distribution.
direction (torch.Tensor) – The normal directions, of shape \((\text{num_points}, 3)\)
roughness (torch.Tensor) – The roughness of the surface, of shape \((\text{num_points})\)
The amplitude of the spherical gaussians, of shape \((\text{num_points}, 3)\).
The input direction.
The sharpness of the spherical gaussians, of shape \((\text{num_points})\).
Returns Spherical Gaussian parameters corresponding to suns.
strength (torch.Tensor) – The strength of the suns, of shape \((\text{num_suns},)\), [1..inf] expected, usually in low integer range.
color (torch.Tensor) – The color of the suns, of shape \((\text{num_suns}, 3)\), float [0..1] expected.
direction (torch.Tensor) – The directions of the suns, of shape \((\text{num_suns}, 3)\).
angle (torch.Tensor) – The suns angular diameter, in radians, of shape \((\text{num_suns},)\).
The amplitude of the spherical gaussians, of shape \((\text{num_suns}, 3)\).
The direction of the spherical gaussians, of shape \((\text{num_suns}, 3)\).
The sharpness of the spherical gaussians, of shape \((\text{num_suns},)\).
Computes an approximate incident irradiance from multiple spherical gaussians representing the incoming radiance.
The result is broadcasted per point per spherical gaussian.
Note
The irradiance is computed using a fitted approximation polynomial, this approximation were provided by Stephen Hill.
amplitude (torch.Tensor) – The amplitudes of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg}, 3)\).
direction (torch.Tensor) – The directions of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg}, 3)\).
sharpness (torch.Tensor) – The sharpness of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg},)\).
normal (torch.Tensor) – The normal of the surface points where the irradiance is to be estimated, of shape \((\text{num_points}, 3)\).
The irradiance for each spherical gaussian for each surface point, of shape \((\text{num_points}, \text{num_sg}, 3)\).
Computes the approximate incident irradiance from multiple spherical gaussians representing incoming radiance.
The clamped cosine lobe is approximated as a spherical gaussian, and convolved with the incoming radiance lobe using a spherical gaussian inner product.
amplitude (torch.Tensor) – The amplitudes of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg}, 3)\).
direction (torch.Tensor) – The directions of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg}, 3)\).
sharpness (torch.Tensor) – The sharpness of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg},)\).
normal (torch.Tensor) – The normal of the surface points where the radiance is to be estimated, of shape \((\text{num_points}, 3)\).
The irradiance, of shape \((\text{num_points}, 3)\).
Generate spherical gaussians that best represent the normal distribution function but with its axis oriented in the direction of the current BRDF slice.
Uses the warping operator from Wang et al.
amplitude (torch.Tensor) – The amplitudes of the spherical gaussians to be warped, of shape \((\text{num_sg}, 3)\).
direction (torch.Tensor) – The directions of the spherical gaussians to be warped, of shape \((\text{num_sg}, 3)\).
sharpness (torch.Tensor) – The sharpness of the spherical gaussians to be warped, of shape \((\text{num_sg},)\).
view (torch.Tensor) – The view direction, of shape \((\text{num_sg}, 3)\).
The input amplitude
The warped direction, of shape \((\text{num_sg}, 3)\)
The warped sharpness, of shape \((\text{num_sg})\)
Computes the specular reflectance from a spherical gaussians lobes representing incoming radiance, using the Cook-Torrance microfacet specular shading model.
amplitude (torch.Tensor) – The amplitudes of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg}, 3)\).
direction (torch.Tensor) – The directions of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg}, 3)\).
sharpness (torch.Tensor) – The sharpness of the spherical gaussians representing the incoming radiance, of shape \((\text{num_sg},)\).
normal (torch.Tensor) – The normal of the surface points where the specular reflectance is to be estimated, of shape \((\text{num_points}, 3)\).
roughness (torch.Tensor) – The roughness of the surface points where the specular reflectance is to be estimated, of shape \((\text{num_points})\).
view (torch.Tensor) – The direction toward the camera from the surface points where the specular reflectance is to be estimated, of shape \((\text{num_points}, 3)\).
spec_albedo (torch.Tensor) – The specular albedo (RGB color) of the surface points where the specular reflectance is to be estimated, of shape \((\text{num_points}, 3)\).
The specular reflectance, of shape \((\text{num_points}, 3)\).
Compute the outgoing radiance from a single spherical harmonic lobe of degree 3 representing incoming radiance, using a Lambertian diffuse BRDF.
directions (torch.Tensor) – Light directions, of 1D size \((3,)\).
normals (torch.Tensor) – Normal of the points where the radiance is to be estimated, of shape \((\text{num_points}, 3)\).
albedo (torch.Tensor) – albedo (RGB color) of the points where the radiance is to be estimated, of shape \((\text{num_points}, 3)\).
The diffuse radiance, of same shape than albedo.
Compute approximate incident irradiance from a single spherical harmonic lobe of degree 3 representing incoming radiance.
The clamped cosine lobe is approximated as spherical harmonics.
lights (torch.Tensor) – Light parameters of each spherical harmonic
(see: project_onto_sh9()),
of 1D size \((9,)\).
normals (torch.Tensor) – Normal of the points where the irradiance is to be estimated, of shape \((\text{num_points}, 3)\).
The irradiance values, of 1D shape \((\text{num_points},)\).