diff options
Diffstat (limited to 'source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl')
-rw-r--r-- | source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl index 9b142fe56b5..8cbc8608f5b 100644 --- a/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl +++ b/source/blender/draw/engines/workbench/shaders/workbench_common_lib.glsl @@ -3,6 +3,10 @@ #define CAVITY_BUFFER_RANGE 4.0 +#ifdef WORKBENCH_ENCODE_NORMALS + +# define WB_Normal vec2 + /* From http://aras-p.info/texts/CompactNormalStorage.html * Using Method #4: Spheremap Transform */ vec3 workbench_normal_decode(vec4 enc) @@ -18,7 +22,7 @@ vec3 workbench_normal_decode(vec4 enc) /* From http://aras-p.info/texts/CompactNormalStorage.html * Using Method #4: Spheremap Transform */ -vec2 workbench_normal_encode(bool front_face, vec3 n) +WB_Normal workbench_normal_encode(bool front_face, vec3 n) { n = normalize(front_face ? n : -n); float p = sqrt(n.z * 8.0 + 8.0); @@ -26,6 +30,13 @@ vec2 workbench_normal_encode(bool front_face, vec3 n) return n.xy; } +#else +# define WB_Normal vec3 +/* Well just do nothing... */ +# define workbench_normal_encode(f, a) (a) +# define workbench_normal_decode(a) (a.xyz) +#endif /* WORKBENCH_ENCODE_NORMALS */ + /* Encoding into the alpha of a RGBA16F texture. (10bit mantissa) */ #define TARGET_BITCOUNT 8u #define METALLIC_BITS 3u /* Metallic channel is less important. */ |