google / filament

Filament is a real-time physically based rendering engine for Android, iOS, Windows, Linux, macOS, and WebGL2
https://google.github.io/filament/
Apache License 2.0
17.69k stars 1.87k forks source link

Feature Request: Set random seed for deterministic rendering #7831

Open nimrod-gileadi opened 4 months ago

nimrod-gileadi commented 4 months ago

Is your feature request related to a problem? Please describe.

I'm using Filament for off-screen batch rendering. It would be useful for me to have deterministic results, where rendering the same view twice results in the same pixel. For the scene I'm using, I'm able to achieve this by disabling dithering, but it would be nice to have dithering, and just be able to set the seed before I call Renderer::render.

Describe the solution you'd like This could be achieved by making FEngine::getRandomEngine a public method of Engine (so I could call engine->getRandomEngine().seed(1234)), or you could have a narrower interface with one function for setting the seed between render calls.

Describe alternatives you've considered

Disabling dithering (my current solution), or casting Engine* to FEngine* to get access to getRandomEngine().

romainguy commented 4 months ago

Dithering doesn't use a random seed but it's based on elapsed time.

nimrod-gileadi commented 4 months ago

Thanks for the correction. Is there a way for a client to explicitly set the time used for dithering?

romainguy commented 4 months ago

You cannot set the time but you can use Renderer::resetUserTime() to control the start time. Probably won't be enough for what you want.