Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClément Foucault <foucault.clem@gmail.com>2021-02-07 20:03:58 +0300
committerClément Foucault <foucault.clem@gmail.com>2021-02-07 20:03:58 +0300
commitfe008592024c3081c5b43b82482d46e41262fdb1 (patch)
tree0c42627c2b504dbb2151a1daea726255506fba14 /source/blender/draw/intern
parente49b702527440997ef32967ef368c1212a2311f9 (diff)
EEVEE: Rewrite closure_lit_lib to reduce complexity
This rewrite improves: - Code clarity: Less duplicated code and removes a few hacks. - Compile time performance: Shader code was divided by 3 in average. I did not profile the compilation time but it is faster. - Shading Perf: Noticed a 25% performance improvement on the shading pass with default dielectric principled bsdf. - Fix Principled Tint being white if color is black - It seems to have fixed issues on some drivers giving some incorect results. - Changes Principled BSDF support to be less hacky.
Diffstat (limited to 'source/blender/draw/intern')
-rw-r--r--source/blender/draw/intern/shaders/common_math_lib.glsl12
1 files changed, 12 insertions, 0 deletions
diff --git a/source/blender/draw/intern/shaders/common_math_lib.glsl b/source/blender/draw/intern/shaders/common_math_lib.glsl
index a82e0b5a5e9..84d93cc3965 100644
--- a/source/blender/draw/intern/shaders/common_math_lib.glsl
+++ b/source/blender/draw/intern/shaders/common_math_lib.glsl
@@ -72,6 +72,9 @@ float sum(vec4 v) { return dot(vec4(1.0), v); }
float avg(vec2 v) { return dot(vec2(1.0 / 2.0), v); }
float avg(vec3 v) { return dot(vec3(1.0 / 3.0), v); }
float avg(vec4 v) { return dot(vec4(1.0 / 4.0), v); }
+
+float sqr(float v) { return v * v; }
+
/* clang-format on */
#define saturate(a) clamp(a, 0.0, 1.0)
@@ -93,6 +96,15 @@ float len_squared(vec3 a)
return dot(a, a);
}
+vec3 safe_normalize(vec3 v)
+{
+ float len = length(v);
+ if (isnan(len) || len == 0.0) {
+ return vec3(1.0, 0.0, 0.0);
+ }
+ return v / len;
+}
+
/** \} */
/* ---------------------------------------------------------------------- */