From 5505ba8d4753ee6b3c0101ba3e4abf337546a1b0 Mon Sep 17 00:00:00 2001 From: Lukas Stockner Date: Thu, 24 May 2018 03:50:16 +0200 Subject: Cycles/Eevee: Implement disk and ellipse shapes for area lamps The implementation is pretty straightforward. In Cycles, sampling the shapes is currently done w.r.t. area instead of solid angle. There is a paper on solid angle sampling for disks [1], but the described algorithm is based on simply sampling the enclosing square and rejecting samples outside of the disk, which is not exactly great for Cycles' RNG (we'd need to setup a LCG for the repeated sampling) and for GPU divergence. Even worse, the algorithm is only defined for disks. For ellipses, the basic idea still works, but a way to analytically calculate the solid angle is required. This is technically possible [2], but the calculation is extremely complex and still requires a lookup table for the Heuman Lambda function. Therefore, I've decided to not implement that for now, we could still look into it later on. In Eevee, the code uses the existing ltc_evaluate_disk to implement the lighting calculations. [1]: "Solid Angle Sampling of Disk and Cylinder Lights" [2]: "Analytical solution for the solid angle subtended at any point by an ellipse via a point source radiation vector potential" Reviewers: sergey, brecht, fclem Differential Revision: https://developer.blender.org/D3171 --- source/blender/draw/intern/draw_cache.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'source/blender/draw/intern/draw_cache.h') diff --git a/source/blender/draw/intern/draw_cache.h b/source/blender/draw/intern/draw_cache.h index 8bc609ffe1f..8cf38cdd123 100644 --- a/source/blender/draw/intern/draw_cache.h +++ b/source/blender/draw/intern/draw_cache.h @@ -78,7 +78,8 @@ struct Gwn_Batch *DRW_cache_field_cone_limit_get(void); struct Gwn_Batch *DRW_cache_lamp_get(void); struct Gwn_Batch *DRW_cache_lamp_shadows_get(void); struct Gwn_Batch *DRW_cache_lamp_sunrays_get(void); -struct Gwn_Batch *DRW_cache_lamp_area_get(void); +struct Gwn_Batch *DRW_cache_lamp_area_square_get(void); +struct Gwn_Batch *DRW_cache_lamp_area_disk_get(void); struct Gwn_Batch *DRW_cache_lamp_hemi_get(void); struct Gwn_Batch *DRW_cache_lamp_spot_get(void); struct Gwn_Batch *DRW_cache_lamp_spot_square_get(void); -- cgit v1.2.3