Workbench: Cleanup: Remove Spherical harmonic evaluation

It is not used anymore
This commit is contained in:
2018-12-03 02:33:27 +01:00
parent 82f01c666f
commit d8d52e273e
4 changed files with 0 additions and 80 deletions

View File

@@ -5,7 +5,6 @@ struct LightData {
};
struct WorldData {
vec3 spherical_harmonics_coefs[STUDIOLIGHT_SH_MAX_COMPONENTS];
vec4 background_color_low;
vec4 background_color_high;
vec4 object_outline_color;

View File

@@ -1,76 +1,3 @@
#define BLINN
#if STUDIOLIGHT_SH_BANDS == 2
vec3 spherical_harmonics(vec3 N, vec3 sh_coefs[STUDIOLIGHT_SH_MAX_COMPONENTS])
{
/* http://www.geomerics.com/wp-content/uploads/2015/08/CEDEC_Geomerics_ReconstructingDiffuseLighting1.pdf */
/* Highly optimized form, precompute as much as we can. */
/**
* R1 = 0.5 * vec3(L3.r, L2.r, L1.r);
* sh_coefs[0..2] = R1 / length(R1);
**/
vec3 q;
q.x = dot(sh_coefs[1], N);
q.y = dot(sh_coefs[2], N);
q.z = dot(sh_coefs[3], N);
q = 0.5 * q + 0.5;
/**
* R0 = L0.r;
* lr1_r0 = lenR1 / R0;
* p = 1.0 + 2.0 * lr1_r0;
* a = (1.0 - lr1_r0) / (1.0 + lr1_r0);
* return R0 * (a + (1.0 - a) * (p + 1.0) * pow(q, p));
*
* sh_coefs[4] = p;
* sh_coefs[5] = R0 * a;
* sh_coefs[0] = R0 * (1.0 - a) * (p + 1.0);
**/
q = pow(q, sh_coefs[4]);
return sh_coefs[0] * q + sh_coefs[5];
}
#else
vec3 spherical_harmonics(vec3 N, vec3 sh_coefs[STUDIOLIGHT_SH_MAX_COMPONENTS])
{
vec3 sh = 0.282095 * sh_coefs[0];
# if STUDIOLIGHT_SH_BANDS > 1
float nx = N.x;
float ny = N.y;
float nz = N.z;
sh += -0.488603 * nz * sh_coefs[1];
sh += 0.488603 * ny * sh_coefs[2];
sh += -0.488603 * nx * sh_coefs[3];
# endif
# if STUDIOLIGHT_SH_BANDS > 2
float nx2 = nx * nx;
float ny2 = ny * ny;
float nz2 = nz * nz;
sh += 1.092548 * nx * nz * sh_coefs[4];
sh += -1.092548 * nz * ny * sh_coefs[5];
sh += 0.315392 * (3.0 * ny2 - 1.0) * sh_coefs[6];
sh += -1.092548 * nx * ny * sh_coefs[7];
sh += 0.546274 * (nx2 - nz2) * sh_coefs[8];
# endif
# if STUDIOLIGHT_SH_BANDS > 4
float nx4 = nx2 * nx2;
float ny4 = ny2 * ny2;
float nz4 = nz2 * nz2;
sh += (2.5033429417967046 * nx * nz * (nx2 - nz2)) * sh_coefs[9];
sh += (-1.7701307697799304 * nz * ny * (3.0 * nx2 - nz2)) * sh_coefs[10];
sh += (0.9461746957575601 * nz * nx * (-1.0 +7.0*ny2)) * sh_coefs[11];
sh += (-0.6690465435572892 * nz * ny * (-3.0 + 7.0 * ny2)) * sh_coefs[12];
sh += ((105.0*ny4-90.0*ny2+9.0)/28.359261614) * sh_coefs[13];
sh += (-0.6690465435572892 * nx * ny * (-3.0 + 7.0 * ny2)) * sh_coefs[14];
sh += (0.9461746957575601 * (nx2 - nz2) * (-1.0 + 7.0 * ny2)) * sh_coefs[15];
sh += (-1.7701307697799304 * nx * ny * (nx2 - 3.0 * nz2)) * sh_coefs[16];
sh += (0.6258357354491761 * (nx4 - 6.0 * nz2 * nx2 + nz4)) * sh_coefs[17];
# endif
return sh;
}
#endif
/* [Drobot2014a] Low Level Optimizations for GCN */
vec4 fast_rcp(vec4 v)

View File

@@ -94,9 +94,6 @@ char *workbench_material_build_defines(WORKBENCH_PrivateData *wpd, bool use_text
BLI_dynstr_appendf(ds, "#define HAIR_SHADER\n");
}
BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_SH_BANDS %d\n", STUDIOLIGHT_SH_BANDS);
BLI_dynstr_appendf(ds, "#define STUDIOLIGHT_SH_MAX_COMPONENTS %d\n", WORKBENCH_SH_DATA_LEN);
str = BLI_dynstr_get_cstring(ds);
BLI_dynstr_free(ds);
return str;

View File

@@ -143,10 +143,7 @@ typedef struct WORKBENCH_UBO_Light {
float diffuse_color[3], wrapped;
} 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[WORKBENCH_SH_DATA_LEN][4];
float background_color_low[4];
float background_color_high[4];
float object_outline_color[4];