Cycles: Add support for single channel byte textures.

This way, we also save 3/4th of memory for single channel byte textures (e.g. Bump Maps).

Note: In order for this to work, the texture *must* have 1 channel only.
In Gimp you can e.g. do that via the menu: Image -> Mode -> Grayscale
This commit is contained in:
Thomas Dinges
2016-05-12 14:51:42 +02:00
parent cde10e774c
commit 3c85e1ca1a
7 changed files with 155 additions and 21 deletions

View File

@@ -138,6 +138,22 @@ void kernel_tex_copy(KernelGlobals *kg,
tex->extension = extension;
}
}
else if(strstr(name, "__tex_image_byte")) {
texture_image_uchar *tex = NULL;
int id = atoi(name + strlen("__tex_image_byte_"));
int array_index = id - TEX_IMAGE_BYTE_START_CPU;
if(array_index >= 0 && array_index < TEX_NUM_BYTE_IMAGES_CPU) {
tex = &kg->texture_byte_images[array_index];
}
if(tex) {
tex->data = (uchar*)mem;
tex->dimensions_set(width, height, depth);
tex->interpolation = interpolation;
tex->extension = extension;
}
}
else
assert(0);
}