diff options
author | Stefan Werner <stefan.werner@tangent-animation.com> | 2018-07-05 13:37:52 +0300 |
---|---|---|
committer | Stefan Werner <stefan.werner@tangent-animation.com> | 2018-07-05 14:53:34 +0300 |
commit | 4d00e95ee3ed91f86262bb218f1c5df901da724c (patch) | |
tree | 5d9af704609b38cca76a5786189c126ac7072332 /intern/cycles/util/util_half.h | |
parent | cd17b3258327522b8c6f56a3ee7239a91f2be149 (diff) |
Cycles: Adding native support for UINT16 textures.
Textures in 16 bit integer format are sometimes used for displacement, bump and normal maps and can be exported by tools like Substance Painter. Without this patch, Cycles would promote those textures to single precision floating point, causing them to take up twice as much memory as needed.
Reviewers: #cycles, brecht, sergey
Reviewed By: #cycles, brecht, sergey
Subscribers: sergey, dingto, #cycles
Tags: #cycles
Differential Revision: https://developer.blender.org/D3523
Diffstat (limited to 'intern/cycles/util/util_half.h')
-rw-r--r-- | intern/cycles/util/util_half.h | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h index 612228dd1c1..f6c507906f3 100644 --- a/intern/cycles/util/util_half.h +++ b/intern/cycles/util/util_half.h @@ -36,7 +36,16 @@ CCL_NAMESPACE_BEGIN /* CUDA has its own half data type, no need to define then */ #ifndef __KERNEL_CUDA__ -typedef unsigned short half; +/* Implementing this as a class rather than a typedef so that the compiler can tell it apart from unsigned shorts. */ +class half { +public: + half() : v(0) {} + half(const unsigned short& i) : v(i) {} + operator unsigned short() { return v; } + half & operator =(const unsigned short& i) { v = i; return *this; } +private: + unsigned short v; +}; #endif struct half4 { half x, y, z, w; }; |