better texture allocation (saves memory)

Issue #1433 resolved
Alessandro Padovani created an issue

daz studio 4.21.0.5, blender 3.4.1, diffeomorphic 1.7.0.1458

Sometime it happens that we need to use the same texture in different color spaces, for example srgb for diffuse and non-color for bump, so we split it as two textures. While this works as intended, it has the drawback that two images are allocated, thus doubling the memory usage for the texture.

One way to fix this is, instead of using two textures, we use one srgb texture and a gamma node for non-color. Test scene included star.duf, it’s a cube using the same texture for diffuse and bump.

# convert srgb to non-color
gamma = 1/2.2

note. Unless I miss something and the plugin does some trick with data pointers to reuse the same data with different images. But even if so, this would be confusing for the general user, so the trick above would do fine instead.

Let me know.

Comments (5)

  1. Thomas Larsson repo owner

    Implemented in last commit. The texture node is set to either srgb or linear, depending on which node needs the texture first, and thus gamma is set to either 2.2 or 1/2.2. If the gamma node is not used, which usually is the case, it will be removed when the node tree is pruned. This has the advantage that we don’t have to add a lot of gamma nodes if they aren’t needed.

  2. Alessandro Padovani reporter

    Commit 65ea233 works great.

    Very minor just to don’t open another issue for this. For some more cleanup, there’s the texture coordinates that can be closed when we use the uv output, not when we use other outputs that we need to see what it is. Also the modulo node could be closed.

    Let me know or I’ll close as resolved anyway.

    note. Not really sure it makes sense to use the modulo outside LIE, though it doesn’t harm. Will have to think better about this and eventually open another issue.

  3. Alessandro Padovani reporter

    note. important. solid view bug.

    Sorry didn’t think about this. But the solid view depends on the diffuse texture node to be srgb, so when there’s non-color we have to use the texture as srgb and the gamma as non-color. That is, always give priority to diffuse for the texture. If this is hard to implement then we may leave it as is but will ruin the solid view.

    Let me know.

  4. Thomas Larsson repo owner

    I think I have implemented all suggestions, except moving the modulo node away from its mapping node. The texture nodes are always created as srgb, but changed to non-color in the pruning step. You can see all the unused gamma nodes if you turn off prune node tree in the global settings.

  5. Log in to comment