summaryrefslogtreecommitdiffstatshomepage
path: root/hlsl
diff options
context:
space:
mode:
author ImJezze <jezze@gmx.net>2015-07-11 20:01:24 +0200
committer ImJezze <jezze@gmx.net>2015-07-11 20:01:24 +0200
commit6e5f7f5d943c3cacee4de7f0bdd618ee96c83557 (patch)
tree6439a6397654d17a9f568c2bc64bb22a6e94ace6 /hlsl
parent35ad49dd032969062083e3db8637f9557727b60a (diff)
Refactoring
- separated downsample pass and bloom pass into two function calls - removed/replaced simple.fx by using primary.fx to render on screen - changed PostPass parameter of primary.fx to boolean - simplified bloom.fx and downsample.fx, Prescale parameter is now set correctly from outside depending on raster/vector rendering
Diffstat (limited to 'hlsl')
-rw-r--r--hlsl/bloom.fx34
-rw-r--r--hlsl/downsample.fx28
-rw-r--r--hlsl/primary.fx11
-rw-r--r--hlsl/simple.fx93
4 files changed, 20 insertions, 146 deletions
diff --git a/hlsl/bloom.fx b/hlsl/bloom.fx
index f6a0c9d57d1..9ed97bbd936 100644
--- a/hlsl/bloom.fx
+++ b/hlsl/bloom.fx
@@ -177,7 +177,7 @@ struct PS_INPUT
uniform float2 ScreenDims;
-uniform float2 Prescale = float2(8.0f, 8.0f);
+uniform float2 Prescale = float2(1.0f, 1.0f);
uniform float4 Level01Size;
uniform float4 Level23Size;
@@ -192,10 +192,6 @@ VS_OUTPUT vs_main(VS_INPUT Input)
{
VS_OUTPUT Output = (VS_OUTPUT)0;
- float2 ScreenDimsTexel = 1.0f / ScreenDims;
-
- float2 HalfPrescale = Prescale * 0.5f;
-
Output.Position = float4(Input.Position.xyz, 1.0f);
Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y;
@@ -204,26 +200,14 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Color = Input.Color;
- // Vector graphics is not prescaled it has the size of the screen
- if (PrepareVector)
- {
- Output.TexCoord01 = Input.Position.xyxy / ScreenDims.xyxy + 1.0f / Level01Size;
- Output.TexCoord23 = Input.Position.xyxy / ScreenDims.xyxy + 1.0f / Level23Size;
- Output.TexCoord45 = Input.Position.xyxy / ScreenDims.xyxy + 1.0f / Level45Size;
- Output.TexCoord67 = Input.Position.xyxy / ScreenDims.xyxy + 1.0f / Level67Size;
- Output.TexCoord89 = Input.Position.xyxy / ScreenDims.xyxy + 1.0f / Level89Size;
- Output.TexCoordA = Input.Position.xy / ScreenDims.xy + 1.0f / LevelASize;
- }
- else
- {
- Output.TexCoord01 = Input.Position.xyxy / ScreenDims.xyxy + HalfPrescale.xyxy / Level01Size;
- Output.TexCoord23 = Input.Position.xyxy / ScreenDims.xyxy + HalfPrescale.xyxy / Level23Size;
- Output.TexCoord45 = Input.Position.xyxy / ScreenDims.xyxy + HalfPrescale.xyxy / Level45Size;
- Output.TexCoord67 = Input.Position.xyxy / ScreenDims.xyxy + HalfPrescale.xyxy / Level67Size;
- Output.TexCoord89 = Input.Position.xyxy / ScreenDims.xyxy + HalfPrescale.xyxy / Level89Size;
- Output.TexCoordA = Input.Position.xy / ScreenDims.xy + HalfPrescale.xy / LevelASize;
- }
-
+ float2 TexCoord = Input.Position.xy / ScreenDims;
+ Output.TexCoord01 = TexCoord.xyxy + Prescale.xyxy / Level01Size;
+ Output.TexCoord23 = TexCoord.xyxy + Prescale.xyxy / Level23Size;
+ Output.TexCoord45 = TexCoord.xyxy + Prescale.xyxy / Level45Size;
+ Output.TexCoord67 = TexCoord.xyxy + Prescale.xyxy / Level67Size;
+ Output.TexCoord89 = TexCoord.xyxy + Prescale.xyxy / Level89Size;
+ Output.TexCoordA = TexCoord.xy + Prescale.xy / LevelASize;
+
return Output;
}
diff --git a/hlsl/downsample.fx b/hlsl/downsample.fx
index b7579fc24ed..18eaa8313c0 100644
--- a/hlsl/downsample.fx
+++ b/hlsl/downsample.fx
@@ -50,11 +50,7 @@ struct PS_INPUT
uniform float2 ScreenDims;
uniform float2 TargetSize;
-uniform float2 Prescale = float2(8.0f, 8.0f);
-
-uniform float BloomRescale;
-
-uniform bool PrepareVector = false;
+uniform float2 Prescale = float2(1.0f, 1.0f);
VS_OUTPUT vs_main(VS_INPUT Input)
{
@@ -71,22 +67,10 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Color = Input.Color;
float2 TexCoord = Input.Position.xy / ScreenDims;
-
- // Vector graphics is not prescaled it has the size of the screen
- if (PrepareVector)
- {
- Output.TexCoord01.xy = TexCoord + float2(-0.5f, -0.5f) * TargetTexelSize;
- Output.TexCoord01.zw = TexCoord + float2( 0.5f, -0.5f) * TargetTexelSize;
- Output.TexCoord23.xy = TexCoord + float2(-0.5f, 0.5f) * TargetTexelSize;
- Output.TexCoord23.zw = TexCoord + float2( 0.5f, 0.5f) * TargetTexelSize;
- }
- else
- {
- Output.TexCoord01.xy = TexCoord + float2(-0.5f, -0.5f) * TargetTexelSize * Prescale;
- Output.TexCoord01.zw = TexCoord + float2( 0.5f, -0.5f) * TargetTexelSize * Prescale;
- Output.TexCoord23.xy = TexCoord + float2(-0.5f, 0.5f) * TargetTexelSize * Prescale;
- Output.TexCoord23.zw = TexCoord + float2( 0.5f, 0.5f) * TargetTexelSize * Prescale;
- }
+ Output.TexCoord01.xy = TexCoord + float2(-0.5f, -0.5f) * TargetTexelSize * Prescale;
+ Output.TexCoord01.zw = TexCoord + float2( 0.5f, -0.5f) * TargetTexelSize * Prescale;
+ Output.TexCoord23.xy = TexCoord + float2(-0.5f, 0.5f) * TargetTexelSize * Prescale;
+ Output.TexCoord23.zw = TexCoord + float2( 0.5f, 0.5f) * TargetTexelSize * Prescale;
return Output;
}
@@ -102,7 +86,7 @@ float4 ps_main(PS_INPUT Input) : COLOR
float4 texel2 = tex2D(DiffuseSampler, Input.TexCoord23.xy);
float4 texel3 = tex2D(DiffuseSampler, Input.TexCoord23.zw);
- float4 outTexel = (texel0 + texel1 + texel2 + texel3) / 4.0 * BloomRescale;
+ float4 outTexel = (texel0 + texel1 + texel2 + texel3) / 4.0;
return float4(outTexel.rgb, 1.0f);
}
diff --git a/hlsl/primary.fx b/hlsl/primary.fx
index fd53bf572e8..ed73750185d 100644
--- a/hlsl/primary.fx
+++ b/hlsl/primary.fx
@@ -47,8 +47,7 @@ struct PS_INPUT
//-----------------------------------------------------------------------------
uniform float2 ScreenDims;
-uniform float PostPass;
-uniform float FixedAlpha;
+uniform bool PostPass;
uniform float Brighten;
VS_OUTPUT vs_main(VS_INPUT Input)
@@ -59,9 +58,11 @@ VS_OUTPUT vs_main(VS_INPUT Input)
Output.Position.xy /= ScreenDims;
Output.Position.y = 1.0f - Output.Position.y;
Output.Position.xy -= 0.5f;
- Output.Position *= float4(2.0f, 2.0f, 1.0f, 1.0f);
+ Output.Position.xy *= 2.0f;
+
+ Output.TexCoord = PostPass ? (Input.Position.xy / ScreenDims) : Input.TexCoord;
+
Output.Color = Input.Color;
- Output.TexCoord = lerp(Input.TexCoord, Input.Position.xy / ScreenDims, PostPass);
return Output;
}
@@ -86,8 +87,6 @@ technique TestTechnique
{
Lighting = FALSE;
- //Sampler[0] = <DiffuseSampler>;
-
VertexShader = compile vs_2_0 vs_main();
PixelShader = compile ps_2_0 ps_main();
}
diff --git a/hlsl/simple.fx b/hlsl/simple.fx
deleted file mode 100644
index e26ca3fbb36..00000000000
--- a/hlsl/simple.fx
+++ /dev/null
@@ -1,93 +0,0 @@
-// license:BSD-3-Clause
-// copyright-holders:Ryan Holtz,ImJezze
-//-----------------------------------------------------------------------------
-// Effect File Variables
-//-----------------------------------------------------------------------------
-
-texture DiffuseTexture;
-
-sampler DiffuseSampler = sampler_state
-{
- Texture = <DiffuseTexture>;
- 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;
-};
-
-//-----------------------------------------------------------------------------
-// Simple Vertex Shader
-//-----------------------------------------------------------------------------
-
-uniform float2 ScreenDims;
-
-VS_OUTPUT vs_main(VS_INPUT Input)
-{
- VS_OUTPUT Output = (VS_OUTPUT)0;
-
- Output.Position = float4(Input.Position.xyz, 1.0f);
- Output.Position.xy /= ScreenDims;
- Output.Position.y = 1.0f - Output.Position.y; // flip y
- Output.Position.xy -= 0.5f; // center
- Output.Position.xy *= 2.0f; // zoom
-
- Output.TexCoord = Input.Position.xy / ScreenDims;
-
- Output.Color = Input.Color;
-
- return Output;
-}
-
-//-----------------------------------------------------------------------------
-// Simple Pixel Shader
-//-----------------------------------------------------------------------------
-
-float4 ps_main(PS_INPUT Input) : COLOR
-{
- float4 texel = tex2D(DiffuseSampler, Input.TexCoord);
-
- return float4(texel.rgb, 1.0f);
-}
-
-//-----------------------------------------------------------------------------
-// Simple Effect
-//-----------------------------------------------------------------------------
-
-technique TestTechnique
-{
- pass Pass0
- {
- Lighting = FALSE;
-
- Sampler[0] = <DiffuseSampler>;
-
- VertexShader = compile vs_2_0 vs_main();
- PixelShader = compile ps_2_0 ps_main();
- }
-}