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
This commit is contained in:
Stefan Werner
2018-07-05 12:37:52 +02:00
parent cd17b32583
commit 4d00e95ee3
13 changed files with 198 additions and 18 deletions

View File

@@ -127,11 +127,12 @@ ccl_device float4 kernel_tex_image_interp(KernelGlobals *kg, int id, float x, fl
const TextureInfo& info = kernel_tex_fetch(__texture_info, id);
CUtexObject tex = (CUtexObject)info.data;
/* float4, byte4 and half4 */
/* float4, byte4, ushort4 and half4 */
const int texture_type = kernel_tex_type(id);
if(texture_type == IMAGE_DATA_TYPE_FLOAT4 ||
texture_type == IMAGE_DATA_TYPE_BYTE4 ||
texture_type == IMAGE_DATA_TYPE_HALF4)
texture_type == IMAGE_DATA_TYPE_HALF4 ||
texture_type == IMAGE_DATA_TYPE_USHORT4)
{
if(info.interpolation == INTERPOLATION_CUBIC) {
return kernel_tex_image_interp_bicubic<float4>(info, tex, x, y);
@@ -164,7 +165,8 @@ ccl_device float4 kernel_tex_image_interp_3d(KernelGlobals *kg, int id, float x,
const int texture_type = kernel_tex_type(id);
if(texture_type == IMAGE_DATA_TYPE_FLOAT4 ||
texture_type == IMAGE_DATA_TYPE_BYTE4 ||
texture_type == IMAGE_DATA_TYPE_HALF4)
texture_type == IMAGE_DATA_TYPE_HALF4 ||
texture_type == IMAGE_DATA_TYPE_USHORT4)
{
if(interpolation == INTERPOLATION_CUBIC) {
return kernel_tex_image_interp_bicubic_3d<float4>(info, tex, x, y, z);