Skip to content

Commit

Permalink
ABZU: Move specular highlights to correct depth
Browse files Browse the repository at this point in the history
The same technique that works in Unity and MGSV to move specular
highlights to the accurate depth works in UE4 as well - subtracting
separation*convergence from the world space camera position.

Similar to Unity, this only fixes some of the specular highlights on the
shiny surface, suggesting that some of the highlights are drawn in the
forwards pass (and if so, would require all relevant shaders to be
modified, or if I can get the constant buffer modification technique to
work modifying it there might fix all specular highlights at once).

However, the shiny surface I was looking at was a glitch - the shader
had seemingly been replaced by a completely unrelated shader. Dumping
it with 3DMigoto restored it to the correct shader, but the broken one
returned with show_original and by removing the replaced shader. I'm not
sure where this came from (it could be a 3DMigoto bug, or possibly even
a 3D Vision bug), but I have observed some strange things related to
shader management in UE4 games before that this might be related to.
  • Loading branch information
DarkStarSword committed Dec 23, 2016
1 parent a93ed88 commit 31dfd0f
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
6 changes: 6 additions & 0 deletions ABZU/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,9 @@ known working driver:
- 376.19 (Mon Dec 05, 2016): Untested, presumed broken
- 376.33 (Wed Dec 14, 2016): Broken
- 376.48 (Wed Dec 21, 2016): Broken

Known Issues
============
While I was playing I came across a surface that was shiny and flickering like
crazy - I believe that the shader had been replaced by an unrelated one. This
was a glitch and cleared up after a restart.
6 changes: 5 additions & 1 deletion ABZU/ShaderFixes/18e877bb595a8a55-ps_replace.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// Spot lights from helmet in dark areas
// Spot lights from helmet in dark areas with specular highlight on shiny surfaces

// ---- Created with 3Dmigoto v1.2.51 on Sat Dec 24 04:12:43 2016
Texture2D<uint4> t8 : register(t8);
Expand Down Expand Up @@ -104,6 +104,10 @@ r0.x -= s.x * (r2.z - s.y);
r4.xyzw = cb0[43].xyzw + r4.xyzw;
r4.xyz = r4.xyz / r4.www;
r5.xyz = -cb0[53].xyz + r4.xyz;

// Fix specular highlight depth:
r5.xyz -= mul(float4(s.x * s.y, 0, 0, 0), MATRIX(cb0, 40)).xyz;

r0.x = dot(r5.xyz, r5.xyz);
r0.x = rsqrt(r0.x);
r5.xyz = r5.xyz * r0.xxx;
Expand Down

0 comments on commit 31dfd0f

Please sign in to comment.