Separate keys for effect on/off

  • pondwithducks
  • Topic Author
More
2 years 3 months ago #1 by pondwithducks Separate keys for effect on/off was created by pondwithducks
Is there a way to use one button to enable an effect and another to disable it?
In Ys IX I use 4 different buttons to open various menus (I can map those all to one key, which I'd like to have set to enable the DOF effect), and one button to close any given menu, which would be set to re-enable the effect. Any way I can do this?

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

  • pondwithducks
  • Topic Author
More
2 years 3 months ago - 2 years 3 months ago #2 by pondwithducks Replied by pondwithducks on topic Separate keys for effect on/off
Alternatively, is there a way I can have an effect be nullified on pixels where the depth buffer is 100% white (aka menu screens)? I don't mind if this prevents the effect from working in the far far background.
Last edit: 2 years 3 months ago by pondwithducks.

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

  • Daemonjax
More
2 years 1 month ago - 2 years 1 month ago #3 by Daemonjax Replied by Daemonjax on topic Separate keys for effect on/off
> Is there a way to use one button to enable an effect and another to disable it?

Not sure about hotkeying specific shaders within a single preset, but I'm pretty sure you can hotkey different presets and so have a different presets with that shader enabled/disabled.  

>  is there a way I can have an effect be nullified on pixels where the depth buffer is 100% white

Yes.  You'll need to modify the shader to access the depth buffer, and then use some kind of interpolation function (you use case is slightly different, but anyways) between that shader's final pixel output color and the original pixel color using the depth value as the weight.  Sounds complicated, but it's really not.  I happen to have an example of me doing just that right here:
    
    if (DEPTH_FADE)
    {        
        finalColor = lerp(finalColor.rgb, original.rgb, Depth);
    }
    return float4(finalColor, 1.0);

where float value Depth is the result of a linear depth texture tap -- the function is found in reshade.fxh or whatever.  You can also add a ui element to create a slider for the strength of the effect and just multiply Depth by it.

BUT you just want depth to equal 1 if and only if it's actually 1, otherwise you want it to be zero, right?  There's a couple ways to skin that cat... you can simply convert the float to int so:

finalColor = lerp(finalColor.rgb, original.rgb, (int)(Depth));

... or floor() or trunc() it.  I don't remember which is more performant.  You can also do the lerp manually, which may or may not be more performant.  But it really shouldn't matter because we're talking about like 1 instruction more or less, so probably like 4 cycles.

* if it does the opposite thing you want it to do, don't make the weight calculation more complicated -- just swap the finalColor and Original lerp arguements.  I can never remember the right order for lerp anyways. ;)
Last edit: 2 years 1 month ago by Daemonjax.

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

We use cookies
We use cookies on our website. Some of them are essential for the operation of the forum. You can decide for yourself whether you want to allow cookies or not. Please note that if you reject them, you may not be able to use all the functionalities of the site.