Recreating Mirror Mode mod using a shader?
- CelicetheGreat
- Topic Author
Years ago someone created a mirror mode effect using the FXAA shader included with DSFix for Dark Souls. Here is a link to the download from the original reddit post,
www.reddit.com/r/darksouls/comments/17k3ai/pc_mirror_mode_mod/
Here is the shader code itself (posting this in the original post was what seemed to get my post regarded as spam and thrown out),
pastebin.com/L5vRj3Dq
A game update at some time broke the shader effect. I was wondering if it would be possible to recreate the mirroring effect. The big thing is that the original mod didn't affect the 2D hud elements which was really nice.
Thank you for any help or tips you guys can provide.
Please Log in or Create an account to join the conversation.
- Marty McFly
texture BackBufferTex : COLOR;
sampler BackBuffer { Texture = BackBufferTex; };
void PostProcessVS(in uint id : SV_VertexID, out float4 position : SV_Position, out float2 texcoord : TEXCOORD)
{
texcoord.x = (id == 2) ? 2.0 : 0.0;
texcoord.y = (id == 1) ? 2.0 : 0.0;
position = float4(texcoord * float2(2.0, -2.0) + float2(-1.0, 1.0), 0.0, 1.0);
}
void PS_Mirror(in float4 position : SV_Position, in float2 texcoord : TEXCOORD, out float4 o : SV_Target0)
{
o = tex2D(BackBuffer, float2(1 - texcoord.x, texcoord.y));
}
technique MirrorScreen
{
pass
{
VertexShader = PostProcessVS;
PixelShader = PS_Mirror;
}
}
This is basically everything. Your original source code also applies FXAA but I omitted it since ReShade has a separate FXAA (and SMAA) shader. Save as any .fx file and drop it where ReShade loads the shaders.
Please Log in or Create an account to join the conversation.
- CelicetheGreat
- Topic Author
This is what it looks like if I use the original shader, and the problem it causes in the latest version of Dark Souls:
i.imgur.com/unLsuZc.jpg
i.imgur.com/40z3XMR.jpg
i.imgur.com/gXazUfp.jpg
The problem is it looks like any alpha effects are not mirrored in the image, such as the tree dof silhouettes, character hair, bonfire effects, and many other things. Originally, all of these worked and the UI stayed left-to-right while only 3D geometry appeared flipped. A few effects like sunshafts and the lock-on icon had problems, but nothing like the above problems.
When using the shader you posted, I don't notice any of the above problems, but I do see that the UI is flipped with the rest of the image. This is what the shader you posted looks like in-game (and some other unrelated shaders on too),
i.imgur.com/WWcRh9x.jpg
i.imgur.com/F9CpTqG.jpg
Please Log in or Create an account to join the conversation.
- Marty McFly
Please Log in or Create an account to join the conversation.
- CelicetheGreat
- Topic Author
Please Log in or Create an account to join the conversation.
- crosire
Please Log in or Create an account to join the conversation.
- CelicetheGreat
- Topic Author
Thank you for both of your inputs crosire and Marty McFly.
I noticed the depthbuffer has a preview feature for the 3D geometry. If the shader is able to detect only 3D geometry, could it perhaps be able to also mirror only that detected geometry, or am I grossly misunderstanding or oversimplifying what the depth buffer stuff is all about?
Please Log in or Create an account to join the conversation.
- OtisInf
CelicetheGreat wrote: I contacted the author of DSfix, and according to him, the reason the shader works (or worked) was that originally DSfix applied the shader effect before the game itself applied alpha effects. So it was a game-specific hack that seems to be lost to newer revisions of the game Dark Souls.
Thank you for both of your inputs crosire and Marty McFly.
I noticed the depthbuffer has a preview feature for the 3D geometry. If the shader is able to detect only 3D geometry, could it perhaps be able to also mirror only that detected geometry, or am I grossly misunderstanding or oversimplifying what the depth buffer stuff is all about?
no:
Even if it was possible to detect where the UI elements are, the mirrored image would need to reconstruct what's behind them and that's not possible.
Please Log in or Create an account to join the conversation.