I have some issues with the RenderContent create/copy/instance APIs in v7, which are working differently for me here than in v6. In a nutshell, my types are able to reference other types (of mine, or others), and they should be able to reference a given instance multiple times, at different slots in a given type, displaying to the user as a link to the referenced instance. This is working for me in v6, but not in more recent builds of v7 (not sure exactly when it changed).
Below are some detailed sequences (done on the most recent v6 SR and the most recent v7 RC) to demonstrate what I am referring to, based on use of this test code:
TestLinkTextures.cs (6.6 KB)
v6
1. create a Test Link textures material
2. click the first "Choose texture" link
3. choose a new 2D Checker Texture
a. the new texture does not show up in the Textures list
b. it is shown below the material in tree view
c. the material xml shows one "rcm-2d-checker-texture"
4. click the second "Choose texture" link
5. try to create an instance of the checker texture
a. you cannot, because it does not appear in the list
6. right-click > Copy the texture in the material tree
7. right-click > Paste as Instance in the textures panel
a. the texture is added, with "(Shared)" appended
b. the texture now has a non-empty Group ID
8. repeat step 5, which is now possible
a. the texture shows up under the material in the tree
b. both instances of the texture have unique Instance IDs
c. the material xml shows a second "rcm-2d-checker-texture"
9. save & re-open the file, everything looks ok
v7 - approach 1
1. create a Test Link Textures material
2. click the first "Choose texture" link
3. choose a new 2D Checker Texture
a. a new texture appears in the Textures list
b. it is also shown below the material in tree view
c. the material xml shows one "rcm-2d-checker-texture"
4. click the second "Choose texture" link
5. try to create an instance of the checker texture
a. you can do so, but MakeGroupInstance will fail
b. MakeCopy will be used instead, and will succeed
c. "(Instanced)" is appended in the Textures list
d. the texture still has an empty Group ID
e. the texture now shows up twice in the material tree
f. both copies show the same Instance ID
g. the material xml has added a "texture-proxy"
6. save & re-open, one of the textures is a "Texture Proxy"
v7 - approach 2
1. create a new 2D Checker texture
2. create a new Test Link Textures material
3. click the first "Choose texture" link
4. create an instance of the texture
a. MakeGroupInstance will fail
b. MakeCopy will be used instead, and will succeed
c. "(Instanced)" is appended in the Textures list
d. the texture still has an empty Group ID
e. it is shown below the material in tree view
f. the material xml shows one "texture-proxy"
5. repeat steps 3 & 4 with the second "Choose texture" link
a. a sequence of events similar to above will occur
b. all "instances" of the texture show the same Instance ID
c. the material xml shows a second "texture-proxy"
6. save & re-open
a. two "Texture Proxy" textures show up in the Textures list
b. both of these are linked in the material tree
I know it is possible to make things work, since the built-in texture chooser (e.g. used in the cycles glass material) is able to correctly do what I am trying to accomplish. However, that uses a different API (the Fields.AddTextured one), so it is probably not purely using c# rhcommon, internally.
I had a similar issue once before, where I was not calling RenderContent.Replace in a certain spot (after calling RenderContent.Edit), so hopefully it is just something like that, but the very different behavior of the two versions, and the fact that the example works as I expect in v6, makes me uncertain about what is really happening.