Shaders uniforms variable reset

  • K4sh
  • Topic Author
More
1 week 3 days ago #1 by K4sh Shaders uniforms variable reset was created by K4sh
I have made a shader that is used in a Reshade addon.
Uniforms variables are stored in ReShadePreset.ini and can persist if the game crash.
I would like to know what is the best practice to reset all uniforms on game loading (which event can be used to reset uniforms only once and before i can use them).

Please Log in or Create an account to join the conversation.

  • K4sh
  • Topic Author
More
1 week 2 days ago - 1 week 2 days ago #2 by K4sh Replied by K4sh on topic Shaders uniforms variable reset
I was finally able to reset uniforms variable once on reshade_begin_effects event using this code :
Global variable definition :
    static LONG g_uniformReseted = 0;


reshade_begin_effects callback :
    if (InterlockedCompareExchange(&g_uniformReseted, 1, 0) != 0) return; // reset OSD uniforms once
    if (<myuniformvariable>.handle && ...) {
        runtime->reset_uniform_value(<myuniformvariable>;);
        ...
        runtime->save_current_preset();
    }
Last edit: 1 week 2 days ago by K4sh.

Please Log in or Create an account to join the conversation.