diff options
author | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-29 15:54:38 +0300 |
---|---|---|
committer | Jeroen Bakker <j.bakker@atmind.nl> | 2018-06-29 15:59:30 +0300 |
commit | ccca2c01649106ee24ad7407f182919eceda5bd9 (patch) | |
tree | 468dae28c0c2d886c737fae3f7af8b1b77bb66af /source/blender/draw/engines/workbench/shaders | |
parent | 5ba87cf22ebdfa660ec2044a8e97c3501c573176 (diff) |
Workbench: Spherical Harmonics tests
Added a compile directive in order to test SH4 in stead of SH2Win.
For now I disabled SH4, it is a bit more clear, but has a small
performance impact. Will check later for a better approach
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders')
-rw-r--r-- | source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl | 39 |
1 files changed, 31 insertions, 8 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl index b13c4f1b43b..3eda4455487 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_world_light_lib.glsl @@ -7,17 +7,40 @@ vec3 spherical_harmonics(vec3 N, vec3 spherical_harmonics_coefs[STUDIOLIGHT_SPHE sh += 0.282095 * spherical_harmonics_coefs[0]; #if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL > 0 - sh += -0.488603 * N.z * spherical_harmonics_coefs[1]; - sh += 0.488603 * N.y * spherical_harmonics_coefs[2]; - sh += -0.488603 * N.x * spherical_harmonics_coefs[3]; + float nx = N.x; + float ny = N.y; + float nz = N.z; + sh += -0.488603 * nz * spherical_harmonics_coefs[1]; + sh += 0.488603 * ny * spherical_harmonics_coefs[2]; + sh += -0.488603 * nx * spherical_harmonics_coefs[3]; #endif #if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL > 1 - sh += 1.092548 * N.x * N.z * spherical_harmonics_coefs[4]; - sh += -1.092548 * N.z * N.y * spherical_harmonics_coefs[5]; - sh += 0.315392 * (3.0 * N.y * N.y - 1.0) * spherical_harmonics_coefs[6]; - sh += -1.092548 * N.x * N.y * spherical_harmonics_coefs[7]; - sh += 0.546274 * (N.x * N.x - N.z * N.z) * spherical_harmonics_coefs[8]; + float nx2 = nx * nx; + float ny2 = ny * ny; + float nz2 = nz * nz; + + sh += 1.092548 * nx * nz * spherical_harmonics_coefs[4]; + sh += -1.092548 * nz * ny * spherical_harmonics_coefs[5]; + sh += 0.315392 * (3.0 * ny2 - 1.0) * spherical_harmonics_coefs[6]; + sh += -1.092548 * nx * ny * spherical_harmonics_coefs[7]; + sh += 0.546274 * (nx2 - nz2) * spherical_harmonics_coefs[8]; +#endif + +#if STUDIOLIGHT_SPHERICAL_HARMONICS_LEVEL > 3 + float nx4 = nx2 * nx2; + float ny4 = ny2 * ny2; + float nz4 = nz2 * nz2; + + sh += (2.5033429417967046 * nx * nz * (nx2 - nz2)) * spherical_harmonics_coefs[9]; + sh += (-1.7701307697799304 * nz * ny * (3.0 * nx2 - nz2)) * spherical_harmonics_coefs[10]; + sh += (0.9461746957575601 * nz * nx * (-1.0 +7.0*ny2)) * spherical_harmonics_coefs[11]; + sh += (-0.6690465435572892 * nz * ny * (-3.0 + 7.0 * ny2)) * spherical_harmonics_coefs[12]; + sh += ((105.0*ny4-90.0*ny2+9.0)/28.359261614) * spherical_harmonics_coefs[13]; + sh += (-0.6690465435572892 * nx * ny * (-3.0 + 7.0 * ny2)) * spherical_harmonics_coefs[14]; + sh += (0.9461746957575601 * (nx2 - nz2) * (-1.0 + 7.0 * ny2)) * spherical_harmonics_coefs[15]; + sh += (-1.7701307697799304 * nx * ny * (nx2 - 3.0 * nz2)) * spherical_harmonics_coefs[16]; + sh += (0.6258357354491761 * (nx4 - 6.0 * nz2 * nx2 + nz4)) * spherical_harmonics_coefs[17]; #endif return sh; |