User:Helifax
From Bo3b's School for Shaderhackers
Lesson 0
Before installing HelixMod Wrapper:
After installing HelixMod Wrapper:
Lesson 1
Before removing the lens flare:
After removing the lens flare:
The vertex shader that controls is:
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022
//
// Parameters:
//
// float4 CameraPosition;
// float4 CameraRight;
// float4 CameraUp;
// float3 ExponentialFogColor;
// float3 ExponentialFogLightVector;
// float3 ExponentialFogParameters;
// float4 FogDistanceScale;
// float4 FogExtinctionDistance;
// float4 FogInScattering[4];
// float4 FogMaxHeight;
// float4 FogMinHeight;
// float4 FogStartDistance;
// float3 LightInscatteringColor;
// float4x4 LocalToWorld;
// float4x4 ViewProjectionMatrix;
// float bUseExponentialHeightFog;
//
//
// Registers:
//
// Name Reg Size
// ------------------------- ----- ----
// ViewProjectionMatrix c0 4
// CameraPosition c4 1
// LocalToWorld c6 4
// FogInScattering c10 4
// CameraRight c14 1
// CameraUp c15 1
// bUseExponentialHeightFog c16 1
// ExponentialFogParameters c17 1
// ExponentialFogColor c18 1
// LightInscatteringColor c19 1
// ExponentialFogLightVector c20 1
// FogDistanceScale c21 1
// FogExtinctionDistance c22 1
// FogStartDistance c23 1
// FogMinHeight c24 1
// FogMaxHeight c25 1
//
vs_3_0
def c5, 0.00100000005, 1, 0, -1
def c26, 0.159154937, 0.5, 6.28318548, -3.14159274
dcl_position v0
dcl_tangent v1
dcl_blendweight v2
dcl_texcoord v3
dcl_texcoord1 v4
dcl_texcoord2 v5
dcl_texcoord o0.xy
dcl_texcoord1 o1
dcl_texcoord2 o2
dcl_texcoord4 o3
dcl_texcoord5 o4
dcl_texcoord6 o5
dcl_position o6
mul r0, c7, v0.y
mad r0, c6, v0.x, r0
mad r0, c8, v0.z, r0
mad r0, c9, v0.w, r0
mad r1.x, v2.x, c26.x, c26.y
frc r1.x, r1.x
mad r1.x, r1.x, c26.z, c26.w
sincos r2.xy, r1.x
mul r1, r2.y, c14
mad r1, -r2.x, c15, r1
mul r3, r2.x, c14
mad r2, r2.y, c15, r3
mul r3.xy, v1.zwzw, v1
add r3.zw, -c26.y, v3.xyxy
mul r3.xy, r3.zwzw, r3
mad r0, r3.x, r1, r0
mad r0, r3.y, r2, r0
mul r3.xyz, r1.zxyw, r2.yzxw
mad r3.xyz, r1.yzxw, r2.zxyw, -r3
nrm r4.xyz, r3
mul r3, r0.y, c1
mad r3, c0, r0.x, r3
mad r3, c2, r0.z, r3
mad r3, c3, r0.w, r3
mad r5.xyz, r0, -c4.w, c4
dp3 o5.x, r1, r5
dp3 o5.y, r2, r5
dp3 o5.z, r4, r5
abs r0.w, c16.x
if_lt -r0.w, r0.w
add r1.xyz, r0, -c4
dp3 r0.w, r1, r1
rsq r0.w, r0.w
rcp r1.w, r0.w
mul r1.w, r1.w, c17.x
slt r2.x, c5.x, r1_abs.z
mul r2.y, r1.z, -c17.y
exp r2.y, r2.y
add r2.y, -r2.y, c5.y
mul r2.z, r1.z, c17.y
rcp r2.z, r2.z
mul r2.y, r2.z, r2.y
mad r2.y, r1.w, r2.y, -r1.w
mad r1.w, r2.x, r2.y, r1.w
mul r1.xyz, r0.w, r1
dp3 r0.w, c20, r1
slt r1.x, r0.w, c17.z
mov r2.xyz, c18
add r4.xyz, r2, c19
mul r5.xyz, r4, c26.y
add r1.y, r0.w, c5.y
mov r6.y, c5.y
add r1.z, r6.y, c17.z
rcp r1.z, r1.z
mul_sat r1.y, r1.z, r1.y
mad r2.xyz, r4, c26.y, -r2
mad r2.xyz, r1.y, r2, c18
add r0.w, r0.w, -c17.z
add r1.y, r6.y, -c17.z
rcp r1.y, r1.y
mul_sat r0.w, r0.w, r1.y
mul r0.w, r0.w, r0.w
mov r1.y, c26.y
mad r4.xyz, r4, -r1.y, c19
mad r4.xyz, r0.w, r4, r5
lrp r5.xyz, r1.x, r2, r4
exp r0.w, -r1.w
min r0.w, r0.w, c5.y
add r1.x, -r0.w, c5.y
mul o3.xyz, r1.x, r5
mov o3.w, r0.w
else
add r0.xyz, r0, -c4
dp3 r0.x, r0, r0
rsq r0.x, r0.x
rcp r0.x, r0.x
mov r1.z, c4.z
add r2, -r1.z, c24
sge r0.y, c5.x, r0_abs.z
lrp r1.x, r0.y, c5.x, r0.z
rcp r0.y, r1.x
mul_sat r2, r0.y, r2
add r1, -r1.z, c25
mul_sat r1, r0.y, r1
add r0, r0.x, -c23
max r0, r0, c5.z
add r1, -r2, r1
mul r0, r0, r1_abs
slt r1, r0, c22
mul r0, r0, c21
exp r2.x, r0.x
exp r2.y, r0.y
exp r2.z, r0.z
exp r2.w, r0.w
mul r0, r1, r2
mad r1, r1, r2, c5.w
mul r2.xyz, r1.x, c10
mov r2.w, r0.x
mul r2, r0.y, r2
mad r2.xyz, r1.y, c11, r2
mul r2, r0.z, r2
mad r2.xyz, r1.z, c12, r2
mul r0, r0.w, r2
mad o3.xyz, r1.w, c13, r0
mov o3.w, r0.w
endif
mov o0.xy, v3
mov o1, v4
mov o2, v5
mov o4, r3
mov o5.w, c5.y
mov o6, r3
// approximately 123 instruction slots used
Lesson 2
Before removing the Pixel + Vertex Shader
Vertex Shader as above (Lesson 1).
Pixel Shader:
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022
//
// Parameters:
//
// float4 MinZ_MaxZRatio;
// float NvStereoEnabled;
// sampler2D NvStereoFixTexture;
// sampler2D SceneColorTexture;
// float4 ScreenPositionScaleBias;
// sampler2D Texture2D_0;
// sampler2D Texture2D_1;
// sampler2D Texture2D_2;
// sampler2D Texture2D_3;
// float UniformPixelScalar_17;
// float UniformPixelScalar_18;
// float UniformPixelScalar_20;
// float UniformPixelScalar_21;
// float4 UniformPixelVector_0;
// float4 UniformPixelVector_1;
// float4 UniformPixelVector_2;
// float4 UniformPixelVector_3;
// float4 UniformPixelVector_4;
//
//
// Registers:
//
// Name Reg Size
// ----------------------- ----- ----
// UniformPixelVector_0 c0 1
// ScreenPositionScaleBias c1 1
// MinZ_MaxZRatio c2 1
// NvStereoEnabled c3 1
// UniformPixelVector_1 c4 1
// UniformPixelVector_2 c5 1
// UniformPixelVector_3 c6 1
// UniformPixelVector_4 c7 1
// UniformPixelScalar_17 c8 1
// UniformPixelScalar_18 c9 1
// UniformPixelScalar_20 c10 1
// UniformPixelScalar_21 c11 1
// SceneColorTexture s0 1
// NvStereoFixTexture s1 1
// Texture2D_0 s2 1
// Texture2D_1 s3 1
// Texture2D_2 s4 1
// Texture2D_3 s5 1
//
ps_3_0
def c12, 1.5, 1, 0.5, -1
def c13, 0, 2, 0.100000001, 1
def c14, 8, 0.800000012, 0.0625, 0
def c15, 65503, 512, -0.00100000005, 1000
dcl_texcoord4 v0
dcl_texcoord5 v1.xyw
dcl_texcoord6 v2.xyz
dcl_texcoord v3.xy
dcl_2d s0
dcl_2d s1
dcl_2d s2
dcl_2d s3
dcl_2d s4
dcl_2d s5
nrm r0.xyz, v2
mad r0.xyz, r0.z, c13.xxyw, -r0
mov r1.xyz, c12
add_pp r1.xyz, r1, c0
mov r2.xy, c4
mad r2.xy, v3, r2, c5
texld r2, r2, s2
mov r3.xy, c6
mad r2.xz, v3.xyyw, r3.xyyw, c7.xyyw
texld r3, r2.xzzw, s3
mad r0.w, r2.y, r3.y, c13.z
mad r0.w, r0.w, c12.x, c12.w
mov r1.w, c13.w
mad r0.w, c8.x, r0.w, r1.w
add r0.z, r0.z, c14.x
mul r0.z, r0.z, c14.y
rsq r0.z, r0.z
mad r2.x, r0.x, r0.z, c12.z
mov r2.y, v3.y
texld r2, r2, s4
mad r0.xy, r0, r0.z, c12.z
texld r3, r0, s5
mul r0.x, r2.x, r3.x
mul r0.x, r0.x, r0.w
mul r0.x, r0.x, c9.x
mul r0.y, c10.x, v1.w
min r2.x, r0.y, c13.w
mul r0.x, r0.x, r2.x
abs r0.y, c3.x
if_ne c3.x, -c3.x
texld r2, c14.zwzw, s1
add r0.z, -r2.y, v1.w
mad r2.x, r2.x, r0.z, v1.x
mov r2.yz, v1.xyww
else
mov r2.xyz, c13.x
endif
cmp r0.yzw, -r0.y, v1.xxyw, r2.xxyz
rcp r0.w, r0.w
mul r0.yz, r0.w, r0
mad r0.yz, r0, c1.xxyw, c1.xwzw
texld_pp r2, r0.yzzw, s0
min_pp r0.y, r2.w, c15.x
mad r0.y, r0.y, c2.z, -c2.w
rcp_pp r0.y, r0.y
add r0.z, r1.w, -c11.x
mul r0.w, r0.z, c15.y
add r0.y, r0.y, -v1.w
mad r0.z, r0.z, c15.y, c15.z
rcp r0.w, r0.w
cmp r0.z, r0.z, r0.w, c15.w
mul_sat r0.y, r0.z, r0.y
mul_pp oC0.w, r0.y, r0.x
mad_pp oC0.xyz, r1, v0.w, v0
// approximately 58 instruction slots used (6 texture, 52 arithmetic)
After removing/fixing the Pixel + Vertex Shader
Vertex Shade:
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022
//
// Parameters:
//
// float4 CameraPosition;
// float4 CameraRight;
// float4 CameraUp;
// float3 ExponentialFogColor;
// float3 ExponentialFogLightVector;
// float3 ExponentialFogParameters;
// float4 FogDistanceScale;
// float4 FogExtinctionDistance;
// float4 FogInScattering[4];
// float4 FogMaxHeight;
// float4 FogMinHeight;
// float4 FogStartDistance;
// float3 LightInscatteringColor;
// float4x4 LocalToWorld;
// float4x4 ViewProjectionMatrix;
// float bUseExponentialHeightFog;
//
//
// Registers:
//
// Name Reg Size
// ------------------------- ----- ----
// ViewProjectionMatrix c0 4
// CameraPosition c4 1
// LocalToWorld c6 4
// FogInScattering c10 4
// CameraRight c14 1
// CameraUp c15 1
// bUseExponentialHeightFog c16 1
// ExponentialFogParameters c17 1
// ExponentialFogColor c18 1
// LightInscatteringColor c19 1
// ExponentialFogLightVector c20 1
// FogDistanceScale c21 1
// FogExtinctionDistance c22 1
// FogStartDistance c23 1
// FogMinHeight c24 1
// FogMaxHeight c25 1
//
vs_3_0
// approximately 123 instruction slots used
Pixel Shader:
//
// Generated by Microsoft (R) HLSL Shader Compiler 9.27.952.3022
//
// Parameters:
//
// float4 MinZ_MaxZRatio;
// float NvStereoEnabled;
// sampler2D NvStereoFixTexture;
// sampler2D SceneColorTexture;
// float4 ScreenPositionScaleBias;
// sampler2D Texture2D_0;
// sampler2D Texture2D_1;
// sampler2D Texture2D_2;
// sampler2D Texture2D_3;
// float UniformPixelScalar_17;
// float UniformPixelScalar_18;
// float UniformPixelScalar_20;
// float UniformPixelScalar_21;
// float4 UniformPixelVector_0;
// float4 UniformPixelVector_1;
// float4 UniformPixelVector_2;
// float4 UniformPixelVector_3;
// float4 UniformPixelVector_4;
//
//
// Registers:
//
// Name Reg Size
// ----------------------- ----- ----
// UniformPixelVector_0 c0 1
// ScreenPositionScaleBias c1 1
// MinZ_MaxZRatio c2 1
// NvStereoEnabled c3 1
// UniformPixelVector_1 c4 1
// UniformPixelVector_2 c5 1
// UniformPixelVector_3 c6 1
// UniformPixelVector_4 c7 1
// UniformPixelScalar_17 c8 1
// UniformPixelScalar_18 c9 1
// UniformPixelScalar_20 c10 1
// UniformPixelScalar_21 c11 1
// SceneColorTexture s0 1
// NvStereoFixTexture s1 1
// Texture2D_0 s2 1
// Texture2D_1 s3 1
// Texture2D_2 s4 1
// Texture2D_3 s5 1
//
ps_3_0
def c12, 1.5, 1, 0.5, -1
def c13, 0, 2, 0.100000001, 1
def c14, 8, 0.800000012, 0.0625, 0
def c15, 65503, 512, -0.00100000005, 1000
dcl_texcoord4 v0
dcl_texcoord5 v1.xyw
dcl_texcoord6 v2.xyz
dcl_texcoord v3.xy
dcl_2d s0
dcl_2d s1
dcl_2d s2
dcl_2d s3
dcl_2d s4
dcl_2d s5
nrm r0.xyz, v2
mad r0.xyz, r0.z, c13.xxyw, -r0
mov r1.xyz, c12
add_pp r1.xyz, r1, c0
mov r2.xy, c4
mad r2.xy, v3, r2, c5
texld r2, r2, s2
mov r3.xy, c6
mad r2.xz, v3.xyyw, r3.xyyw, c7.xyyw
texld r3, r2.xzzw, s3
mad r0.w, r2.y, r3.y, c13.z
mad r0.w, r0.w, c12.x, c12.w
mov r1.w, c13.w
mad r0.w, c8.x, r0.w, r1.w
add r0.z, r0.z, c14.x
mul r0.z, r0.z, c14.y
rsq r0.z, r0.z
mad r2.x, r0.x, r0.z, c12.z
mov r2.y, v3.y
texld r2, r2, s4
mad r0.xy, r0, r0.z, c12.z
texld r3, r0, s5
mul r0.x, r2.x, r3.x
mul r0.x, r0.x, r0.w
mul r0.x, r0.x, c9.x
mul r0.y, c10.x, v1.w
min r2.x, r0.y, c13.w
mul r0.x, r0.x, r2.x
abs r0.y, c3.x
if_ne c3.x, -c3.x
texld r2, c14.zwzw, s1
add r0.z, -r2.y, v1.w
mad r2.x, r2.x, r0.z, v1.x
mov r2.yz, v1.xyww
else
mov r2.xyz, c13.x
endif
cmp r0.yzw, -r0.y, v1.xxyw, r2.xxyz
rcp r0.w, r0.w
mul r0.yz, r0.w, r0
mad r0.yz, r0, c1.xxyw, c1.xwzw
texld_pp r2, r0.yzzw, s0
min_pp r0.y, r2.w, c15.x
mad r0.y, r0.y, c2.z, -c2.w
rcp_pp r0.y, r0.y
add r0.z, r1.w, -c11.x
mul r0.w, r0.z, c15.y
add r0.y, r0.y, -v1.w
mad r0.z, r0.z, c15.y, c15.z
rcp r0.w, r0.w
cmp r0.z, r0.z, r0.w, c15.w
mul_sat r0.y, r0.z, r0.y
mul_pp oC0.w, r0.y, r0.x
mad_pp oC0.xyz, r1, v0.w, v0
//Disable annoying bloom effect
mov oC0.xyzw, c14.wwww
// approximately 58 instruction slots used (6 texture, 52 arithmetic)