Single channel byte image takes same amount of memory in Cycles as multi channel image (GPU and CPU)
Closed, ResolvedPublic

Description

System Information
Windows 10 64bit, Geforce GTX970 (driver 373.06)

Blender Version
Broken: 2.78

Short description of error
As the title says. 2k image textures (rgb and single channel version) are provided and packed in the blend file.
Cycles should display less memory usage according to rB3c85e1ca1a91 when using the grayscale version

Exact steps for others to reproduce the error
Rendering scene with rgb texture:

Taking same amount of memory when rendering with grayscale texture:

Note: Maybe packing the texture files into the blend changed its' internal format to RGB, however the problem still is there with the original external files:

Thanks in advance!

Details

Type
Bug

I'm seeing similar behaviour on 2.78 (linux), but only for packed images. Files referenced from disk use less memory as long as they're true single channel. I'm not seeing any memory savings on GPU though - packed or unpacked.

-RAM usage with 3840x2160 PNG-

(for unpacked image)

single channel PNG:
CPU 9MB
GPU 32MB

RGB PNG:
CPU 32MB
GPU 32MB

(for packed image)

single channel PNG:
CPU 32MB
GPU 32MB

RGB PNG:
CPU 32MB
GPU 32MB

Sergey Sharybin (sergey) triaged this task as Incomplete priority.Oct 11 2016, 12:45 PM

Packed images are always RGBA. This is a known limitation.

If i unpack the images from provided .blend and convert them to grayscale in Gimp i've got noticeable memory save in render.

So make sure your image is set to grayscale (as in, only stores single channel) and if there's still no memory saving with such file please provide original image file.

this is the original image file.

Makes no defference in memory usage here, regardless of rendering with cpu od gpu.
Tried exporting as grayscale from Blender and again checked in Gimp that it is single channel (which it is definetly).

With the .blend attached here you need to disable autopack (File -> External Data -> Automatically Pack into .blend). After doing that and opening the new image in shader brings memory usage form 20M to 8M here, Both on Linux and Win7.

Can you confirm that with un-packed image you still have an error?

Yes, still no change in memory usage here, tested with autopack off.

Can you upload the unpacked png that's causing the problem?

@Paul R (intracube) see above for the original file :)

Ah, sorry. Didn't realise the inline image was it.

Still can't reprooduce on linux. GRAYSCALE.png peaks at just over 5MB, converting to RGB 24bit increases it to 17MB.

@David Ullmann (robocyte), can you upload exact .blend you use to test memory usage? (make sure you don't hit pack images before uploading :)

here it is, also the original rgb image
.

Thanks for looking into it :)

Also, should the file info in the properties region of the node editor change to something like 'BW' or 'Grayscale' when selecting an image texture node?

@David Ullmann (robocyte), ideally yes but let's keep it outside of this bug report. Will check the file later.

Just to add, I tried the supplied .blend and have got inconsistent results after removing the embedded images. On one attempt, RAM usage didn't decrease for the single channel image. Another attempt seemed to work.

I was also going to mention the incorrect labelling in the image preview...

We need to know exact steps reproducing the issue. Just mentioning that issue happens spontaneously doesn't give any clues about where the issue might be.. it might be in a particular .blend setup..

prepared another blend:

create a plane
subdivide in edit mode and unwrap
apply new material
create 4k color grid texture in uv/image editor
export texture as RGB png -> RGB.png
export another version as BW.png (gimp and irfan view correctly recognize image as grayscale)
load textures in node editor (set 'non color data' in image node) and render...

result: expected memory savings in viewport render and with F12, cpu and gpu.. ~65Mb vs. 16Mb

this is weird... @Sergey Sharybin (sergey) any hints why this is not working with the original blend?

Thanks for looking into this btw :)

I think I found the problem: Although I was editing the original file in Photoshop CS5 in grayscale mode, when saving it as PNG, Photoshop creates an RGB image nevertheless... No problem from Blender side here!

Sergey Sharybin (sergey) closed this task as Resolved.Nov 1 2016, 11:49 AM
Sergey Sharybin (sergey) claimed this task.

Considering resolved then :)

Let us know if there's real bug tho.

I would rather close it as todo. There is absolutely no warning in the UI that packed texture will explode the memory usage, even if unpacked afterwards and that an external tool is then needed. Is it really hard to implement single channel packed images that it has to wait for 2.8?