Itoo Software Forum

Author Topic: "On Duplicate Material" setting problem  (Read 2817 times)

JTP Vis

  • Full Member
  • ***
  • Posts: 122
"On Duplicate Material" setting problem
« on: July 18, 2017, 02:40:37 PM »
Hi,

I've been facing a very frustrating problem for quite a while now, and i've only just worked out where the root of the problem is. It's to do with the setting "On Duplicate Material:" being set to "Replace from Library".

I've made a number of roofing presets, including a roof slate preset, and a ridge tile preset. They are both created in the same master file, so the presets both point to the same file. The objects all use the same multi-sup material in that master file, so that there are not too many materials created... it keeps it neater.

Here is the problem/error: I create a rc object in a new file using the slates, for instance. It has material 1 on. I then create a rc object that is the ridge tiles, which points to material 1. If use the setting "replace from library", when I create the second rc object, it applies the material from the library, and tries to replace the material on the first rc object with this newly "created" material. All well and good, but then I save the file and reset. If I now go to that file and try to open it, Max will crash. The file has become un-usable. The two rc objects are completely broken. I have tried merging everything into a new scene, but as soon as I try the rc objects Max will crash.

However, if I set rc to the other setting; "Use scene material" and repeat the creation steps above, when I make the second rc object it will apply the material already in the scene to the second rc object. I save, reset Max and then re-open the file and it's ok.

I have no idea why this happens, and while the file is still live the materials work fine. It appears that it's just something to do with saving the file when you're trying to apply a new material to an already generated object.

I am using Max 2016 or 2017 (not tested it on others yet) and I'm using RC 2.7.4. I did try upgrading to the latest version but it did not fix it. That was before a complete un-install of RC (registry and file deletion) and re-install to try to work out what the problem was. I'm also using v-ray 3.50.04 set to the default renderer.

Any suggestions? As I have said above, the way to get around the problem is to use the "Use scene material" option, but it might be useful to use the other option at some point?

Cheers,

Bill

FC1888

  • Full Member
  • ***
  • Posts: 158
Re: "On Duplicate Material" setting problem
« Reply #1 on: July 18, 2017, 03:26:25 PM »
I have noticed that myself, though I always do a material cleanup, before saving and here's the solution, at least for me

If several RC objects use the same multi material in a particular scene, Go into the mat editor and in one slot pick the material for the slates and in another pick the material from the ridges, you should find that the tiles material is NOT applied to the ridges despite them using the same material.

So what you do is select one of them in the material editor, select all the tile, ridge and hip RC objects that should be using the same one and apply that single material to them all.. Then save the file and you shouldn't have that problem again. This also tidies up the scene, since you only have the one material being used,  instead of two or three, which are all the same and of course you avoid that dialog.

Hope that helps

JTP Vis

  • Full Member
  • ***
  • Posts: 122
Re: "On Duplicate Material" setting problem
« Reply #2 on: July 18, 2017, 03:40:00 PM »
Hi FC1888,

Thanks for the reply and the pointers. I was aware of this technique, although I have not tested it in this particular situation (I will have a go to see if this fixes the problem). The reason for posting here was more to do with a potential identification of a problem with railclone, not how to apply materials. However, as I said, I'm going to test your method, following the steps that cause the crash, and see if that stops the crash too.

Bill

FC1888

  • Full Member
  • ***
  • Posts: 158
Re: "On Duplicate Material" setting problem
« Reply #3 on: July 18, 2017, 03:49:29 PM »
Well I have encountered a similar problem in another plugin called "VRay Preset Materials Manager". If you select an object, open the library of materials and apply one to the object, then choose another object later and apply that same material to that second object, you end up with duplicate materials. If you apply the material to the editor, then apply it to each object, you only have one.. However I have not had a scene crash when reloading due to duplicate materials, usually you just choose which material to use on loading and it loads just fine.. So yeah, while my solution is not a fix for whatever is causing the crash, hopefully it will prevent any further crashes, tidy up your scenes and same memory too

Would still love to hear from iToo, as to what might be causing the crash though

Anyway good luck

JTP Vis

  • Full Member
  • ***
  • Posts: 122
Re: "On Duplicate Material" setting problem
« Reply #4 on: July 18, 2017, 03:55:53 PM »
I have actually just done a further experiment with the simple scene, following your idea with applying a single material (multi sub in this case) to both the rc objects, after creating the second one with the "replace from library" setting on. It worked!

I have also made a further discovery about the materials. When you create the second rc object with "replace from library" setting on, the new object gets a new multi sub material, presumably from the library, but the old rc object gets an x-ref material, not the new updated material! This I don't understand. It would also therefore seem to be true that it is the introduction of the x-ref material that actually causes the problem! The x-ref material path is to the master file of the rc object.

Any suggestions?

Bill

JTP Vis

  • Full Member
  • ***
  • Posts: 122
Re: "On Duplicate Material" setting problem
« Reply #5 on: July 18, 2017, 04:59:08 PM »
This problem is proving to be a bit elusive :-(

I tried to create an rc object and replace it's material with an x-ref material, to see if that broke max: but it didn't. I even made sure the x-ref material was pointing to the rc master file, but it didn't break it.

Then I tried to re-create the problem again, so I could try some other options, only to find that it doesn't break anymore... even if I do exactly the same as I did this morning!!!!

the saga continues...

Bill

JTP Vis

  • Full Member
  • ***
  • Posts: 122
Re: "On Duplicate Material" setting problem
« Reply #6 on: July 18, 2017, 05:39:22 PM »
Another update:

It doesn't happen with rc original presets. I also know how to make a test scene to make it break:

1: make a cube with two materials in a multi sub applied to half the surfaces.
2: make a second cube and apply the multi sub to it. I set the surfaces to id 2.
3: make a spline (along which to make an rc object)
4: make an rc object with a linear 1s generator, one spline, and two objects, one cube one and the other cube 2. Apply cube 1 to the default slot and cube to the start and end. Apply the multi sub to it.
5: create a library object that points to the rc object in that scene. Save the lib and close. Don't import the style.
6: save and reset the max scene.
7: in the new max scene make two separate new spline objects.
8: make a new rc object, using the test library object, making sure that the "on duplicate material" option is set to "replace from library". apply it to one of the splines.
9: make another new rc object in the same was as above, with the same settings. Now go to the material pallet and select the "get material" button, if you're using the old style material/map browser, you can set the "browse from" selection to "scene" and you will see that the second rc object now has the multi sub material applied, but the first rc object now has an xref material applied to it... in fact I now notice that it also has the other material applied to it too!!! I don't even know how that is possible. This only shows up when you check through the method above! if yuo use the material picker you cannot tell that there are two materials applied to one object.

EDIT: I've also checked out the materials in the slate editor and discovered something more strange. The xref material that is applied shows the sub elements of the xref material live in the file... which doesn't normally happen. Also, the first rc object created also shows as having both the x-ref material applied, and the normal material from the second rc object applied, without being in a multi sub material!!!!! I can send you the master file, but not the second file as it will become erroneous if i save and close it. It has to be created in sequence and tested before it is saved.

does this point anyone in the right direction?

Bill
« Last Edit: July 18, 2017, 05:48:14 PM by JTP Vis »

Michal Karmazín

  • iToo Software
  • Hero Member
  • *****
  • Posts: 2447
Re: "On Duplicate Material" setting problem
« Reply #7 on: July 19, 2017, 12:03:41 PM »
Hi Bill,

To get the XRef Material, I guess you don't have the "Library updates objects using the same style" option enabled. Thought we can't reproduce any problems leading to crash, the material handling on these situations needs to be checked more in deep by our main developers. We will keep you posted.

Big thanks for your feedback, it's very important to us.

Best regards,

JTP Vis

  • Full Member
  • ***
  • Posts: 122
Re: "On Duplicate Material" setting problem
« Reply #8 on: July 19, 2017, 12:40:57 PM »
Hi Michal,

I've taken another look at this problem, and it would appear that it has more to do with my rc roof slates and it's material, rather than a generic problem than originally thought. While I thought it created strange materials on the generic model as described how to create below, it would appear that it doesn't actually cause a crash as predicted. How could I send you my preset, with the master file for you to test? There are two rc objects in my library that use the same material, and when used in the way described it will always cause a crash.

I do have the setting you mentioned enabled as it is default.

I'll try to send you my presets and how they are set up and see if that helps.

Cheers,

Bill

Michal Karmazín

  • iToo Software
  • Hero Member
  • *****
  • Posts: 2447
Re: "On Duplicate Material" setting problem
« Reply #9 on: July 19, 2017, 12:48:55 PM »
Hi Bill,

Thanks for your swift reply. Please feel free to send us your files to analyse them here. Thanks in advance.

Best regadrs,

JTP Vis

  • Full Member
  • ***
  • Posts: 122
Re: "On Duplicate Material" setting problem
« Reply #10 on: July 19, 2017, 03:29:38 PM »
I've sent you a few documents via we-transfer. I hope it all makes sense.

Please ask if you need further information.

Bill

JTP Vis

  • Full Member
  • ***
  • Posts: 122
Re: "On Duplicate Material" setting problem
« Reply #11 on: July 20, 2017, 04:51:37 PM »
Any luck recreating the crash with the files I sent over?

Cheers,

Bill

Michal Karmazín

  • iToo Software
  • Hero Member
  • *****
  • Posts: 2447
Re: "On Duplicate Material" setting problem
« Reply #12 on: July 20, 2017, 05:08:05 PM »
Hi Bill,

I've replied you by email a while ago. With your help, we've been able to reproduce this unwanted behaviour here too. We'll check what can be done to avoid similar troubles (it'll need to be investigated more in deep by our main developers).

Meanwhile, using the Override Material option (loading the material from a material library) while importing the style should avoid this troubles. Big thanks for all your feedback.

Best regards,

iToo

  • Administrator
  • Hero Member
  • *****
  • Posts: 4388
    • iToo Software
Re: "On Duplicate Material" setting problem
« Reply #13 on: July 21, 2017, 09:13:23 AM »
Hi, finally i could isolate and fix the bug.

In RailClone we use the XRef system, to import the library item temporary into the scene. Once its style and material is copied to the target object, this XRef is deleted.
But the problem happens in this way:

1) First RC object and its material are created correctly.
2) For the second RC object, the library item is imported as XRef in the scene.
3) But the material of this item already exists in the scene, so it's overwritten and assigned to the first RC object... but in XRef format. That creates the "ghost" XRef material.
4) In a further process, we get the base material of the XRef and assign it to both objects. Wrongly, because one of them already is a XRef which contains that same material... that corrupts the scene.

This bug doesn't happen with the builtin libraries because we don't store any materials in the scene, they are taken from the material lib.

The fix will be included in the next patch.
Until then, you can use the workaround suggested by Michal. If that doesn't work, try removing all materials from the RC objects in the style scene (it can be done from Maxscript using $.material = undefined).
« Last Edit: July 24, 2017, 01:30:54 PM by iToo »
Carlos Quintero
iToo Software

JTP Vis

  • Full Member
  • ***
  • Posts: 122
Re: "On Duplicate Material" setting problem
« Reply #14 on: July 24, 2017, 12:56:56 PM »
Thanks for looking into this for me, and I'm glad I can be of any "help" for this fantastic plugin. It's becoming more and more important for our work and is so powerful. I really wish I could use it to it's full potential!

Cheers,

Bill