Skip to content

Commit

Permalink
Viscera: Fix trapdoor in 1st locked room of office (accurate UE3 mult…
Browse files Browse the repository at this point in the history
…ipass fog fix)

Some of the fog volumes in UE3 are a little tricky as they are rendered
in two passes that interract with each other. These can be distinguished
by trying to unadjust them - one vertex shader brings the effect to
screen depth, while the other does not.

The vertex shader that brings it to screen depth needs texcoord5 to be
adjusted, while the other needs both the position and texcoord5 to be
adjusted.

The texcoord5 adjustments can be done in either vertex or pixel shader,
but the position adjustment needs to be done in the vertex shader.

Only doing part of the adjustment will either result in an outline
around closer objects, or the fog density being incorrect from a
distance, or other problems.
  • Loading branch information
DarkStarSword committed Oct 27, 2015
1 parent 4df8429 commit d4d9f63
Show file tree
Hide file tree
Showing 4 changed files with 281 additions and 0 deletions.
82 changes: 82 additions & 0 deletions Viscera/ShaderOverride/PixelShaders/0DAF3BEA.txt
@@ -0,0 +1,82 @@
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// Parameters:
//
// float4 DepthFilterSampleOffsets[2];
// float FaceScale;
// float4 FirstDensityFunctionParameters;
// float MaxDistance;
// float4 MinZ_MaxZRatio;
// sampler2D SceneColorTexture;
// float4 ScreenPositionScaleBias;
// float StartDistance;
//
//
// Registers:
//
// Name Reg Size
// ------------------------------ ----- ----
// FirstDensityFunctionParameters c0 1
// ScreenPositionScaleBias c1 1
// MinZ_MaxZRatio c2 1
// DepthFilterSampleOffsets c9 2
// StartDistance c11 1
// FaceScale c12 1
// MaxDistance c13 1
// SceneColorTexture s0 1
//

ps_3_0
def c3, 1, 0, 0.25, 65535
dcl_texcoord5 v0
dcl_2d s0

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

// Input adjustment inserted with DarkStarSword's shadertool.py:
// shadertool.py -i -f --adjust-input=texcoord5 PixelShader/PixelShader_24_CRC32_0DAF3BEA.txt
mov r30, v0
texldl r31, c220.z, s13
add r31.w, r30.w, -r31.y
mad r30.x, r31.w, r31.x, r30.x

rcp r0.x, r30.w
mul r0, r0.x, r30.xyxy
mad r0, r0, c1.xyxy, c1.wzwz
add r1, r0.zwzw, c9
add r0, r0, c10
mul r2, r1.xyxx, c3.xxyy
mul r1, r1.zwxx, c3.xxyy
texldl r1, r1, s0
texldl r2, r2, s0
mov r1.x, c3.x
add r1.x, r1.x, -c2.y
add r1.y, -r1.x, r2.w
rcp r1.y, r1.y
mul r2.x, r1.y, -c2.x
add r1.y, -r1.x, r1.w
rcp r1.y, r1.y
mul r2.y, r1.y, -c2.x
mul r3, r0.xyxx, c3.xxyy
mul r0, r0.zwxx, c3.xxyy
texldl r0, r0, s0
add r0.x, -r1.x, r0.w
rcp r0.x, r0.x
mul r2.w, r0.x, -c2.x
texldl r0, r3, s0
add r0.x, -r1.x, r0.w
rcp r0.x, r0.x
mul r2.z, r0.x, -c2.x
min r0, c13.x, r2
dp4_pp r0.x, r0, c3.z
min_pp r1.x, r0.x, c3.w
min_pp r0.x, r30.z, r1.x
add_pp r0.x, r0.x, -c11.x
mul r0.y, r0.x, c0.x
mul r0.y, r0.y, c12.x
cmp oC0.x, r0.x, r0.y, c3.y
mov oC0.yzw, c3.y

// approximately 40 instruction slots used (8 texture, 32 arithmetic)
47 changes: 47 additions & 0 deletions Viscera/ShaderOverride/PixelShaders/9530AC2B.txt
@@ -0,0 +1,47 @@
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// Parameters:
//
// sampler2D AccumulatedBackfacesLineIntegralTexture;
// float4 ScreenPositionScaleBias;
// float4 UniformPixelScalars_0;
// float4 UniformPixelVector_0;
// float4 UniformPixelVector_1;
//
//
// Registers:
//
// Name Reg Size
// --------------------------------------- ----- ----
// UniformPixelVector_0 c0 1
// ScreenPositionScaleBias c1 1
// UniformPixelVector_1 c9 1
// UniformPixelScalars_0 c10 1
// AccumulatedBackfacesLineIntegralTexture s0 1
//

ps_3_0
dcl_texcoord5 v0.xyw
dcl_2d s0

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

// Input adjustment inserted with DarkStarSword's shadertool.py:
// shadertool.py -i -f --adjust-input=texcoord5 PixelShader/PixelShader_25_CRC32_9530AC2B.txt
mov r30.xyw, v0 // manually fixed mask
texldl r31, c220.z, s13
add r31.w, r30.w, -r31.y
mad r30.x, r31.w, r31.x, r30.x

mov r0, c9
mad_pp oC0.xyz, r0.w, r0, c0
rcp r0.x, r30.w
mul r0.xy, r0.x, r30
mad r0.xy, r0, c1, c1.wzzw
texld r0, r0, s0
mul r0.x, -r0.x, c10.x
exp_sat_pp oC0.w, r0.x

// approximately 8 instruction slots used (1 texture, 7 arithmetic)
70 changes: 70 additions & 0 deletions Viscera/ShaderOverride/VertexShaders/0432F8F1.txt
@@ -0,0 +1,70 @@
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// Parameters:
//
// float4x4 LocalToWorld;
// float4 VSRRealDCoefficients1;
// float4x4 ViewProjectionMatrix;
//
//
// Registers:
//
// Name Reg Size
// --------------------- ----- ----
// ViewProjectionMatrix c0 4
// VSRRealDCoefficients1 c6 1
// LocalToWorld c7 4
//

vs_3_0
def c4, 9.98999977, 0.693147182, 1, -1
def c5, 2, 0, 0, 0
dcl_position v0
dcl_color1 v1
dcl_color o0
dcl_texcoord o1
dcl_texcoord5 o2
dcl_position o3

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

mov o0, v1
mov o1, c5.y
mul r0, c8, v0.y
mad r0, c7, v0.x, r0
mad r0, c9, v0.z, r0
mad r0, c10, v0.w, r0
mul r1, r0.y, c1
mad r1, c0, r0.x, r1
mad r1, c2, r0.z, r1
mad r0, c3, r0.w, r1
add r1.x, r0.z, c4.x
add r1.y, r1.x, c6.x
rcp r1.x, r1.x
log r1.y, r1.y
mul r1.y, r1.y, c6.y
mad r1.z, r1.y, -c4.y, c4.z
mov r2.z, c6.z
mad r1.y, r1.y, c4.y, r2.z
mul r1.y, r1.y, c6.x
add r1.z, r1.z, -c6.z
rcp r1.z, r1.z
mul r1.y, r1.z, r1.y
mul r1.x, r1.x, r1.y
rcp r1.x, r1.x
add r1.x, r1.x, c4.w
mul r1.x, r1.x, c6.w
mad r0.x, r1.x, c5.x, r0.x
mov o2, r0
mov r3, r0

// approximately 29 instruction slots used

// Output adjustment inserted with DarkStarSword's shadertool.py:
// shadertool.py -i -f --stereo-sampler-vs=s3 --adjust=position VertexShader/VertexShader_21_CRC32_ 432F8F1.txt
texldl r31, c220.z, s3
add r31.w, r3.w, -r31.y
mad r3.x, r31.w, r31.x, r3.x
mov o3, r3
82 changes: 82 additions & 0 deletions Viscera/ShaderOverride/VertexShaders/2DBAEEC0.txt
@@ -0,0 +1,82 @@
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.29.952.3111
//
// Parameters:
//
// float4 CameraPositionVS;
// float4x4 LocalToWorld;
// float4 VSRRealDCoefficients1;
// float4x4 ViewProjectionMatrix;
// float3x3 WorldToLocal;
//
//
// Registers:
//
// Name Reg Size
// --------------------- ----- ----
// ViewProjectionMatrix c0 4
// CameraPositionVS c4 1
// VSRRealDCoefficients1 c6 1
// LocalToWorld c7 4
// WorldToLocal c11 3
//

vs_3_0
def c5, 0.00784313772, -1, 9.98999977, 0.693147182
def c14, 2, 0, 0, 0
dcl_position v0
dcl_tangent v1
dcl_normal v2
dcl_color1 v3
dcl_color o0
dcl_texcoord o1
dcl_texcoord5 o2
dcl_texcoord6 o3
dcl_position o4
mad r0.xyz, v1.yzxw, c5.x, c5.y
mad r1, v2, c5.x, c5.y
mul r2.xyz, r0, r1.zxyw
mad r0.xyz, r1.yzxw, r0.yzxw, -r2
mul r0.xyz, r1.w, r0
mul r2.xyz, r1.yzxw, r0.zxyw
mad r2.xyz, r0.yzxw, r1.zxyw, -r2
mul r2.xyz, r1.w, r2
mul r3, c8, v0.y
mad r3, c7, v0.x, r3
mad r3, c9, v0.z, r3
mad r3, c10, v0.w, r3
mad r4.xyz, r3, -c4.w, c4
mul r5.xyz, r4.y, c12
mad r4.xyw, c11.xyzz, r4.x, r5.xyzz
mad r4.xyz, c13, r4.z, r4.xyww
dp3 o3.x, r2, r4
dp3 o3.y, r0, r4
dp3 o3.z, r1, r4
mov o0, v3
mov o1, c14.y
mul r0, r3.y, c1
mad r0, c0, r3.x, r0
mad r0, c2, r3.z, r0
mad r0, c3, r3.w, r0
add r1.x, r0.z, c5.z
add r1.y, r1.x, c6.x
rcp r1.x, r1.x
log r1.y, r1.y
mul r1.y, r1.y, c6.y
mad r1.z, r1.y, -c5_abs.w, c5_abs.y
mov r1.w, c5.w
mad r1.y, r1.y, r1.w, c6.z
mul r1.y, r1.y, c6.x
add r1.z, r1.z, -c6.z
rcp r1.z, r1.z
mul r1.y, r1.z, r1.y
mul r1.x, r1.x, r1.y
rcp r1.x, r1.x
add r1.x, r1.x, c5.y
mul r1.x, r1.x, c6.w
mad r0.x, r1.x, c14.x, r0.x
mov o2, r0
mov o4, r0
mov o3.w, -c5.y

// approximately 45 instruction slots used

0 comments on commit d4d9f63

Please sign in to comment.