Fix wrong conversion between power and radiance of emitters #108505

Closed
opened 2023-06-01 11:29:36 +02:00 by Weizhen Huang · 2 comments
Member

There are factors for converting power in watts to radiance in watts per steradian per square meter (eval_fac in Cycles). However, some scalings are incorrect. Adjusting the scaling preserves the energy of the light source and improves compatibility with other renderers.

Area Light

Assuming Lambertian emitter, the outgoing radiance integrated over the hemisphere and the projected area gives the total emitted power (radiant flux)

\Phi_e=\int_\mathcal{H^2}L_e\mathrm{d}\omega\mathrm{d}A^\bot=\int_\mathcal{H^2}L_e\cos\theta\mathrm{d}\omega\mathrm{d}A=\pi L_e\int\mathrm{d}A=\pi A L_e.

Therefore, eval_fac should be M_1_PI_F * invarea instead of 0.25f * invarea.
The factor normalize_spread in light.cpp ensures that the area light emits the same amount of power regardless of the spread angle.

Point Light

The physical meaning of a point light with radius is unclear. In Blender it appears to be something similar to sphere light although not exactly due to the visible solid angle. If treated as a sphere light, the total emitted power is given by

\Phi=\pi L_e\int\mathrm{d}A=4\pi^2 R^2L_e,

with R being the radius of the point light. In Cycles, spot.inv_area = 1.0f / (M_PI_F * radius * radius) (see light.cpp). Therefore, eval_fac = 0.25f * M_1_PI_F * invarea, as currently in the implementation.

HOWEVER, if we follow the current sampling procedure exactly, a point light with radius looks like a disk light from every direction. In this case, we can compute the radiant flux through a sphere of radius D around the point light center (Gauss's Law). The irradiance at arbitrary point on the sphere is

E=\int L_e(\omega_i\cdot n)\mathrm{d}\omega_i=\int_0^{2\pi}\int_0^{R}\frac{L_e\cos\theta_i\cos\theta_o}{d^2}r\mathrm{d}r\mathrm{d}\phi,

using the Jacobians \mathrm{d}\omega=\frac{\cos\theta_o}{d^2}\mathrm{d}A and \mathrm{d}A=r\mathrm{d}r\mathrm{d}\phi, and d=\sqrt{r^2+D^2} is the distance between a point on the light source and the point on the sphere. Substituting \cos\theta_i=\cos\theta_o=\frac{D}{d} in the above equation, we obtain

E=\pi L_e\frac{R^2}{D^2+R^2}.

Therefore, the total emitted radiant flux is

\Phi_e=\oiint_\mathcal{S^2} E\mathrm{d}S=4\pi D^2E =4\pi^2\frac{R^2D^2}{D^2+R^2}L_e.

The result depends on the receiver distance and is therefore not physically correct. The additional factor \frac{D^2}{D^2+R^2} plotted against \frac{D}{R} is

point_light_factor.png

Therefore, it approximates a sphere light when approaching infinity.
The plan is to change point light to (double-sided) sphere light (#108506). In EEVEE a sphere light can be treated as a disk light that spans the same solid angle from the shading point.

Spot Light

Spot lights use the same sampling procedure as point lights, but emit light only in a cone: the function spot_light_attenuation() in spot.h acts as masking function (if blend is ignored), so the power specified in the UI corresponds to TWICE the power emitted by a spot light with \mathrm{half\_spread} = \frac{\pi}{2}. This behaviour is different than with area lights, where a normalization factor is used so that the intensity changes when adjusting the spread angle. According to Frostbite:

Such a coupling makes spotlight manipulation harder for artists and causes trouble when optimizing: artists cannot reduce the cone attenuation to affect fewer pixels without changing its intensity.

We could follow their approach to multiply the current eval_fac by 4, so that the power corresponds to the amount emitted by a spot light with \mathrm{half\_spread} = \frac{\pi}{3}, or just keep it as is so it gives the same intensity as a point light, or add an option for normalization.

Sun Light

For sun light, user specify an "intensity", which is the irradiance received by a surface perpendicular to the sun direction, the unit being Watt per square meter. Using the irradiance formula derived for point lights and treating the sun light as a disk light 1 unit away, we have

E=\int_0^{2\pi}\int_0^{R}\frac{L_eD^2}{d^4}r\mathrm{d}r\mathrm{d}\phi=\int_0^{2\pi}\int_0^{\tan\alpha}\frac{L_er}{(r^2+1)^2}\mathrm{d}r\mathrm{d}\phi,

where \alpha is half the angular diameter. Currently \mathrm{eval\_fac} = \frac{1}{\pi\tan^2\alpha\cos^3\phi}; using \cos\phi = \frac{1}{\sqrt{r^2+1}}, the irradiance is computed as

E=\frac{1}{\pi\tan^2\alpha}\int_0^{2\pi}\int_0^{\tan\alpha}\frac{Ir}{\sqrt{r^2+1}}\mathrm{d}r\mathrm{d}\phi=\frac{2(\sec\alpha-1)}{\tan^2\alpha}I.

Plotting the additional factor against the angular diameter:
sun_light_plot.png
for small angular diameter the value is close to 1, so the scaling for sun light seems fine.

There are factors for converting power in watts to radiance in watts per steradian per square meter (`eval_fac` in Cycles). However, some scalings are incorrect. Adjusting the scaling preserves the energy of the light source and improves compatibility with other renderers. ## Area Light Assuming Lambertian emitter, the outgoing radiance integrated over the hemisphere and the projected area gives the total emitted power (radiant flux) \[\Phi_e=\int_\mathcal{H^2}L_e\mathrm{d}\omega\mathrm{d}A^\bot=\int_\mathcal{H^2}L_e\cos\theta\mathrm{d}\omega\mathrm{d}A=\pi L_e\int\mathrm{d}A=\pi A L_e.\] Therefore, `eval_fac` should be `M_1_PI_F * invarea` instead of `0.25f * invarea`. The factor `normalize_spread` in `light.cpp` ensures that the area light emits the same amount of power regardless of the spread angle. ## Point Light The physical meaning of a point light with radius is unclear. In Blender it appears to be something similar to sphere light although not exactly due to the visible solid angle. If treated as a sphere light, the total emitted power is given by \[\Phi=\pi L_e\int\mathrm{d}A=4\pi^2 R^2L_e,\] with \(R\) being the radius of the point light. In Cycles, `spot.inv_area = 1.0f / (M_PI_F * radius * radius)` (see `light.cpp`). Therefore, `eval_fac = 0.25f * M_1_PI_F * invarea`, as currently in the implementation. HOWEVER, if we follow the current sampling procedure exactly, a point light with radius looks like a disk light from every direction. In this case, we can compute the radiant flux through a sphere of radius \(D\) around the point light center (Gauss's Law). The irradiance at arbitrary point on the sphere is \[E=\int L_e(\omega_i\cdot n)\mathrm{d}\omega_i=\int_0^{2\pi}\int_0^{R}\frac{L_e\cos\theta_i\cos\theta_o}{d^2}r\mathrm{d}r\mathrm{d}\phi,\] using the Jacobians \(\mathrm{d}\omega=\frac{\cos\theta_o}{d^2}\mathrm{d}A\) and \(\mathrm{d}A=r\mathrm{d}r\mathrm{d}\phi\), and \(d=\sqrt{r^2+D^2}\) is the distance between a point on the light source and the point on the sphere. Substituting \(\cos\theta_i=\cos\theta_o=\frac{D}{d}\) in the above equation, we obtain \[E=\pi L_e\frac{R^2}{D^2+R^2}.\] Therefore, the total emitted radiant flux is \[\Phi_e=\oiint_\mathcal{S^2} E\mathrm{d}S=4\pi D^2E =4\pi^2\frac{R^2D^2}{D^2+R^2}L_e.\] The result depends on the receiver distance and is therefore not physically correct. The additional factor \(\frac{D^2}{D^2+R^2}\) plotted against \(\frac{D}{R}\) is ![point_light_factor.png](/attachments/831cbf01-d3d8-491b-830c-0f861a33e803) Therefore, it approximates a sphere light when approaching infinity. The plan is to change point light to (double-sided) sphere light (#108506). In EEVEE a sphere light can be treated as a disk light that spans the same solid angle from the shading point. ## Spot Light Spot lights use the same sampling procedure as point lights, but emit light only in a cone: the function `spot_light_attenuation()` in `spot.h` acts as masking function (if `blend` is ignored), so the power specified in the UI corresponds to TWICE the power emitted by a spot light with \(\mathrm{half\_spread} = \frac{\pi}{2}\). This behaviour is different than with area lights, where a normalization factor is used so that the intensity changes when adjusting the spread angle. According to [Frostbite](https://seblagarde.files.wordpress.com/2015/07/course_notes_moving_frostbite_to_pbr_v32.pdf): > Such a coupling makes spotlight manipulation harder for artists and causes trouble when optimizing: artists cannot reduce the cone attenuation to affect fewer pixels without changing its intensity. We could follow their approach to multiply the current `eval_fac` by 4, so that the power corresponds to the amount emitted by a spot light with \(\mathrm{half\_spread} = \frac{\pi}{3}\), or just keep it as is so it gives the same intensity as a point light, or add an option for normalization. ## Sun Light For sun light, user specify an "intensity", which is the irradiance received by a surface perpendicular to the sun direction, the unit being Watt per square meter. Using the irradiance formula derived for point lights and treating the sun light as a disk light 1 unit away, we have \[E=\int_0^{2\pi}\int_0^{R}\frac{L_eD^2}{d^4}r\mathrm{d}r\mathrm{d}\phi=\int_0^{2\pi}\int_0^{\tan\alpha}\frac{L_er}{(r^2+1)^2}\mathrm{d}r\mathrm{d}\phi,\] where \(\alpha\) is half the angular diameter. Currently \(\mathrm{eval\_fac} = \frac{1}{\pi\tan^2\alpha\cos^3\phi}\); using \(\cos\phi = \frac{1}{\sqrt{r^2+1}}\), the irradiance is computed as \[E=\frac{1}{\pi\tan^2\alpha}\int_0^{2\pi}\int_0^{\tan\alpha}\frac{Ir}{\sqrt{r^2+1}}\mathrm{d}r\mathrm{d}\phi=\frac{2(\sec\alpha-1)}{\tan^2\alpha}I.\] Plotting the additional factor against the angular diameter: ![sun_light_plot.png](/attachments/263f3efb-b082-446c-83b5-418e44ec0ad3) for small angular diameter the value is close to 1, so the scaling for sun light seems fine.
Weizhen Huang added this to the 4.0 milestone 2023-06-01 11:29:36 +02:00
Weizhen Huang added this to the Render & Cycles project 2023-06-01 11:29:39 +02:00

I think this can be closed now.

I think this can be closed now.
Blender Bot added
Status
Archived
and removed
Status
Confirmed
labels 2023-07-07 18:32:22 +02:00
Author
Member

The factors are corrected in various commits listed above. To summarize:

Area Light

Using a factor of 1/(\pi A), as computed above.

Sphere Light

Using a factor of 1/(4\pi^2r^2), as computed above.

Point Light

Sphere light with r=0, using a factor of 1/(4\pi), corresponds to the solid angle of a sphere.

Spot Light

Using the same factor as sphere light.

Sun Light

Disk sampling has been changed to solid angle sampling. Denoting the half angular diameter as \alpha, the irradiance received by a differential surface penpendicular to the sun direction is

E=\int_{\Omega(\alpha)}L_e\cos\theta_i\mathrm{d}\omega_i=L_e\int_{0}^{2\pi}\int_{0}^{\alpha}\cos\theta_i\sin\theta_i\mathrm{d}\theta\mathrm{d}\phi=L_e\pi\sin^2\alpha.

Therefore, the factor to convert from irradiance to radiance is 1/(\pi\sin^2\alpha).

The factors are corrected in various commits listed above. To summarize: ### Area Light Using a factor of \(1/(\pi A)\), as computed above. ### Sphere Light Using a factor of \(1/(4\pi^2r^2)\), as computed above. ### Point Light Sphere light with \(r=0\), using a factor of \(1/(4\pi)\), corresponds to the solid angle of a sphere. ### Spot Light Using the same factor as sphere light. ### Sun Light Disk sampling has been changed to solid angle sampling. Denoting the half angular diameter as \(\alpha\), the irradiance received by a differential surface penpendicular to the sun direction is \[E=\int_{\Omega(\alpha)}L_e\cos\theta_i\mathrm{d}\omega_i=L_e\int_{0}^{2\pi}\int_{0}^{\alpha}\cos\theta_i\sin\theta_i\mathrm{d}\theta\mathrm{d}\phi=L_e\pi\sin^2\alpha.\] Therefore, the factor to convert from irradiance to radiance is \(1/(\pi\sin^2\alpha)\).
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No Assignees
2 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#108505
No description provided.