112Shaders/postfx_lineardepth.fx
2021-12-28 10:06:46 +01:00

117 lines
3.4 KiB
HLSL

string DefaultParameterScopeBlock = "material"; // 1
float3 AmbientLightColor <bool unmanaged = 1;> = { 0.3, 0.3, 0.3 };
struct {
float3 Color;
float3 Direction;
} DirectionalLight[3] <bool unmanaged = 1;> = { 1.625198, 1.512711, 1.097048, 0.62914, -0.34874, 0.69465, 0.5232916, 0.6654605, 0.7815244, -0.32877, 0.90329, 0.27563, 0.4420466, 0.4102767, 0.4420466, -0.80704, -0.58635, 0.06975 };
struct {
float3 Color;
float3 Position;
float2 Range_Inner_Outer;
} PointLight[8] <bool unmanaged = 1;>;
struct {
float4 WorldPositionMultiplier_XYZZ;
float2 CurrentOffsetUV;
} Cloud <bool unmanaged = 1;>;
float3 NoCloudMultiplier <bool unmanaged = 1;> = { 1, 1, 1 };
float3 RecolorColorDummy <bool unmanaged = 1;>;
row_major float4x4 ShadowMapWorldToShadow <bool unmanaged = 1;>;
float OpacityOverride <bool unmanaged = 1;> = { 1 };
float3 TintColor <bool unmanaged = 1;> = { 1, 1, 1 };
float3 EyePosition <bool unmanaged = 1;>;
row_major float4x4 ViewProjection <bool unmanaged = 1;>;
float4 WorldBones[128] <bool unmanaged = 1;>;
column_major float4x4 ProjectionI : ProjectionInverse : register(ps_2_0, c11);
texture DepthBufferSampler <string SasBindAddress = "PostEffect.DepthBufferTexture";>; // 2
sampler2D DepthBufferSamplerSampler : register(ps_2_0, s0) <string Texture = "DepthBufferSampler"; string SasBindAddress = "PostEffect.DepthBufferTexture";> =
sampler_state
{
Texture = <DepthBufferSampler>; // 4
MinFilter = 1;
MagFilter = 1;
MipFilter = 1;
AddressU = 3;
AddressV = 3;
};
// LinearDepth_PixelShader1 Pixel_2_0 Has PRES False
float4 LinearDepth_PixelShader1(float2 texcoord : TEXCOORD) : COLOR
{
float4 out_color;
float4 temp0;
float3 temp1;
// def c0, -1, 1, 0, 0
// def c1, 0, 2, -2, 1
// dcl t0.xy
// dcl_2d s0
// texld r0, t0, s0
temp0 = tex2D(DepthBufferSamplerSampler, texcoord.xy);
// mov r0.z, r0.x
temp0.z = temp0.x;
// mov r1.yz, c1
temp1.yz = float2(2, -2);
// mad r0.xy, t0, r1.yzxw, c0
temp0.xy = texcoord.xy * temp1.yz + float2(-1, 1);
// mov r0.w, c1.w
temp0.w = float1(1);
// dp4 r1.x, r0, c14
temp1.x = dot(temp0, (ProjectionI._m03_m13_m23_m33));
// dp4 r0.x, r0, c13
temp0.x = dot(temp0, (ProjectionI._m02_m12_m22_m32));
// rcp r0.y, r1.x
temp0.y = 1.0f / temp1.x;
// mul r0.xyz, r0.x, r0.y
temp0.xyz = temp0.x * temp0.y;
// mov r0.w, c1.w
temp0.w = float1(1);
// mov oC0, r0
out_color = temp0;
//
return out_color;
}
// LinearDepth_VertexShader2 Vertex_2_0 Has PRES False
struct LinearDepth_VertexShader2_Input
{
float4 position : POSITION;
float4 texcoord : TEXCOORD;
};
struct LinearDepth_VertexShader2_Output
{
float4 position : POSITION;
float2 texcoord : TEXCOORD;
};
LinearDepth_VertexShader2_Output LinearDepth_VertexShader2(LinearDepth_VertexShader2_Input i)
{
LinearDepth_VertexShader2_Output o;
// def c0, 1, 0, 0, 0
// dcl_position v0
// dcl_texcoord v1
// mov oPos.xyz, v0
o.position.xyz = i.position.xyz;
// mov oPos.w, c0.x
o.position.w = float1(1);
// mov oT0.xy, v1
o.texcoord = i.texcoord;
//
return o;
}
technique LinearDepth
{
pass p0
{
VertexShader = compile vs_2_0 LinearDepth_VertexShader2(); // 7
PixelShader = compile ps_2_0 LinearDepth_PixelShader1(); // 8
ZEnable = 0;
ZWriteEnable = 0;
CullMode = 1;
AlphaBlendEnable = 0;
AlphaTestEnable = 0;
}
}