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:
authorThomas Dinges <blender@dingto.org>2016-06-19 18:31:16 +0300
committerThomas Dinges <blender@dingto.org>2016-06-19 18:31:16 +0300
commit6311a9ff234aecb054121bf12ad03da6242fc092 (patch)
tree944abfd285251449ab9d3cccc54b37715ac4e0f6 /intern/cycles/util/util_half.h
parent7da189b4e8b1afed32716b6b2c127a93a35d498e (diff)
Cycles: Support half and half4 textures.
This is an initial commit for half texture support in Cycles. It adds the basic infrastructure inside of the ImageManager and support for these textures on CPU. Supported: * Half Float OpenEXR images (can be used for e.g HDRs or Normalmaps) now use 1/2 the memory, when loaded via disk (OIIO). ToDo: Various things like support for inbuilt half textures, GPU... will come later, step by step. Part of my GSoC 2016.
Diffstat (limited to 'intern/cycles/util/util_half.h')
-rw-r--r--intern/cycles/util/util_half.h21
1 files changed, 21 insertions, 0 deletions
diff --git a/intern/cycles/util/util_half.h b/intern/cycles/util/util_half.h
index f4bac9888a5..ae85ab3a915 100644
--- a/intern/cycles/util/util_half.h
+++ b/intern/cycles/util/util_half.h
@@ -85,6 +85,27 @@ ccl_device_inline void float4_store_half(half *h, float4 f, float scale)
#endif
}
+ccl_device_inline float half_to_float(half h)
+{
+ float f;
+
+ *((int*) &f) = ((h & 0x8000) << 16) | (((h & 0x7c00) + 0x1C000) << 13) | ((h & 0x03FF) << 13);
+
+ return f;
+}
+
+ccl_device_inline float4 half4_to_float4(half4 h)
+{
+ float4 f;
+
+ f.x = half_to_float(h.x);
+ f.y = half_to_float(h.y);
+ f.z = half_to_float(h.z);
+ f.w = half_to_float(h.w);
+
+ return f;
+}
+
#endif
#endif