Skip to content

Commit

Permalink
The Forest: Fix SSAO normal map artefacts
Browse files Browse the repository at this point in the history
These are the same type of artefact we saw with HBAO+, but here it's a
lot easier to fix - just a couple of places to subtract the stereo
correction formula.
  • Loading branch information
DarkStarSword committed Dec 14, 2015
1 parent 5aa19c5 commit 1c99194
Show file tree
Hide file tree
Showing 2 changed files with 115 additions and 4 deletions.
59 changes: 57 additions & 2 deletions The Forest/ShaderOverride/PixelShaders/0CC87CDB.txt
@@ -1,3 +1,44 @@
// CRC32: 0CC87CDB | Unity headers extracted from SESSAO.shader
// Shader "Hidden/SESSAO" {
// Properties {
// _MainTex ("Base (RGB)", 2D) = "white" { }
// }
// Fallback Off
// SubShader 1/1 {
// Pass 2/7 {
// ZTest False
// ZWrite Off
// Cull Off
// Fog { Mode Off }
// GpuProgramID 78601
// Program "fp" {
// SubProgram "d3d9 " {
// Matrix 0 [ProjectionMatrixInverse]
// Float 7 [Bias]
// Float 13 [Downsamp]
// Float 11 [DrawDistance]
// Float 12 [DrawDistanceFadeSize]
// Float 14 [HalfSampling]
// Float 9 [Intensity]
// Float 16 [Orthographic]
// Float 15 [PreserveDetails]
// Float 6 [Radius]
// Float 10 [SampleDistributionCurve]
// Float 8 [ZThickness]
// Vector 5 [_MainTex_TexelSize]
// Vector 4 [_ScreenParams]
// SetTexture 0 [_CameraDepthNormalsTexture] 2D 0
// SetTexture 1 [_CameraDepthTexture] 2D 1
// SetTexture 2 [_DitherTexture] 2D 2
// }
// }
// }
// }
// }
//
// Headers extracted with DarkStarSword's extract_unity_shaders.py
// https://raw.githubusercontent.com/DarkStarSword/3d-fixes/master/extract_unity_shaders.py

ps_3_0
def c17, 3.55539989, 0, -1.77769995, 1
def c18, 5, 4, 8, 9.99999975e-005
Expand All @@ -11,10 +52,21 @@
dcl_2d s0
dcl_2d s1
dcl_2d s2

def c220, 0, 1, 0.0625, 0.5
dcl_2d s15

texldl r31, c220.z, s15

mul r0, c23.xxyy, v0.xyxx
texldl r0, r0, s1
mad r0.z, r0.x, c23.z, c23.w
mad r0.xyw, v0.xyzx, c23.zzzy, c23.wwzx

// SSAO normal map artefact fix:
add r31.w, r0.w, -r31.y
mad r0.x, -r31.w, r31.x, r0.x

dp4 r1.x, c0, r0
dp4 r1.y, c1, r0
dp4 r1.z, c2, r0
Expand Down Expand Up @@ -78,6 +130,11 @@
texldl r7, r5, s1
mad r6.xy, r5, c23.z, c23.w
mad r6.z, r7.x, c23.z, c23.w

// SSAO normal map artefact fix:
add r31.w, r6.w, -r31.y
mad r6.x, -r31.w, r31.x, r6.x

dp4 r7.x, c0, r6
dp4 r7.y, c1, r6
dp4 r7.z, c2, r6
Expand Down Expand Up @@ -109,5 +166,3 @@
add r0.y, r1.x, c23.w
mad oC0.w, r0.x, r0.y, c23.x
mov oC0.xyz, c22.z

// approximately 119 instruction slots used (7 texture, 112 arithmetic)
60 changes: 58 additions & 2 deletions The Forest/ShaderOverride/PixelShaders/4CF4A2F4.txt
@@ -1,3 +1,45 @@
// CRC32: 4CF4A2F4 | Unity headers extracted from SESSAO.shader
// Shader "Hidden/SESSAO" {
// Properties {
// _MainTex ("Base (RGB)", 2D) = "white" { }
// }
// Fallback Off
// SubShader 1/1 {
// Pass 1/7 {
// ZTest False
// ZWrite Off
// Cull Off
// Fog { Mode Off }
// GpuProgramID 31003
// Program "fp" {
// SubProgram "d3d9 " {
// Matrix 0 [ProjectionMatrixInverse]
// Float 7 [Bias]
// Float 13 [Downsamp]
// Float 11 [DrawDistance]
// Float 12 [DrawDistanceFadeSize]
// Float 14 [HalfSampling]
// Float 9 [Intensity]
// Float 16 [Orthographic]
// Float 15 [PreserveDetails]
// Float 6 [Radius]
// Float 10 [SampleDistributionCurve]
// Float 8 [ZThickness]
// Vector 5 [_MainTex_TexelSize]
// Vector 4 [_ScreenParams]
// SetTexture 0 [_CameraDepthNormalsTexture] 2D 0
// SetTexture 1 [_CameraDepthTexture] 2D 1
// SetTexture 2 [_DitherTexture] 2D 2
// SetTexture 3 [_ColorDownsampled] 2D 3
// }
// }
// }
// }
// }
//
// Headers extracted with DarkStarSword's extract_unity_shaders.py
// https://raw.githubusercontent.com/DarkStarSword/3d-fixes/master/extract_unity_shaders.py

ps_3_0
def c17, 3.55539989, 0, -1.77769995, 1
def c18, 5, 4, 8, 9.99999975e-005
Expand All @@ -12,10 +54,21 @@
dcl_2d s1
dcl_2d s2
dcl_2d s3

def c220, 0, 1, 0.0625, 0.5
dcl_2d s15

texldl r31, c220.z, s15

mul r0, c22.xxyy, v0.xyxx
texldl r0, r0, s1
mad r0.z, r0.x, c22.z, c22.w
mad r0.xyw, v0.xyzx, c22.zzzy, c22.wwzx

// SSAO normal map artefact fix:
add r31.w, r0.w, -r31.y
mad r0.x, -r31.w, r31.x, r0.x

dp4 r1.x, c0, r0
dp4 r1.y, c1, r0
dp4 r1.z, c2, r0
Expand Down Expand Up @@ -85,6 +138,11 @@
texldl r9, r5, s1
mad r6.xy, r5, c22.z, c22.w
mad r6.z, r9.x, c22.z, c22.w

// SSAO normal map artefact fix:
add r31.w, r6.w, -r31.y
mad r6.x, -r31.w, r31.x, r6.x

dp4 r9.x, c0, r6
dp4 r9.y, c1, r6
dp4 r9.z, c2, r6
Expand Down Expand Up @@ -125,5 +183,3 @@
rsq r0.w, r0.w
mul oC0.xyz, r0.w, r0
endif

// approximately 137 instruction slots used (9 texture, 128 arithmetic)

0 comments on commit 1c99194

Please sign in to comment.