texture resizing improvement

Issue #123 resolved
Alessandro Padovani created an issue

I don’t know if this is possible. But a difference between iray and cycles is that iray converts textures depending on their usage, while cycles doesn’t.

For example, a bump map will always be loaded as greyscale in iray, even if it is truecolor in the image file. This also has the benefit to save memory in vram.

On the other side cycles loads a truecolor bump map as truecolor in vram, even if only the gray information is then used by the bump map. This is a major waste of vram in cycles since most iray textures come in truecolor format even if they only get non-color data. See for example the G8F textures.

Would it be possible to have a “texture optimizer” that converts to greyscale all the non-color textures in a scene ? I mean for the resized textures, so the original daz textures would not be changed.

Comments (6)

  1. Alessandro Padovani reporter

    edit. Please note that the conversion is done by iray, not by daz studio. So for example a truecolor texture in the bump channel will be shown as truecolor by daz studio, but it will be converted to grayscale for rendering by iray.

    The texture bitdepth in vram for cycles can be verified with the outliner in data mode, where grayscale has 8 while truecolor has 24 bits.

  2. Thomas Larsson repo owner

    This seems straightforward, since Open CV has a function that converts colors from BGR to grey. The tricky part is figuring out which textures that should be grey. Currently I traverse the node tree and say that textures that only link to bump nodes are probably grey. But there could be others, e.g. displacement maps.

    I think it is difficult to only look at the texture itself and deduce if it is grey, unless one loops over all pixels. Which probably is doable.

  3. Thomas Larsson repo owner

    Found a better solution: convert the texture to greyscale if the red, green and blue channels are identical. It turned out to be quite easy to do, and it converts grey textures even if they are used in a place where color textures would be possible. For G8F, the bump and specularity textures (B and S) are grey, and the diffuse and translucency textures (D and SSS) are color.

  4. Alessandro Padovani reporter

    In my opinion the proper way would be to convert to greyscale the textures that are non-color data in the blender scene. The plugin seems to already know what are non-color for bumps, displacement, specularity etc.

    For any doubt non-color data is easy to spot because it gets a grey socket in the nodes.

    There are also some textures that are duplicated in color and non-color if needed. The plugin already does this. In this case it’s probably safe to keep the truecolor image in vram and use two separate color non-color texture nodes referencing to it.

    Also checking for non-color may be faster than checking the rgb pixel values in hires textures.

    Any improvement will be fine though. If checking the rgb channels is easier I guess it will be a nice improvement anyway.

    Optimizing greyscale textures is especially important for eevee that doesn’t get the max texture size option in the simplify panel.

    Going to test the new commit as I get home. Thank you Thomas for the fast fix.

  5. Log in to comment