diff options
author | Clément Foucault <foucault.clem@gmail.com> | 2018-11-19 20:03:06 +0300 |
---|---|---|
committer | Clément Foucault <foucault.clem@gmail.com> | 2018-11-19 20:05:15 +0300 |
commit | 7bb512594cd9502fea290ac6124f2eb5fd3cfce8 (patch) | |
tree | 190b9e4184e6eabf3349e74bf6d58c6da9f29288 /source/blender/draw/engines/workbench/workbench_private.h | |
parent | 2b56d2183972a0cb3b1355652a6709599ae6af0d (diff) |
Workbench: Use non-negative lighting evaluation
This makes the lighting a bit more diffuse but don't produce negative
values.
Add a bias of 1.5f to make the lighting a bit more directionnal.
The implementation is based on:
https://github.com/kayru/Probulator/blob/master/Source/Probulator/SphericalHarmonics.h#L136
which is derived from:
http://www.geomerics.com/wp-content/uploads/2015/08/CEDEC_Geomerics_ReconstructingDiffuseLighting1.pdf
The shader implementation is optimized and has the same runtime cost
as previous method:
* no sh eval : 0.13ms
* prev sh eval : 0.14ms
* new sh eval : 0.22ms
* new sh eval opti : 0.14ms
Diffstat (limited to 'source/blender/draw/engines/workbench/workbench_private.h')
-rw-r--r-- | source/blender/draw/engines/workbench/workbench_private.h | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/source/blender/draw/engines/workbench/workbench_private.h b/source/blender/draw/engines/workbench/workbench_private.h index ef18c00cff3..93b3bddfb72 100644 --- a/source/blender/draw/engines/workbench/workbench_private.h +++ b/source/blender/draw/engines/workbench/workbench_private.h @@ -138,8 +138,10 @@ typedef struct WORKBENCH_UBO_Light { float energy; } WORKBENCH_UBO_Light; +#define WORKBENCH_SH_DATA_LEN ((STUDIOLIGHT_SH_BANDS == 2) ? 6 : STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN) + typedef struct WORKBENCH_UBO_World { - float spherical_harmonics_coefs[STUDIOLIGHT_SH_EFFECTIVE_COEFS_LEN][4]; + float spherical_harmonics_coefs[WORKBENCH_SH_DATA_LEN][4]; float background_color_low[4]; float background_color_high[4]; float object_outline_color[4]; |