[Closed] Callback to notify on changes on materials
Is there any way to catch material changes with callbacks or something similar? Like when I change my Standard materials color to black, it would trigger. Is it possible?
“when parameters $mat do” would do it, but it triggers way too often, even when selecting the material in medit.
Basicly I would like it to trigger each time material editor updates its preview of the material.
When I was writing the TriMatoGraph script, I also used a when construct with the base material as the argument. It is up to you to filter out the additional calls – for example, you could set a threshold and record the last update time – if the new call comes earlier than, say, one second, you could ignore it. Also, you could store the time it takes to refresh the whole material and then dynamically adjust the threshold based on that. So if you know that it takes 0.5 seconds to actually rerender all samples, you could filter out all calls coming during this time and the following 0.5 seconds to leave some time for interactivity. Another thing you could do is have a timer which is being reset each time a call is triggered, pushing the actual update for later point in time. For example, if you are changing a color in the color picker, the calls will come constantly and would just reset the base time. When they stop coming, the timer would wait for a given interval, say, one second, and then do the actual update, assuming the user has stopped moving the colors around.
Don’t expect everything to be available, be creative – that’s the fun part of coding, right?