Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deterministic per-frame RNG #164

Open
gregcotten opened this issue Jun 9, 2024 · 2 comments
Open

Deterministic per-frame RNG #164

gregcotten opened this issue Jun 9, 2024 · 2 comments

Comments

@gregcotten
Copy link

gregcotten commented Jun 9, 2024

I'm just stubbing this issue for now, but some context:

One of our plugins uses kOfxPropTime to seed its RNG so we can do deterministically random things per-frame so when render is called on that frame, the frame looks the same, every time. kOfxPropTime isn't necessarily unique, and could be repeated for multiple clips depending on how the host uses it. It would be useful to have some sort of "per plugin instance" way of seeding the RNG, so that randomness is calculated as a combination of the plugin instance's unique ID and the current kOfxPropTime.

I have also considered storing some sort of secret property on the plugin instance that defaults to 0 but then is immediately replaced with a random number if its value is 0, but that behavior is kind of weird and probably most hosts implementations of copying parameters from one plugin instance to another would simply copy the random number I generated over to another instance, which is not desired.

Has anyone thought about how one might do this without adding anything to OpenFX?

@john-paulsmith
Copy link
Contributor

Quite a few plug-ins have needed things like this over the years, but it's usually done with a visible seed parameter that's initialised to a random number. The reason you want a visible parameter is so that the user can set it manually to get an identical, predictable effect. If you want the user to be able to "roll the dice" to get random looks, you could include a re-seed button.

@gregcotten
Copy link
Author

Quite a few plug-ins have needed things like this over the years, but it's usually done with a visible seed parameter that's initialised to a random number. The reason you want a visible parameter is so that the user can set it manually to get an identical, predictable effect. If you want the user to be able to "roll the dice" to get random looks, you could include a re-seed button.

For sure! We have a checkbox for "automatic" RNG mode that can be unchecked to reveal the underlying seed parameter. Unfortunately still the pitfall of hosts naively copying this parameter around when duplicating instances of the plugin when the user likely doesn't want this parameter copied still arise! There doesn't really seem to be much for the plugin to do here to mitigate things like that.

Also, in a "progressive disclosure" sense, I'd rather the user not have to manually manage the seed until they know they need to - our plugin should "do the right thing" until then. Just looking for a creative solution that allows for the plugin user to not have to worry about two plugin instances having identical RNG until they actually want that to happen.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants