Options for switching between many scenes

While I’m relatively new to TD - this no longer seems like strictly a beginner question.

I’m trying to put together essentially a “slide-show” of multiple 1080p scenes.

Using the sceneChanger component and just a laptop (older macbook pro with Radeon) my framerate is dropping to single digits after just a couple scenes. This seems to be because plenty of children in my scenes keep cooking even when not the active scene.

In looking for solutions I’m considering the following which both look like they would work:

  1. externally script the launching and killing of different TD processes, using perform on launch for multiple .toe files. Advantage is that I can have a directory with infinite files and they all stay simple and efficient to work with. Downside is that both for editing and performing, repeatedly launching TD has its own drag/tax

  2. Basically writing a some custom python to augment sceneChanger - a simple sequence like this seems to do the trick in principle

op('/project1/sceneChanger').par.Nextscene.val = 2
op('/project1/sceneChanger').par.Firescene.pulse()
op('/project1/scenes/clouds').allowCooking=False
# play scene
time.sleep(60)
op('/project1/scenes/clouds').allowCooking=True
# allow cook to start
time.sleep(3)
op('/project1/sceneChanger').par.Nextscene.val = 3
op('/project1/sceneChanger').par.Firescene.pulse()

This allows me to keep only one running process during perform, and while editing keep everything open without relaunching TD - the main downside is it looks like I’m going to have to run this orchestration script in a thread for the sleeping, and use queues to shuttle the actions to be executed via the run func in one of the onFrame handlers in the execute DAT

I’m leaning toward option 2 - but both seem hacky

Also considering figuring out how to add the allowCooking call into the sceneChanger extension directly somehow.

So I’ve got both methods working - initially had some issues getting queue to work as I wanted, and got the process manager one working, it looks like this for anyone looking for something similar.

I do have the threading version working now, and with the cross-fade of sceneChanger, shared audio adjustments, etc I’m going to hopefully use that one

-P

Yeah, I would not mess with sleeping, as you said, hacky, and it will make more problems than it solves. You also shouldn’t ever need to touch the allowcooking on scenes (as seen in your first post), sceneChanger is designed to optimize cooking so only the 2 scenes being crossfaded should ever be cooking. If you have children cooking inside scenes when they are not in use you either a) have viewers on which causes them to cook, or b) are using the data inside the scene somewhere else, both which should be avoided when building scenes for sceneChanger. The other thing that might cause this unintended cooking is if you are connected to in/out devices which cook every frame. Good design in a sceneChanger system would get these out of your scenes and somewhere central, again only the scenes that need it would ask for the data when they are running. You can use the ‘Play’ parameter on each scene to turn these off when the scene is not in use, most devices have an ‘Active’ toggle.

Also, check out the sceneChanger’s built-in extension allowing you to call up a scene by index or name instead of having to interact directly with multiple parameters.

For changing through scenes like a playlist, I would recommend a Timer CHOP which uses segments. In the attached example, the segments table lists how many seconds each scene will run for, and the segment channel output from the Timer CHOP is used to change the scenes. This is segment val used by the CHOP Execute DAT to fire the sceneChanger’s extension, just 1 line of python.
This Timer CHOP reinitializes to the first scene when done, but you can control that behavior in the Timer CHOP parameters.

sceneChanger_timer.toe (32.7 KB)

You want TouchDesigner to be playing forward naturally all the time and shouldn’t need to be managing cooking like that. Just make sure that any two scenes can play together at once as that is a minimum requirement for cross-fading between any 2 scenes.

1 Like

Hey Ben, just want to say thanks for this code, it helped me loads.

1 Like