summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl
diff options
context:
space:
mode:
author Ryan Holtz <rholtz@batcountryentertainment.com>2013-01-21 02:40:48 +0000
committer Ryan Holtz <rholtz@batcountryentertainment.com>2013-01-21 02:40:48 +0000
commitd157249cb74fe849effaef21c1676a8cf17474e4 (patch)
treedb3388ea55fde34ff34e5f9f42da0521ebc6ea5e /hlsl
parent7f3372abf3800e185fa56b51d137e0c47e3357df (diff)
d3dhlsl.c: Add preliminary vector post-processing. [MooglyGuy]
Diffstat (limited to 'hlsl')
-rw-r--r--hlsl/bloom.fx242
-rw-r--r--hlsl/downsample.fx121
-rw-r--r--hlsl/focus.fx4
-rw-r--r--hlsl/phosphor.fx8
-rw-r--r--hlsl/post.fx1
-rw-r--r--hlsl/primary.fx3
-rw-r--r--hlsl/vector.fx33
7 files changed, 382 insertions, 30 deletions
diff --git a/hlsl/bloom.fx b/hlsl/bloom.fx
new file mode 100644
index 00000000000..cf8b603cece
--- /dev/null
+++ b/hlsl/bloom.fx
@@ -0,0 +1,242 @@
+//-----------------------------------------------------------------------------
+// Effect File Variables
+//-----------------------------------------------------------------------------
+
+texture DiffuseA;
+texture DiffuseB;
+texture DiffuseC;
+texture DiffuseD;
+texture DiffuseE;
+texture DiffuseF;
+texture DiffuseG;
+texture DiffuseH;
+texture DiffuseI;
+texture DiffuseJ;
+texture DiffuseK;
+
+sampler DiffuseSampler0 = sampler_state
+{
+ Texture = <DiffuseA>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+sampler DiffuseSampler1 = sampler_state
+{
+ Texture = <DiffuseB>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+sampler DiffuseSampler2 = sampler_state
+{
+ Texture = <DiffuseC>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+sampler DiffuseSampler3 = sampler_state
+{
+ Texture = <DiffuseD>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+sampler DiffuseSampler4 = sampler_state
+{
+ Texture = <DiffuseE>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+sampler DiffuseSampler5 = sampler_state
+{
+ Texture = <DiffuseF>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+sampler DiffuseSampler6 = sampler_state
+{
+ Texture = <DiffuseG>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+sampler DiffuseSampler7 = sampler_state
+{
+ Texture = <DiffuseH>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+sampler DiffuseSampler8 = sampler_state
+{
+ Texture = <DiffuseI>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+sampler DiffuseSampler9 = sampler_state
+{
+ Texture = <DiffuseJ>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+sampler DiffuseSampler10 = sampler_state
+{
+ Texture = <DiffuseK>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+//-----------------------------------------------------------------------------
+// Vertex Definitions
+//-----------------------------------------------------------------------------
+
+struct VS_OUTPUT
+{
+ float4 Position : POSITION;
+ float4 Color : COLOR0;
+ float2 TexCoord : TEXCOORD0;
+};
+
+struct VS_INPUT
+{
+ float3 Position : POSITION;
+ float4 Color : COLOR0;
+ float2 TexCoord : TEXCOORD0;
+};
+
+struct PS_INPUT
+{
+ float4 Color : COLOR0;
+ float2 TexCoord : TEXCOORD0;
+};
+
+//-----------------------------------------------------------------------------
+// Bloom Vertex Shader
+//-----------------------------------------------------------------------------
+
+uniform float2 TargetSize;
+
+uniform float DiffuseScaleA;
+uniform float DiffuseScaleB;
+uniform float DiffuseScaleC;
+uniform float DiffuseScaleD;
+uniform float DiffuseScaleE;
+uniform float DiffuseScaleF;
+uniform float DiffuseScaleG;
+uniform float DiffuseScaleH;
+uniform float DiffuseScaleI;
+uniform float DiffuseScaleJ;
+uniform float DiffuseScaleK;
+
+VS_OUTPUT vs_main(VS_INPUT Input)
+{
+ VS_OUTPUT Output = (VS_OUTPUT)0;
+
+ Output.Position = float4(Input.Position.xyz, 1.0f);
+ Output.Position.xy /= TargetSize;
+ Output.Position.y = 1.0f - Output.Position.y;
+ Output.Position.xy -= float2(0.5f, 0.5f);
+ Output.Position.xy *= float2(2.0f, 2.0f);
+ Output.Color = Input.Color;
+ float2 inversePixel = 1.0f / TargetSize;
+ Output.TexCoord = Input.Position.xy * inversePixel;
+
+ return Output;
+}
+
+//-----------------------------------------------------------------------------
+// Bloom Pixel Shader
+//-----------------------------------------------------------------------------
+
+float4 ps_main(PS_INPUT Input) : COLOR
+{
+ float3 texel0 = tex2D(DiffuseSampler0, Input.TexCoord).rgb * DiffuseScaleA * 1.00f;
+ float3 texel1 = tex2D(DiffuseSampler1, Input.TexCoord).rgb * DiffuseScaleB * 0.95f;
+ float3 texel2 = tex2D(DiffuseSampler2, Input.TexCoord).rgb * DiffuseScaleC * 0.85f;
+ float3 texel3 = tex2D(DiffuseSampler3, Input.TexCoord).rgb * DiffuseScaleD * 0.75f;
+ float3 texel4 = tex2D(DiffuseSampler4, Input.TexCoord).rgb * DiffuseScaleE * 0.65f;
+ float3 texel5 = tex2D(DiffuseSampler5, Input.TexCoord).rgb * DiffuseScaleF * 0.55f;
+ float3 texel6 = tex2D(DiffuseSampler6, Input.TexCoord).rgb * DiffuseScaleG * 0.45f;
+ float3 texel7 = tex2D(DiffuseSampler7, Input.TexCoord).rgb * DiffuseScaleH * 0.35f;
+ float3 texel8 = tex2D(DiffuseSampler8, Input.TexCoord).rgb * DiffuseScaleI * 0.25f;
+ float3 texel9 = tex2D(DiffuseSampler9, Input.TexCoord).rgb * DiffuseScaleJ * 0.15f;
+ float3 texel10 = tex2D(DiffuseSampler10, Input.TexCoord).rgb * DiffuseScaleK * 0.10f;
+ return float4(texel0 + texel1 + texel2 + texel3 + texel4 +
+ texel5 + texel6 + texel7 + texel8 + texel9 + texel10, 1.0f);
+}
+
+//-----------------------------------------------------------------------------
+// Downsample Effect
+//-----------------------------------------------------------------------------
+
+technique TestTechnique
+{
+ pass Pass0
+ {
+ Lighting = FALSE;
+
+ Sampler[0] = <DiffuseSampler0>; // 2048x2048
+ Sampler[1] = <DiffuseSampler1>; // 1024x1024
+ Sampler[2] = <DiffuseSampler2>; // 512x512
+ Sampler[3] = <DiffuseSampler3>; // 256x256
+ Sampler[4] = <DiffuseSampler4>; // 128x128
+ Sampler[5] = <DiffuseSampler5>; // 64x64
+ Sampler[6] = <DiffuseSampler6>; // 32x32
+ Sampler[7] = <DiffuseSampler7>; // 16x16
+ Sampler[8] = <DiffuseSampler8>; // 8x8
+ Sampler[9] = <DiffuseSampler9>; // 4x4
+ Sampler[10] = <DiffuseSampler10>; // 2x2
+
+ VertexShader = compile vs_3_0 vs_main();
+ PixelShader = compile ps_3_0 ps_main();
+ }
+}
diff --git a/hlsl/downsample.fx b/hlsl/downsample.fx
new file mode 100644
index 00000000000..5e0de0ca46d
--- /dev/null
+++ b/hlsl/downsample.fx
@@ -0,0 +1,121 @@
+//-----------------------------------------------------------------------------
+// Effect File Variables
+//-----------------------------------------------------------------------------
+
+texture Diffuse;
+
+sampler DiffuseSampler = sampler_state
+{
+ Texture = <Diffuse>;
+ MipFilter = LINEAR;
+ MinFilter = LINEAR;
+ MagFilter = LINEAR;
+ AddressU = CLAMP;
+ AddressV = CLAMP;
+ AddressW = CLAMP;
+};
+
+//-----------------------------------------------------------------------------
+// Vertex Definitions
+//-----------------------------------------------------------------------------
+
+struct VS_OUTPUT
+{
+ float4 Position : POSITION;
+ float4 Color : COLOR0;
+ float4 TexCoord01 : TEXCOORD0;
+ float4 TexCoord23 : TEXCOORD1;
+ float4 TexCoord45 : TEXCOORD2;
+ float4 TexCoord67 : TEXCOORD3;
+ float4 TexCoord89 : TEXCOORD4;
+};
+
+struct VS_INPUT
+{
+ float3 Position : POSITION;
+ float4 Color : COLOR0;
+ float2 TexCoord : TEXCOORD0;
+};
+
+struct PS_INPUT
+{
+ float4 Color : COLOR0;
+ float4 TexCoord01 : TEXCOORD0;
+ float4 TexCoord23 : TEXCOORD1;
+ float4 TexCoord45 : TEXCOORD2;
+ float4 TexCoord67 : TEXCOORD3;
+ float4 TexCoord89 : TEXCOORD4;
+};
+
+//-----------------------------------------------------------------------------
+// Downsample Vertex Shader
+//-----------------------------------------------------------------------------
+
+uniform float2 TargetSize;
+uniform float2 SourceSize;
+
+uniform float2 Defocus = float2(0.0f, 0.0f);
+
+uniform float Brighten;
+
+VS_OUTPUT vs_main(VS_INPUT Input)
+{
+ VS_OUTPUT Output = (VS_OUTPUT)0;
+
+ Output.Position = float4(Input.Position.xyz, 1.0f);
+ Output.Position.xy /= TargetSize;
+ Output.Position.y = 1.0f - Output.Position.y;
+ Output.Position.xy -= float2(0.5f, 0.5f);
+ Output.Position.xy *= float2(2.0f, 2.0f);
+ Output.Color = Input.Color;
+ float2 inversePixel = 1.0f / TargetSize;
+ Output.TexCoord01.xy = Input.Position.xy * inversePixel + float2(0.75f - 0.5f, 0.32f - 0.5f) * inversePixel;
+ Output.TexCoord01.zw = Input.Position.xy * inversePixel + float2(0.35f - 0.5f, 0.65f - 0.5f) * inversePixel;
+ Output.TexCoord23.xy = Input.Position.xy * inversePixel + float2(0.31f - 0.5f, 1.25f - 0.5f) * inversePixel;
+ Output.TexCoord23.zw = Input.Position.xy * inversePixel + float2(0.58f - 0.5f, 1.61f - 0.5f) * inversePixel;
+ Output.TexCoord45.xy = Input.Position.xy * inversePixel + float2(1.00f - 0.5f, 1.75f - 0.5f) * inversePixel;
+ Output.TexCoord45.zw = Input.Position.xy * inversePixel + float2(1.35f - 0.5f, 1.64f - 0.5f) * inversePixel;
+ Output.TexCoord67.xy = Input.Position.xy * inversePixel + float2(1.65f - 0.5f, 1.32f - 0.5f) * inversePixel;
+ Output.TexCoord67.zw = Input.Position.xy * inversePixel + float2(1.72f - 0.5f, 0.93f - 0.5f) * inversePixel;
+ Output.TexCoord89.xy = Input.Position.xy * inversePixel + float2(1.57f - 0.5f, 0.57f - 0.5f) * inversePixel;
+ Output.TexCoord89.zw = Input.Position.xy * inversePixel + float2(1.25f - 0.5f, 0.33f - 0.5f) * inversePixel;
+
+ return Output;
+}
+
+//-----------------------------------------------------------------------------
+// Downsample Pixel Shader
+//-----------------------------------------------------------------------------
+
+float4 ps_main(PS_INPUT Input) : COLOR
+{
+ float4 texel0 = tex2D(DiffuseSampler, Input.TexCoord01.xy);
+ float4 texel1 = tex2D(DiffuseSampler, Input.TexCoord01.zw);
+ float4 texel2 = tex2D(DiffuseSampler, Input.TexCoord23.xy);
+ float4 texel3 = tex2D(DiffuseSampler, Input.TexCoord23.zw);
+ float4 texel4 = tex2D(DiffuseSampler, Input.TexCoord45.xy);
+ float4 texel5 = tex2D(DiffuseSampler, Input.TexCoord45.zw);
+ float4 texel6 = tex2D(DiffuseSampler, Input.TexCoord67.xy);
+ float4 texel7 = tex2D(DiffuseSampler, Input.TexCoord67.zw);
+ float4 texel8 = tex2D(DiffuseSampler, Input.TexCoord89.xy);
+ float4 texel9 = tex2D(DiffuseSampler, Input.TexCoord89.zw);
+ float4 outTexel = (texel0 + texel1 + texel2 + texel3 + texel4 + texel5 + texel6 + texel7 + texel8 + texel9) * 0.1f;
+ return float4(outTexel.rgb, 1.0f);
+}
+
+//-----------------------------------------------------------------------------
+// Downsample Effect
+//-----------------------------------------------------------------------------
+
+technique TestTechnique
+{
+ pass Pass0
+ {
+ Lighting = FALSE;
+
+ Sampler[0] = <DiffuseSampler>;
+
+ VertexShader = compile vs_2_0 vs_main();
+ PixelShader = compile ps_2_0 ps_main();
+ }
+}
diff --git a/hlsl/focus.fx b/hlsl/focus.fx
index de660af7d24..37079af55a2 100644
--- a/hlsl/focus.fx
+++ b/hlsl/focus.fx
@@ -60,11 +60,7 @@ struct PS_INPUT
uniform float TargetWidth;
uniform float TargetHeight;
-uniform float WidthRatio;
-uniform float HeightRatio;
-
uniform float2 Defocus = float2(0.0f, 0.0f);
-uniform float FocusEnable;
float2 Coord0Offset = float2( 0.0f, 0.0f);
float2 Coord1Offset = float2(-0.2f, -0.6f);
diff --git a/hlsl/phosphor.fx b/hlsl/phosphor.fx
index 40d97cbf3ee..f6ba4573c49 100644
--- a/hlsl/phosphor.fx
+++ b/hlsl/phosphor.fx
@@ -61,12 +61,6 @@ struct PS_INPUT
uniform float TargetWidth;
uniform float TargetHeight;
-uniform float RawWidth;
-uniform float RawHeight;
-
-uniform float WidthRatio;
-uniform float HeightRatio;
-
uniform float TextureWidth;
uniform float TextureHeight;
@@ -86,7 +80,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Color = Input.Color;
float2 InvTexSize = float2(1.0f / TextureWidth, 1.0f / TextureHeight);
- Output.TexCoord = Input.TexCoord + float2(0.5f, 0.5f) * InvTexSize;
+ Output.TexCoord = Input.TexCoord + float2(1.0f, 1.0f) * InvTexSize;
Output.PrevCoord = Output.TexCoord;
return Output;
diff --git a/hlsl/post.fx b/hlsl/post.fx
index 94c039219e6..4176a78b197 100644
--- a/hlsl/post.fx
+++ b/hlsl/post.fx
@@ -180,6 +180,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
Output.r = pow(Output.r, Power.r);
Output.g = pow(Output.g, Power.g);
Output.b = pow(Output.b, Power.b);
+ Output.a = 1.0f;
return Output;
}
diff --git a/hlsl/primary.fx b/hlsl/primary.fx
index b2f9d0f6826..53653cfba16 100644
--- a/hlsl/primary.fx
+++ b/hlsl/primary.fx
@@ -47,6 +47,7 @@ uniform float TargetWidth;
uniform float TargetHeight;
uniform float PostPass;
uniform float FixedAlpha;
+uniform float Brighten;
VS_OUTPUT vs_main(VS_INPUT Input)
{
@@ -72,7 +73,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
float4 ps_main(PS_INPUT Input) : COLOR
{
float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
- return BaseTexel * Input.Color;
+ return BaseTexel * (Input.Color + float4(Brighten, Brighten, Brighten, 0.0f));
}
//-----------------------------------------------------------------------------
diff --git a/hlsl/vector.fx b/hlsl/vector.fx
index 066d7df1889..8b9aa6333f3 100644
--- a/hlsl/vector.fx
+++ b/hlsl/vector.fx
@@ -2,19 +2,6 @@
// Effect File Variables
//-----------------------------------------------------------------------------
-texture Diffuse;
-
-sampler DiffuseSampler = sampler_state
-{
- Texture = <Diffuse>;
- MipFilter = LINEAR;
- MinFilter = LINEAR;
- MagFilter = LINEAR;
- AddressU = CLAMP;
- AddressV = CLAMP;
- AddressW = CLAMP;
-};
-
//-----------------------------------------------------------------------------
// Vertex Definitions
//-----------------------------------------------------------------------------
@@ -45,6 +32,8 @@ struct PS_INPUT
uniform float TargetWidth;
uniform float TargetHeight;
+uniform float2 TimeParams;
+uniform float3 LengthParams;
VS_OUTPUT vs_main(VS_INPUT Input)
{
@@ -57,7 +46,7 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Position.x -= 0.5f;
Output.Position.y -= 0.5f;
Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
- Output.Color = float4(0.0f, 0.0f, Input.Color.z, 1.0f);
+ Output.Color = Input.Color;
Output.TexCoord = Input.Position.xy / float2(TargetWidth, TargetHeight);
return Output;
@@ -67,10 +56,20 @@ VS_OUTPUT vs_main(VS_INPUT Input)
// Simple Pixel Shader
//-----------------------------------------------------------------------------
+// TimeParams.x: Frame time of the vector
+// TimeParams.y: How much frame time affects the vector's fade
+// LengthParams.x: Length of the vector
+// LengthParams.y: How much length affects the vector's fade
+// LengthParams.z: Size at which fade is maximum
float4 ps_main(PS_INPUT Input) : COLOR
{
- float4 BaseTexel = tex2D(DiffuseSampler, Input.TexCoord);
- return BaseTexel * Input.Color;
+ float timeModulate = lerp(1.0f, TimeParams.x, TimeParams.y) * 2.0;
+
+ float lengthModulate = clamp(1.0f - LengthParams.x / LengthParams.z, 0.0f, 1.0f);
+ lengthModulate = lerp(1.0f, timeModulate * lengthModulate, LengthParams.y) * 2.0;
+
+ float4 outColor = Input.Color * float4(lengthModulate, lengthModulate, lengthModulate, 1.0f) * 2.5;
+ return outColor;
}
//-----------------------------------------------------------------------------
@@ -83,8 +82,6 @@ technique TestTechnique
{
Lighting = FALSE;
- //Sampler[0] = <DiffuseSampler>;
-
VertexShader = compile vs_2_0 vs_main();
PixelShader = compile ps_2_0 ps_main();
}