-
Notifications
You must be signed in to change notification settings - Fork 125
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Far Cry Primal: Fix reflections via stereo2mono technique
The reflections in Far Cry Primal follow the same pattern as Far Cry 4, but fixing those required changes to every single vertex shader that might ever be used when creating the reflection, and there were a lot of these and I still find more. Instead, take a different approach of using 3DMigoto's stereo2mono support to reverse the eyes of the reflection (similar to the mirror in MGSVTPP), combined with the same world space correction and forced surface creation mode result in accurate 3D reflections. It seems that there are some issues with the reverse stereo blit and resources with mip-maps - it seems that the reverse stereo blit only takes effect on the most detailed mip map, and the rest just end up with a copy in one eye. The reflection seems to combine several mip-maps together, and if they are not present it will be much too dark. To work around this, use a custom shader that reverses the reflection to a custom resource with only a single mip-map level so that there will only be one to sample. This makes the ripples more detailed than they are supposed to be (looks fine to me), so I might revisit it later and see what we can do to solve the reverse stereo blit more generally.
- Loading branch information
1 parent
07784ee
commit 594d528
Showing
4 changed files
with
150 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
Texture2D<float4> StereoParams : register(t125); | ||
Texture1D<float4> IniParams : register(t120); | ||
|
||
void main( | ||
out float4 pos : SV_Position0, | ||
uint vertex : SV_VertexID) | ||
{ | ||
// Not using vertex buffers so manufacture our own coordinates. | ||
switch(vertex) { | ||
case 0: | ||
pos.xy = float2(-1, -1); | ||
break; | ||
case 1: | ||
pos.xy = float2(-1, 1); | ||
break; | ||
case 2: | ||
pos.xy = float2(1, -1); | ||
break; | ||
case 3: | ||
pos.xy = float2(1, 1); | ||
break; | ||
default: | ||
pos.xy = 0; | ||
break; | ||
}; | ||
pos.zw = float2(0, 1); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
Texture2D<float4> StereoParams : register(t125); | ||
Texture2D<float4> t100 : register(t100); | ||
|
||
void main(float4 pos : SV_Position0, out float4 result : SV_Target0) | ||
{ | ||
float4 stereo = StereoParams.Load(0); | ||
|
||
float width, height; | ||
|
||
t100.GetDimensions(width, height); | ||
|
||
if (stereo.z == -1) | ||
pos.x += width / 2; | ||
|
||
result = t100.Load(float3(pos.x, pos.y, 0)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters