Isotropix Forums

Resource Reloading

Clarisse Scripting related topics

Resource Reloading

Unread postby wilso_will » Wed Sep 16, 2020 10:38 am

Hi,

I'm putting together some tools to allow artists to easily reload resources when they change on disk. Primarily I'm concerned with USD and texture maps, but I've also been testing with Alembics and references to other Clarisse files. I'm getting some pretty varied results as to whether Clarisse will pick up the updates or not.

I'll touch on both the UI reload methods and the code ones. The UI methods I'm testing are the "Reload Resources" option in the File menu. The "Reload" button in the Attribute Editor on the reference node itself, and the "Reload" and "Reload all" buttons in the Resource View. I will say, up front, that the buttons in the Resource View have not worked to reload any form of resource for me, which makes me wonder if I'm misunderstanding their purpose.

USD
None of the UI methods work to reload a USD. The only piece of code I can produce that will reload a USD is the following:
Code: Select all
for item in ix.selection:
    if item.is_context():
        engine = item.get_engine()
        engine.unload()
        engine.load(True)

Furthermore, if there are two references to the same USD in the scene, even the above code won't work. You need to first unload all references to the USD and then load them again.

Texture Maps
The File menu "Reload Resources" button will reload texture maps. I can't find any way to reload an individual map (I may be missing something), as I said the Resource View "Reload" button doesn't do anything here. If I "Clear" the texture map in the Resource View and then tumble the viewport Clarisse will pull the texture back in and it will be the updated texture.

In the same vein, this code will reload a selected texture map:
Code: Select all
textures = ix.api.OfObjectVector()
ix.application.get_selection().get_objects(textures)
texture_items = ix.api.OfItemVector()
for item in textures:
    if item.is_kindof("Texture"):
        texture_items.add(item)
ix.application.unload_resources(texture_items)

As with pressing "Clear" in the Resource View you will need to do something to prompt Clarisse to pull the texture back in. Tumbling the viewport does the trick.

Alembic/Clarisse Files
These seem far more predictable. All the different UI buttons work (except the Resource View) and the following code does the job:
Code: Select all
for item in ix.selection:
    if item.is_context():
        engine = item.get_engine()
        engine.reload()

So, given all this, I was wondering if this is the expected behaviour? Should USDs be reloadable? Am I doing something wrong? Is there better code to reload a single texture map? If there isn't, is there something I can do through code to prompt Clarisse to reprocess the scene so that users don't have to tumble the viewport in order for the updates to appear? Should the "Reload" buttons in the Resource View reload the resource files, or are they for something else?
wilso_will
 
Posts: 2
Joined: Mon Feb 25, 2019 11:22 pm

Re: Resource Reloading

Unread postby wilso_will » Wed Sep 16, 2020 11:47 am

I meant to say, I'm using Windows 10, Clarisse 4.0 SP10.

We have since found this post https://forum.isotropix.com/viewtopic.php?f=5&t=3519&p=14469&hilit=resync#p14468, which seems relevant with regard to the Resource View, but also dates back to 2017 and the bug mentioned is no longer in the bug tracker.
wilso_will
 
Posts: 2
Joined: Mon Feb 25, 2019 11:22 pm

Re: Resource Reloading

Unread postby dcourtois » Wed Sep 16, 2020 1:35 pm

Hi,

USD: there's indeed a bug in how we manage it. Contrary to Alembic, opening a stage can be quite costly, and takes up significant memory. To avoid this, stages are deduplicated and kept in memory (for playback without paying the cost of reopening the stage) This is why when you have the same stage referenced twice it won't update when you reload only one.
I'll have a look and make it at least behave like Alembic references (which should have been the case, but we missed this)

Resource View / Texture Maps: I'm not really familiar with this part, so I'll have to read the other post you mentioned and do some digging around before reporting back, but it seems there are some bugs (I don't see why `Reload all` would work and not `Reload`...)

Edit: the bug report ID is an internal ID, that's why you won't find it in the bug tracker. Still digging :)
User avatar
dcourtois
 
Posts: 94
Joined: Tue Jul 25, 2017 3:15 pm

Re: Resource Reloading

Unread postby will_wilson » Thu Sep 17, 2020 9:41 am

Thanks. Apologies, I was actually logged in to the wrong account when I made this thread. This is the account I'll use from now on.

I mostly content with the solution I've found for USD. I can hunt out the other references to the same file and do a mass unload/reload. Once you bring USD more in line with Alembic I can change the system.

What I've got for the textures feels like a hack, and like I'm missing a better option somewhere. If you find anything in your digging, let me know. Failing that, what I'm doing at present is working. I'm sure there must be some way to force Clarisse to do whatever internal evaluation causes it to pull the textures back in. If you find anything on that, please let me know.

On the Resource View, neither "Reload all" nor "Reload" is working for me.
will_wilson
 
Posts: 2
Joined: Wed Feb 19, 2020 4:15 pm

Re: Resource Reloading

Unread postby anemoff » Fri Sep 18, 2020 4:34 pm

For textures, that is the way to go for now. There's no dedicated API on Texture items.

Cheers,
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 330
Joined: Wed Jan 13, 2016 10:10 am

Re: Resource Reloading

Unread postby will_wilson » Mon Sep 21, 2020 10:51 am

Thanks. I'll move ahead with what I've got then. Any suggestions as to how to get the update to appear in the viewport without manually having to tumble the camera or similar? I'm not even certain whether it's just a simple redraw I need, or whether Clarisse needs to do some deeper re-evaluation. I think it's the latter as the resources in question don't pop back in to the Resource View until after tumbling the viewport.
will_wilson
 
Posts: 2
Joined: Wed Feb 19, 2020 4:15 pm

Re: Resource Reloading

Unread postby anemoff » Tue Sep 29, 2020 4:56 pm

Sorry for the late reply.
There's no scriptable workaround for that, or none that I can think of, for now.
Anthony Nemoff
Isotropix
R&D Engineer
User avatar
anemoff
 
Posts: 330
Joined: Wed Jan 13, 2016 10:10 am


Return to Scripting
cron