Rising edge toggle compositor values from conditional overlap

sorry if this is the wrong place for this. this is a bit of a complex one and i could use some help working it out. in brief terms im trying to switch between 2 render layers based off if the camera passes through a specific region. i have managed to create a setup via geometry nodes to give me a boolean output if the camera is overlapping a target bounding box but i need to take that continuous true false value and make it toggle when it goes from false to true.

could i do this trivially with keyframes and constant interpolation? yes. do i want to? no. i figure that doing it this way once will allow me a versatile and reusable method to effectively automate the effect for more complex cases. plus, you know, its fun to try something different.

i figure this might need to use some python script but ideally if theres a way to do it with either geometry nodes or animation nodes i would appreciate some ideas.

heres a short video showing the current setup for context

Hello and welcome to BA !

Well, at least you’re aware that the simplest method might be the best :smiley:
A python script might do it. Geometry nodes I don’t think so because they deals with geometry.
You can do the maths easily to output the switch but you can’t drive a compositing node based on that.
Maybe animation node can do it, I haven’t looked into it.

A driver might do it, because it’s about driving a compositor node after all.
Or creating an animation curve with python.

Given that the door is at the center of the world, you can just check if the Y position of the camera is positive or negative, with an expression that looks like “var > 0”
where var is the Y location of the camera.
That will output 1 if the camera position is positive, 0 if it’s negative.

What if the door is not at the center ? well you just need to subtract the door position : “(var -vb) > 0”
Where vb is the door Y position.

All that said, that might work but it’s easy to make it fail.
You might take into account the X position , the width of the door…
I’m not sure if you need to account for camera rotation, or other things…

Without willing to sound too sarcastic , it looks like a great way to waist time to me, and it’s maybe better to focus on automating something that you can’t really fix manually :smiley:

Given that manually keying this stuff can take like 1mn ( I take finding the right frames into account),
How much time that can take to find a rock solid, automated solution that doesn’t fail ? 1 hour if you’re lucky ?
Given these numbers, you’ll have to go 60 times through that door to make the automated solution effective toward the manual one. But maybe the simple driver is enough, then why not, it’s not that complicated !

Good luck !

1 Like

thanks for the reply. your points are entirely valid and if this were for something production related keyframes would be both easiest and the best however this isn’t for anything like that. im just doing something interesting and fun and a challenge, ive just hit a road block with this specific problem is all. all i really need is some SR-Latch type function in the math nodes. that simple memory cell would allow me to then just use the sign of an axis (absolute or arbitrary origin) as the true false flag and the overlap state as the write signal, thus meaning it would only change the state if the camera is inside the bounds of my trigger.

im aware its likely i will need some python script to handle it and im open to doing that despite having no functional knowledge of programming at all (i understand the logic but translating to any given language’s terms is where i struggle).

the end goal is actually more of an “interactive art” thing than anything else. i also wanted a system/method i could reuse trivially and not have to resync things.

the reason im using geometry nodes is less about manipulating the geometry but more as a sort of substitute for a visual scripting tool to do the math. a simple driver getting the sign of the axis position would work fine in the linear case but that eliminates the option for one of the best parts of a TARDIS; walking around the back of it. in fact i have the camera doing just that. i just did not bother rendering out those frames as this was rendered specifically to serve as a quick context demo.

:smiley:
Ok ! I think geometry nodes is a dead end, because you can’t store a value.
That’s basically what you need to do a toggle. If it’s on then it turns off etc …
And needless to say that you need to export that value, how would you do that with the little demo you’ve made ? how would you control something in the compositor using GN ?

Maybe animation nodes allow that.

For a starter with python that might be a bit challenging because some parts aren’t easy to translate literally. Finding if some point is inside the bounds of an object in GN is relatively easy. It’s more involved in python. Probably in that case the same method used in the driver might be simpler as a basis, that you can enhance better with script rather than a driver.

But to make the right choices you need a prior experience.
In short you’ll likely make it way more complicated than it should be, without saying that’s not the simplest thing either.

Also making it interactive is a bit tricky, that means that the code should run every time an update in the scene is made. Which once again isn’t the simplest thing to do when you start scripting.
Writing F-Curves is a bit challenging to for a starter but probably a bit easier.

So, yeah for someone used to python it seems to me like a day of work, for a beginner … I’d say probably a few weeks with some external help.

I’d look a bit more into animation nodes first.

It could have been a good opportunity to learn python, but I think it’s way simpler to learn that without any goal in mind. Just learn how that stuff work for some time and then start doing useful things with it.

In the end , I totally get the idea, sometime taking the long road is useful, learning to automate things is great and can be put to good use latter. I tend to like these challenges ! But you may have picked the wrong subject…
I’d be happy to be proven wrong !

Good luck !

after thinking about it i did remember that its not trivial to read values from geometry nodes. would be a nice driver related feature. to be able to take some value or field and plug it into some output that can be used as a driver. seems like animation nodes is a more likely candidate since thats technically a node based driver system. or at least thats what i’d heard once. point is it seems its more closely related to the desired task. full disclosure, the only reason i started with geometry nodes is that i forgot i had even installed animation nodes, ha ha XD.

anyway. i will have a dabble with that. might need to somehow do the memory cell stuff via a small python script or something. nothing crazy. just getting the 2 relevant values from some driver or animation nodes setup, doing some sort of logic on them, then outputting a value to, say, a custom property. and yeh, starting a new skill (especially one as complex as programming) with a goal in mind isn’t always the best idea as you tend to misjudge the difficulty.

by chance would you be able to point me towards some useful information about blender python basics? like reading and writing values for instance? if i could dabble with simple things like moving an object around in space with code that would be a good start for me personally i think

thanks for the help :slight_smile:

Cool !

I think you should be able to avoid python here, and worse case scenario you output the data to the location of one object and use that as a driver variable. And you should be fine.

Looking into python is great, is one of the best advice I get when I started to go further into CG.
But as said, try to avoid applying that to your work first. And at some point you’ll start to have a lot of idea of things to experiment.

As a starter, you can look for basic python beginners tutorials (non-related to blender), you’ll find lot of them on the internet.
That will teach you the basics of the language, that is quite simple and that’s what you’ll use on a regular basis.

Then comes modules, that are special sets of commands that you load into your script for a particular tasks.
There are modules for nearly everything, like manipulating files on disk , manipulating images, accessing a ftp … And that’s where python gets really interesting, because you can do almost anything with the appropriate module.

And in blender there is a module called bpy, and using that you can redo everything that you can do in blender.
To learn that, I think a good start should be this one : https://studio.blender.org/training/scripting-for-artists/ That will probably also include python basics too.
But you can probably find other resources on youtube with a more limited scope.
Sometime tutorials will be more oriented toward making an addon, sometime it will be more oriented at manipulating data only.
I think you’ll find way less tutorials about python in blender than tutorial about sculpting , modeling ect…
But at least people manage to learn it so proper information should be there anyway :smiley:

appreciate the info. i will play around next chance i get :slight_smile:

1 Like

ive gotten a solution that seems to work quite well. thanks for the pointers and help. i may not have needed it in the end but i appreciate the effort and am happy to share the results should others need a similar solution :slight_smile: