4lex4nder / ReshadeEffectShaderToggler

Reshade 5+ addin to apply Reshade effects to render targets of shader groups based on a key press. It allows you to configure these groups from within the addin as well.
MIT License
89 stars 9 forks source link

How to use Constant Binding functionality? #33

Open Fubaxiusz opened 9 months ago

Fubaxiusz commented 9 months ago

Hi, great addon.

I have found binding to the vertical FOV value in the vertex shader Constant binding tab. It is encoded in the projection matrix (https://ogldev.org/www/tutorial12/tutorial12.html) and can be extracted to the FOV with the following formula: 90°=2*atan(1/0.5625 * 9/16), where 0.5625 is the matrix value, and 9/16 is to convert it to in-menu (see background) 90° vertical FOV, from horizontal matrix's FOV.

How do I use that value inside a shader like PerfectPerspective.fx?

obraz

4lex4nder commented 9 months ago

You can define a uniform matrix variable in your effect with a custom source and add a binding at the matrix offset for it (you can then select that variable under "Add variable binding" with the offset you see in the editor), REST will then feed it into that variable Like so: uniform float4x4 fov < source = "MY_FOV"; >;, but you can also use just use a float if you need a singular value