This is mostly meant as a possible suggestion for the actual developers because for users to implement this method would involve manually editing the .rmtl file whereas the devs can affect how the rmtl files are saved to begin with. And to be clear, I’m not assuming the suggestion is valid, only that it is possibly worthy of consideration.
Some Context
I was fooling around with a double-sided material with embedded images. The front material and the back material both use the exact same HDR image. I looked at the RMTL file and noticed the <embedded-files>
section had two <file>
elements (one for the front material, and one for the back material). However, since they were exactly the same in every way, I manually deleted the second <file>
element and the material still worked fine when reloaded, but now the RMTL file was half its original size (it went from 4mb to 2mb). Even though in my case it was a double-sided material, I highly suspect that this would apply to any material capable of having more than one image and two or more of those images are actually the same image.
The Suggestion
So, my suggestion is that in any material where the user chooses to embed the images, if two or more images have the same path (same ‘name’), that the image only receive ONE <file>
entry in the <embedded-files>
section for that particular image path.
(Below is a partial xml section with some of the relevant parts and intended only as an example…and it may not be completely correct)
<material type-name="double-sided-material">
<material child-slot-name="front">
<texture child-slot-name="environment-texture">
<parameters>
<filename type="string">a\file\path\to\some\image.hdr</filename>
</parameters>
</texture>
</material>
<material child-slot-name="back">
<texture child-slot-name="environment-texture">
<parameters>
<filename type="string">a\file\path\to\some\image.hdr</filename>
</parameters>
</texture>
</material>
</material>
<embedded-files>
<!--
I believe the second <file> element below can be removed
as it is an exact copy of the first one...especially since their
name attributes have the same value
-->
<file name="a\file\path\to\some\image.hdr" original-size="1720094" compressed-size="1565558" compression="zlib" encoding="base64">some base64 nonsense</file>
<file name="a\file\path\to\some\image.hdr" original-size="1720094" compressed-size="1565558" compression="zlib" encoding="base64">some base64 nonsense</file>
</embedded-files>
(Edit)
Several month later, one of the users of my kit said they got a file-not-found error for the embedded image. So I really can’t recommend Rhino users to manually remove duplicate file entries from the rmtl files. I still think the devs might be able to reduce file size of rmtl files with embedded image data by adding only a single embedded data entry where the same image is used more than once in the same material (like a double-sided material or even if the same image is used in multiple slots of a single-sided material)