Elegant way to enable-disable RTX from C++

How do games handle enabling-disabling RTX setting from the Menu? So the ideal flow could be to detect at the beginning/first run if the user has RTX capable (IsRayTracingEnabled() function does this and checks almost everything which can enable RTX). Now despite the machine supporting RTX, there’s a possibility that the user may still choose NOT to use it. In that case, if it’s disabled via the menu, then the game needs to be restarted, but am not sure what all flags to be modified after restarting so that RTX is OFF. Also, if user decides to turn it on, am assuming those same set of flags can be enabled?

Extending to this, if user system doesn’t support RTX, then how do you take the non-RTX path for the game using C++?

Any help would be appreciable.

Thanks.

Did you ever figure this out?

I’m setting up an options menu currently and want to have and RTX on/off setting but cannot seem to find any information on how to set that up.

All other graphics settings are neatly handled by UGameUserSettings which works great - but it’s lacking any RTX settings so I’m at a loss.

It is 2025 and there is still no answer for this presumably simple question.

Yes, we can change it in the project settings, but what if we need a realtime switch to support both high and low end configurations?

i’m pretty sure you just need to toggle “r.Raytracing.Enable” Cvar. Before UE 5.5 you had to restart the game for it to take effect, starting with 5.5 “r.RayTracing.EnableOnDemand” Cvar is now enabled by default so you should be able to toggle “r.Raytracing.Enable” at runtime without restarting.

Docs still say it’s experimental to “Toggle Ray Tracing at Runtime”, but it’s enabled by default now (5.5+) so i think they just didn’t update the doc page.

1 Like

Oh thank you!
With all recent google search degradations I was unable to find it.