Separate keys for effect on/off

More
4 months 3 weeks 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.

More
4 months 3 weeks ago - 4 months 3 weeks 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: 4 months 3 weeks ago by pondwithducks.

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

More
2 months 2 days ago - 2 months 2 days 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 months 2 days ago by Daemonjax.

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